jazz-tools 2.0.0-alpha.60 → 2.0.0-alpha.61

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 (544) hide show
  1. package/README.md +1 -1
  2. package/bin/jazz-tools.js +3 -0
  3. package/dist/_dev/native-account-session.d.ts +8 -1
  4. package/dist/_dev/native-account-session.d.ts.map +1 -1
  5. package/dist/_dev/native-account-session.js +10 -0
  6. package/dist/_dev/native-account-session.js.map +1 -1
  7. package/dist/accounts/account-manager-core.d.ts +6 -0
  8. package/dist/accounts/account-manager-core.d.ts.map +1 -1
  9. package/dist/accounts/account-manager-core.js +26 -2
  10. package/dist/accounts/account-manager-core.js.map +1 -1
  11. package/dist/accounts/enrollment.d.ts.map +1 -1
  12. package/dist/accounts/enrollment.js +11 -4
  13. package/dist/accounts/enrollment.js.map +1 -1
  14. package/dist/accounts/exports.d.ts +1 -2
  15. package/dist/accounts/exports.d.ts.map +1 -1
  16. package/dist/accounts/exports.js +4 -1
  17. package/dist/accounts/exports.js.map +1 -1
  18. package/dist/accounts/persistence.d.ts +8 -0
  19. package/dist/accounts/persistence.d.ts.map +1 -1
  20. package/dist/accounts/persistence.js +12 -0
  21. package/dist/accounts/persistence.js.map +1 -1
  22. package/dist/accounts/registry-client.d.ts +20 -0
  23. package/dist/accounts/registry-client.d.ts.map +1 -1
  24. package/dist/accounts/registry-client.js +34 -0
  25. package/dist/accounts/registry-client.js.map +1 -1
  26. package/dist/accounts/state.d.ts.map +1 -1
  27. package/dist/accounts/state.js +2 -1
  28. package/dist/accounts/state.js.map +1 -1
  29. package/dist/backend/create-jazz-session.d.ts +9 -7
  30. package/dist/backend/create-jazz-session.d.ts.map +1 -1
  31. package/dist/backend/create-jazz-session.js +55 -17
  32. package/dist/backend/create-jazz-session.js.map +1 -1
  33. package/dist/backend/create-jazz.d.ts +122 -34
  34. package/dist/backend/create-jazz.d.ts.map +1 -1
  35. package/dist/backend/create-jazz.js +396 -101
  36. package/dist/backend/create-jazz.js.map +1 -1
  37. package/dist/backend/early-db.d.ts.map +1 -1
  38. package/dist/backend/early-db.js +1 -0
  39. package/dist/backend/early-db.js.map +1 -1
  40. package/dist/backend/from-jwt.d.ts +2 -2
  41. package/dist/backend/from-jwt.d.ts.map +1 -1
  42. package/dist/backend/from-jwt.js +7 -1
  43. package/dist/backend/from-jwt.js.map +1 -1
  44. package/dist/backend/index.d.ts +2 -1
  45. package/dist/backend/index.d.ts.map +1 -1
  46. package/dist/backend/index.js +3 -1
  47. package/dist/backend/index.js.map +1 -1
  48. package/dist/backend/inspect-ui.d.ts +14 -0
  49. package/dist/backend/inspect-ui.d.ts.map +1 -0
  50. package/dist/backend/inspect-ui.js +156 -0
  51. package/dist/backend/inspect-ui.js.map +1 -0
  52. package/dist/backend/inspect.d.ts +129 -0
  53. package/dist/backend/inspect.d.ts.map +1 -0
  54. package/dist/backend/inspect.js +763 -0
  55. package/dist/backend/inspect.js.map +1 -0
  56. package/dist/backend/inspector-ui/0.js +2 -0
  57. package/dist/backend/inspector-ui/1.js +2 -0
  58. package/dist/backend/inspector-ui/10.js +2 -0
  59. package/dist/backend/inspector-ui/11.js +2 -0
  60. package/dist/backend/inspector-ui/12.js +2 -0
  61. package/dist/backend/inspector-ui/13.js +2 -0
  62. package/dist/backend/inspector-ui/14.js +2 -0
  63. package/dist/backend/inspector-ui/15.js +2 -0
  64. package/dist/backend/inspector-ui/16.js +2 -0
  65. package/dist/backend/inspector-ui/17.js +2 -0
  66. package/dist/backend/inspector-ui/18.js +2 -0
  67. package/dist/backend/inspector-ui/19.js +2 -0
  68. package/dist/backend/inspector-ui/2.js +2 -0
  69. package/dist/backend/inspector-ui/20.js +2 -0
  70. package/dist/backend/inspector-ui/3.js +2 -0
  71. package/dist/backend/inspector-ui/4.js +2 -0
  72. package/dist/backend/inspector-ui/5.js +2 -0
  73. package/dist/backend/inspector-ui/6.js +2 -0
  74. package/dist/backend/inspector-ui/7.js +2 -0
  75. package/dist/backend/inspector-ui/8.js +2 -0
  76. package/dist/backend/inspector-ui/9.js +2 -0
  77. package/dist/backend/inspector-ui-files.d.ts +4 -0
  78. package/dist/backend/inspector-ui-files.d.ts.map +1 -0
  79. package/dist/backend/inspector-ui-files.js +25 -0
  80. package/dist/backend/session-expiry.d.ts +61 -0
  81. package/dist/backend/session-expiry.d.ts.map +1 -0
  82. package/dist/backend/session-expiry.js +102 -0
  83. package/dist/backend/session-expiry.js.map +1 -0
  84. package/dist/backend/upgrade-status.d.ts +19 -0
  85. package/dist/backend/upgrade-status.d.ts.map +1 -0
  86. package/dist/backend/upgrade-status.js +55 -0
  87. package/dist/backend/upgrade-status.js.map +1 -0
  88. package/dist/backend/vercel-sockets.d.ts +16 -0
  89. package/dist/backend/vercel-sockets.d.ts.map +1 -0
  90. package/dist/backend/vercel-sockets.js +24 -0
  91. package/dist/backend/vercel-sockets.js.map +1 -0
  92. package/dist/backend/vercel-store.d.ts.map +1 -1
  93. package/dist/backend/vercel-store.js +77 -10
  94. package/dist/backend/vercel-store.js.map +1 -1
  95. package/dist/classic-api.d.ts.map +1 -1
  96. package/dist/classic-api.js +36 -0
  97. package/dist/classic-api.js.map +1 -1
  98. package/dist/cli.d.ts.map +1 -1
  99. package/dist/cli.js +30 -2
  100. package/dist/cli.js.map +1 -1
  101. package/dist/client/index.d.ts +2 -6
  102. package/dist/client/index.d.ts.map +1 -1
  103. package/dist/client/index.js +2 -3
  104. package/dist/client/index.js.map +1 -1
  105. package/dist/cloud/credentials.d.ts +1 -1
  106. package/dist/cloud/credentials.d.ts.map +1 -1
  107. package/dist/cloud/credentials.js.map +1 -1
  108. package/dist/dev/catalogue.d.ts +12 -0
  109. package/dist/dev/catalogue.d.ts.map +1 -1
  110. package/dist/dev/catalogue.js +31 -0
  111. package/dist/dev/catalogue.js.map +1 -1
  112. package/dist/dev/inspector-overlay/embedded/assets/backend-DHeT1LCS.css +1 -0
  113. package/dist/dev/inspector-overlay/embedded/assets/backend-Dt5FYVfX.js +1 -0
  114. package/dist/dev/inspector-overlay/embedded/assets/{create-legacy-browser-delegate-X_T_QKCN.js → create-legacy-browser-delegate-Bf58kV5i.js} +1 -1
  115. package/dist/dev/inspector-overlay/embedded/assets/esm-BQhYkCKN.js +1 -0
  116. package/dist/dev/inspector-overlay/embedded/assets/{esm-aRzpnC3u.js → esm-CI6IodCN.js} +1 -1
  117. package/dist/dev/inspector-overlay/embedded/assets/{esm-ezD5H765.js → esm-D5aLlEYl.js} +1 -1
  118. package/dist/dev/inspector-overlay/embedded/assets/{esm-7mP3GQX4.js → esm-D_R-EGgt.js} +1 -1
  119. package/dist/dev/inspector-overlay/embedded/assets/{esm-BX6IY2Mv.js → esm-WihpI9g6.js} +1 -1
  120. package/dist/dev/inspector-overlay/embedded/assets/index-CjhxdwQ7.js +1 -0
  121. package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-CaVlHITU.js +3 -0
  122. package/dist/dev/inspector-overlay/embedded/assets/{jazz-broker-worker-XRRxJUcx.js → jazz-broker-worker-D-HQuhdu.js} +160 -557
  123. package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-t1Mm3faf.js +1 -0
  124. package/dist/dev/inspector-overlay/embedded/assets/{jazz_wasm_bg-KR7h3v27.wasm → jazz_wasm_bg-BazWJnU4.wasm} +0 -0
  125. package/dist/dev/inspector-overlay/embedded/assets/{index-C78Pprka.css → src-Cq8gSOLx.css} +1 -1
  126. package/dist/dev/inspector-overlay/embedded/assets/src-Dg6641Mj.js +22 -0
  127. package/dist/dev/inspector-overlay/embedded/assets/{trace-api-B5CaetI0.js → trace-api-BctnwbUf.js} +1 -1
  128. package/dist/dev/inspector-overlay/embedded/backend.html +16 -0
  129. package/dist/dev/inspector-overlay/embedded/embedded.html +3 -2
  130. package/dist/dev/inspector-overlay/host-bridge.d.ts.map +1 -1
  131. package/dist/dev/inspector-overlay/host-bridge.js +4 -1
  132. package/dist/dev/inspector-overlay/host-bridge.js.map +1 -1
  133. package/dist/dev/inspector-overlay/loader.d.ts +12 -1
  134. package/dist/dev/inspector-overlay/loader.d.ts.map +1 -1
  135. package/dist/dev/inspector-overlay/loader.js +31 -4
  136. package/dist/dev/inspector-overlay/loader.js.map +1 -1
  137. package/dist/drivers/schema-wire.d.ts +6 -2
  138. package/dist/drivers/schema-wire.d.ts.map +1 -1
  139. package/dist/drivers/schema-wire.js +6 -2
  140. package/dist/drivers/schema-wire.js.map +1 -1
  141. package/dist/effect/jazz.d.ts +12 -5
  142. package/dist/effect/jazz.d.ts.map +1 -1
  143. package/dist/effect/jazz.js +28 -5
  144. package/dist/effect/jazz.js.map +1 -1
  145. package/dist/expo/create-account-manager.d.ts +1 -1
  146. package/dist/expo/create-account-manager.d.ts.map +1 -1
  147. package/dist/expo/create-jazz-session.d.ts +37 -17
  148. package/dist/expo/create-jazz-session.d.ts.map +1 -1
  149. package/dist/expo/create-jazz-session.js +49 -10
  150. package/dist/expo/create-jazz-session.js.map +1 -1
  151. package/dist/expo/index.d.ts +5 -8
  152. package/dist/expo/index.d.ts.map +1 -1
  153. package/dist/expo/index.js +5 -7
  154. package/dist/expo/index.js.map +1 -1
  155. package/dist/expo/provider.d.ts +6 -3
  156. package/dist/expo/provider.d.ts.map +1 -1
  157. package/dist/expo/provider.js +7 -6
  158. package/dist/expo/provider.js.map +1 -1
  159. package/dist/index.d.ts +2 -2
  160. package/dist/index.d.ts.map +1 -1
  161. package/dist/index.js +2 -1
  162. package/dist/index.js.map +1 -1
  163. package/dist/inspect/cli.d.ts +12 -0
  164. package/dist/inspect/cli.d.ts.map +1 -0
  165. package/dist/inspect/cli.js +292 -0
  166. package/dist/inspect/cli.js.map +1 -0
  167. package/dist/inspect/client.d.ts +60 -0
  168. package/dist/inspect/client.d.ts.map +1 -0
  169. package/dist/inspect/client.js +241 -0
  170. package/dist/inspect/client.js.map +1 -0
  171. package/dist/inspect/mcp.d.ts +17 -0
  172. package/dist/inspect/mcp.d.ts.map +1 -0
  173. package/dist/inspect/mcp.js +308 -0
  174. package/dist/inspect/mcp.js.map +1 -0
  175. package/dist/inspect/protocol.d.ts +218 -0
  176. package/dist/inspect/protocol.d.ts.map +1 -0
  177. package/dist/inspect/protocol.js +357 -0
  178. package/dist/inspect/protocol.js.map +1 -0
  179. package/dist/inspector/index.d.ts +10 -0
  180. package/dist/inspector/index.d.ts.map +1 -0
  181. package/dist/inspector/index.js +27 -0
  182. package/dist/inspector/index.js.map +1 -0
  183. package/dist/migrations.d.ts +1 -1
  184. package/dist/migrations.js +1 -1
  185. package/dist/migrations.js.map +1 -1
  186. package/dist/react/index.d.ts +4 -9
  187. package/dist/react/index.d.ts.map +1 -1
  188. package/dist/react/index.js +4 -6
  189. package/dist/react/index.js.map +1 -1
  190. package/dist/react/provider-props.d.ts +7 -0
  191. package/dist/react/provider-props.d.ts.map +1 -0
  192. package/dist/react/provider-props.js +15 -0
  193. package/dist/react/provider-props.js.map +1 -0
  194. package/dist/react/provider.d.ts +9 -15
  195. package/dist/react/provider.d.ts.map +1 -1
  196. package/dist/react/provider.js +19 -38
  197. package/dist/react/provider.js.map +1 -1
  198. package/dist/react-core/index.d.ts +3 -4
  199. package/dist/react-core/index.d.ts.map +1 -1
  200. package/dist/react-core/index.js +8 -4
  201. package/dist/react-core/index.js.map +1 -1
  202. package/dist/react-core/provider.d.ts +6 -6
  203. package/dist/react-core/provider.d.ts.map +1 -1
  204. package/dist/react-core/provider.js +5 -6
  205. package/dist/react-core/provider.js.map +1 -1
  206. package/dist/react-core/session.d.ts +41 -33
  207. package/dist/react-core/session.d.ts.map +1 -1
  208. package/dist/react-core/session.js +41 -89
  209. package/dist/react-core/session.js.map +1 -1
  210. package/dist/react-native/account-session.js +1 -1
  211. package/dist/react-native/account-session.js.map +1 -1
  212. package/dist/react-native/create-account-manager.d.ts +1 -1
  213. package/dist/react-native/create-account-manager.d.ts.map +1 -1
  214. package/dist/react-native/create-jazz-session.d.ts +37 -17
  215. package/dist/react-native/create-jazz-session.d.ts.map +1 -1
  216. package/dist/react-native/create-jazz-session.js +49 -10
  217. package/dist/react-native/create-jazz-session.js.map +1 -1
  218. package/dist/react-native/index.d.ts +5 -10
  219. package/dist/react-native/index.d.ts.map +1 -1
  220. package/dist/react-native/index.js +5 -7
  221. package/dist/react-native/index.js.map +1 -1
  222. package/dist/react-native/native-foreground-db.d.ts +7 -0
  223. package/dist/react-native/native-foreground-db.d.ts.map +1 -1
  224. package/dist/react-native/native-foreground-db.js +29 -0
  225. package/dist/react-native/native-foreground-db.js.map +1 -1
  226. package/dist/react-native/provider.d.ts +14 -19
  227. package/dist/react-native/provider.d.ts.map +1 -1
  228. package/dist/react-native/provider.js +19 -18
  229. package/dist/react-native/provider.js.map +1 -1
  230. package/dist/react-native/runtime-source.js +1 -1
  231. package/dist/react-native/runtime-source.js.map +1 -1
  232. package/dist/removed-api.d.ts +87 -0
  233. package/dist/removed-api.d.ts.map +1 -0
  234. package/dist/removed-api.js +95 -0
  235. package/dist/removed-api.js.map +1 -0
  236. package/dist/runtime/auth-secret-store.d.ts +0 -44
  237. package/dist/runtime/auth-secret-store.d.ts.map +1 -1
  238. package/dist/runtime/auth-secret-store.js +1 -103
  239. package/dist/runtime/auth-secret-store.js.map +1 -1
  240. package/dist/runtime/client.d.ts +10 -4
  241. package/dist/runtime/client.d.ts.map +1 -1
  242. package/dist/runtime/client.js.map +1 -1
  243. package/dist/runtime/connection-manager/browser-connection-manager.d.ts +4 -1
  244. package/dist/runtime/connection-manager/browser-connection-manager.d.ts.map +1 -1
  245. package/dist/runtime/connection-manager/browser-connection-manager.js +33 -2
  246. package/dist/runtime/connection-manager/browser-connection-manager.js.map +1 -1
  247. package/dist/runtime/connection-manager/types.d.ts +17 -2
  248. package/dist/runtime/connection-manager/types.d.ts.map +1 -1
  249. package/dist/runtime/connection-manager/types.js +19 -5
  250. package/dist/runtime/connection-manager/types.js.map +1 -1
  251. package/dist/runtime/credentialed-transport.d.ts +5 -2
  252. package/dist/runtime/credentialed-transport.d.ts.map +1 -1
  253. package/dist/runtime/credentialed-transport.js +12 -3
  254. package/dist/runtime/credentialed-transport.js.map +1 -1
  255. package/dist/runtime/db-replaced-error.d.ts +3 -1
  256. package/dist/runtime/db-replaced-error.d.ts.map +1 -1
  257. package/dist/runtime/db-replaced-error.js +4 -2
  258. package/dist/runtime/db-replaced-error.js.map +1 -1
  259. package/dist/runtime/db.d.ts +35 -7
  260. package/dist/runtime/db.d.ts.map +1 -1
  261. package/dist/runtime/db.js +65 -9
  262. package/dist/runtime/db.js.map +1 -1
  263. package/dist/runtime/index.d.ts +3 -4
  264. package/dist/runtime/index.d.ts.map +1 -1
  265. package/dist/runtime/index.js +1 -2
  266. package/dist/runtime/index.js.map +1 -1
  267. package/dist/runtime/native-artifact-fingerprint-napi.d.ts +1 -1
  268. package/dist/runtime/native-artifact-fingerprint-napi.js +1 -1
  269. package/dist/runtime/native-artifact-fingerprint-napi.js.map +1 -1
  270. package/dist/runtime/native-artifact-fingerprint-wasm.d.ts +1 -1
  271. package/dist/runtime/native-artifact-fingerprint-wasm.js +1 -1
  272. package/dist/runtime/native-artifact-fingerprint-wasm.js.map +1 -1
  273. package/dist/runtime/native-artifact-fingerprints.d.ts +2 -2
  274. package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts +3 -1
  275. package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts.map +1 -1
  276. package/dist/runtime/native-runtime/attached-browser-worker-connection.js.map +1 -1
  277. package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts +31 -0
  278. package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts.map +1 -0
  279. package/dist/runtime/native-runtime/broker-worker-load-failure.js +66 -0
  280. package/dist/runtime/native-runtime/broker-worker-load-failure.js.map +1 -0
  281. package/dist/runtime/native-runtime/browser-follower-connection.d.ts +5 -1
  282. package/dist/runtime/native-runtime/browser-follower-connection.d.ts.map +1 -1
  283. package/dist/runtime/native-runtime/browser-follower-connection.js +4 -3
  284. package/dist/runtime/native-runtime/browser-follower-connection.js.map +1 -1
  285. package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts +3 -1
  286. package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts.map +1 -1
  287. package/dist/runtime/native-runtime/browser-shared-worker-connection.js +55 -4
  288. package/dist/runtime/native-runtime/browser-shared-worker-connection.js.map +1 -1
  289. package/dist/runtime/native-runtime/browser-worker-protocol.d.ts +5 -0
  290. package/dist/runtime/native-runtime/browser-worker-protocol.d.ts.map +1 -1
  291. package/dist/runtime/native-runtime/browser-worker-protocol.js.map +1 -1
  292. package/dist/runtime/native-runtime/http-stream-socket.d.ts +25 -7
  293. package/dist/runtime/native-runtime/http-stream-socket.d.ts.map +1 -1
  294. package/dist/runtime/native-runtime/http-stream-socket.js +56 -29
  295. package/dist/runtime/native-runtime/http-stream-socket.js.map +1 -1
  296. package/dist/runtime/native-runtime/native-runtime-adapter.d.ts +13 -5
  297. package/dist/runtime/native-runtime/native-runtime-adapter.d.ts.map +1 -1
  298. package/dist/runtime/native-runtime/native-runtime-adapter.js +38 -10
  299. package/dist/runtime/native-runtime/native-runtime-adapter.js.map +1 -1
  300. package/dist/runtime/native-runtime/websocket.d.ts +13 -0
  301. package/dist/runtime/native-runtime/websocket.d.ts.map +1 -1
  302. package/dist/runtime/native-runtime/websocket.js +23 -4
  303. package/dist/runtime/native-runtime/websocket.js.map +1 -1
  304. package/dist/runtime/page-handle.d.ts +87 -0
  305. package/dist/runtime/page-handle.d.ts.map +1 -0
  306. package/dist/runtime/page-handle.js +144 -0
  307. package/dist/runtime/page-handle.js.map +1 -0
  308. package/dist/runtime/removed-provider-props.d.ts +17 -0
  309. package/dist/runtime/removed-provider-props.d.ts.map +1 -0
  310. package/dist/runtime/removed-provider-props.js +16 -0
  311. package/dist/runtime/removed-provider-props.js.map +1 -0
  312. package/dist/runtime/runtime-source.d.ts +4 -1
  313. package/dist/runtime/runtime-source.d.ts.map +1 -1
  314. package/dist/runtime/runtime-source.js.map +1 -1
  315. package/dist/runtime/store-held-by-another-tab-error.d.ts +11 -0
  316. package/dist/runtime/store-held-by-another-tab-error.d.ts.map +1 -1
  317. package/dist/runtime/store-held-by-another-tab-error.js +11 -0
  318. package/dist/runtime/store-held-by-another-tab-error.js.map +1 -1
  319. package/dist/runtime/sync-status.d.ts +60 -1
  320. package/dist/runtime/sync-status.d.ts.map +1 -1
  321. package/dist/runtime/sync-status.js +64 -4
  322. package/dist/runtime/sync-status.js.map +1 -1
  323. package/dist/session/backend-watch.d.ts +53 -14
  324. package/dist/session/backend-watch.d.ts.map +1 -1
  325. package/dist/session/backend-watch.js +99 -22
  326. package/dist/session/backend-watch.js.map +1 -1
  327. package/dist/session/config-options.d.ts +15 -0
  328. package/dist/session/config-options.d.ts.map +1 -0
  329. package/dist/session/config-options.js +55 -0
  330. package/dist/session/config-options.js.map +1 -0
  331. package/dist/session/consumer.d.ts +1 -1
  332. package/dist/session/consumer.js +1 -1
  333. package/dist/session/consumer.js.map +1 -1
  334. package/dist/session/create-jazz-session.d.ts +57 -21
  335. package/dist/session/create-jazz-session.d.ts.map +1 -1
  336. package/dist/session/create-jazz-session.js +257 -58
  337. package/dist/session/create-jazz-session.js.map +1 -1
  338. package/dist/session/follow-user.d.ts +17 -7
  339. package/dist/session/follow-user.d.ts.map +1 -1
  340. package/dist/session/follow-user.js +23 -2
  341. package/dist/session/follow-user.js.map +1 -1
  342. package/dist/session/jazz-session.d.ts +164 -0
  343. package/dist/session/jazz-session.d.ts.map +1 -0
  344. package/dist/session/jazz-session.js +432 -0
  345. package/dist/session/jazz-session.js.map +1 -0
  346. package/dist/session/left-behind-replicas.d.ts +8 -1
  347. package/dist/session/left-behind-replicas.d.ts.map +1 -1
  348. package/dist/session/left-behind-replicas.js +21 -4
  349. package/dist/session/left-behind-replicas.js.map +1 -1
  350. package/dist/session/state.d.ts +20 -13
  351. package/dist/session/state.d.ts.map +1 -1
  352. package/dist/session/state.js +68 -23
  353. package/dist/session/state.js.map +1 -1
  354. package/dist/solid/index.d.ts +3 -9
  355. package/dist/solid/index.d.ts.map +1 -1
  356. package/dist/solid/index.js +8 -11
  357. package/dist/solid/index.ssr.js +3 -6
  358. package/dist/solid/provider.d.ts +3 -3
  359. package/dist/solid/provider.d.ts.map +1 -1
  360. package/dist/solid/provider.js +23 -39
  361. package/dist/solid/provider.js.map +1 -1
  362. package/dist/solid/provider.ssr.js +6 -23
  363. package/dist/solid/provider.ssr.js.map +1 -1
  364. package/dist/solid/session.d.ts +42 -12
  365. package/dist/solid/session.d.ts.map +1 -1
  366. package/dist/solid/session.js +82 -35
  367. package/dist/solid/session.js.map +1 -1
  368. package/dist/solid/session.ssr.js +85 -22
  369. package/dist/solid/session.ssr.js.map +1 -1
  370. package/dist/svelte/JazzProvider.svelte +54 -20
  371. package/dist/svelte/JazzProvider.svelte.d.ts +14 -4
  372. package/dist/svelte/JazzProvider.svelte.d.ts.map +1 -1
  373. package/dist/svelte/JazzSvelteClientProvider.svelte +1 -7
  374. package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts +0 -1
  375. package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts.map +1 -1
  376. package/dist/svelte/JazzSvelteProvider.svelte +5 -4
  377. package/dist/svelte/JazzSvelteProvider.svelte.d.ts +2 -2
  378. package/dist/svelte/JazzSvelteProvider.svelte.d.ts.map +1 -1
  379. package/dist/svelte/index.d.ts +4 -12
  380. package/dist/svelte/index.d.ts.map +1 -1
  381. package/dist/svelte/index.js +4 -8
  382. package/dist/svelte/session-state.d.ts +14 -4
  383. package/dist/svelte/session-state.d.ts.map +1 -1
  384. package/dist/svelte/session-state.js +10 -4
  385. package/dist/testing/policy-test-app.d.ts.map +1 -1
  386. package/dist/testing/policy-test-app.js +5 -4
  387. package/dist/testing/policy-test-app.js.map +1 -1
  388. package/dist/testing/test-jazz.d.ts +2 -2
  389. package/dist/testing/test-jazz.d.ts.map +1 -1
  390. package/dist/testing/test-jazz.js +5 -2
  391. package/dist/testing/test-jazz.js.map +1 -1
  392. package/dist/thin/index.d.ts +7 -10
  393. package/dist/thin/index.d.ts.map +1 -1
  394. package/dist/thin/index.js +28 -11
  395. package/dist/thin/index.js.map +1 -1
  396. package/dist/thin/thin-runtime.d.ts +22 -2
  397. package/dist/thin/thin-runtime.d.ts.map +1 -1
  398. package/dist/thin/thin-runtime.js +157 -24
  399. package/dist/thin/thin-runtime.js.map +1 -1
  400. package/dist/vue/index.d.ts +3 -8
  401. package/dist/vue/index.d.ts.map +1 -1
  402. package/dist/vue/index.js +3 -5
  403. package/dist/vue/index.js.map +1 -1
  404. package/dist/vue/provider.d.ts +6 -27
  405. package/dist/vue/provider.d.ts.map +1 -1
  406. package/dist/vue/provider.js +10 -19
  407. package/dist/vue/provider.js.map +1 -1
  408. package/dist/vue/session.d.ts +29 -28
  409. package/dist/vue/session.d.ts.map +1 -1
  410. package/dist/vue/session.js +79 -22
  411. package/dist/vue/session.js.map +1 -1
  412. package/dist/window-client-storage.d.ts +4 -30
  413. package/dist/window-client-storage.d.ts.map +1 -1
  414. package/dist/window-client-storage.js +2 -63
  415. package/dist/window-client-storage.js.map +1 -1
  416. package/dist/worker/jazz-broker-worker-core.d.ts.map +1 -1
  417. package/dist/worker/jazz-broker-worker-core.js +16 -19
  418. package/dist/worker/jazz-broker-worker-core.js.map +1 -1
  419. package/dist/worker/jazz-broker-worker.js +160 -557
  420. package/dist/worker/jazz_wasm_bg.wasm +0 -0
  421. package/dist/worker/runtime-admission.d.ts +19 -0
  422. package/dist/worker/runtime-admission.d.ts.map +1 -0
  423. package/dist/worker/runtime-admission.js +34 -0
  424. package/dist/worker/runtime-admission.js.map +1 -0
  425. package/package.json +18 -5
  426. package/dist/backend/session-recheck.d.ts +0 -18
  427. package/dist/backend/session-recheck.d.ts.map +0 -1
  428. package/dist/backend/session-recheck.js +0 -57
  429. package/dist/backend/session-recheck.js.map +0 -1
  430. package/dist/dev/inspector-overlay/embedded/assets/esm-k3rsq4Gn.js +0 -1
  431. package/dist/dev/inspector-overlay/embedded/assets/index-C-btvLcw.js +0 -20
  432. package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-CAMcDeUa.js +0 -3
  433. package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-Cc71x_6y.js +0 -1
  434. package/dist/dev/inspector-overlay/serve.d.ts +0 -46
  435. package/dist/dev/inspector-overlay/serve.d.ts.map +0 -1
  436. package/dist/dev/inspector-overlay/serve.js +0 -131
  437. package/dist/dev/inspector-overlay/serve.js.map +0 -1
  438. package/dist/dev-tools/auto-attach.d.ts +0 -11
  439. package/dist/dev-tools/auto-attach.d.ts.map +0 -1
  440. package/dist/dev-tools/auto-attach.js +0 -26
  441. package/dist/dev-tools/auto-attach.js.map +0 -1
  442. package/dist/expo/auth-secret-store.d.ts +0 -37
  443. package/dist/expo/auth-secret-store.d.ts.map +0 -1
  444. package/dist/expo/auth-secret-store.js +0 -139
  445. package/dist/expo/auth-secret-store.js.map +0 -1
  446. package/dist/expo/session.d.ts +0 -10
  447. package/dist/expo/session.d.ts.map +0 -1
  448. package/dist/expo/session.js +0 -5
  449. package/dist/expo/session.js.map +0 -1
  450. package/dist/expo/use-local-first-auth.d.ts +0 -12
  451. package/dist/expo/use-local-first-auth.d.ts.map +0 -1
  452. package/dist/expo/use-local-first-auth.js +0 -13
  453. package/dist/expo/use-local-first-auth.js.map +0 -1
  454. package/dist/react/devtools-auto-attach.d.ts +0 -2
  455. package/dist/react/devtools-auto-attach.d.ts.map +0 -1
  456. package/dist/react/devtools-auto-attach.js +0 -11
  457. package/dist/react/devtools-auto-attach.js.map +0 -1
  458. package/dist/react/session.d.ts +0 -18
  459. package/dist/react/session.d.ts.map +0 -1
  460. package/dist/react/session.js +0 -28
  461. package/dist/react/session.js.map +0 -1
  462. package/dist/react/use-local-first-auth.d.ts +0 -11
  463. package/dist/react/use-local-first-auth.d.ts.map +0 -1
  464. package/dist/react/use-local-first-auth.js +0 -13
  465. package/dist/react/use-local-first-auth.js.map +0 -1
  466. package/dist/react-core/app.d.ts +0 -31
  467. package/dist/react-core/app.d.ts.map +0 -1
  468. package/dist/react-core/app.js +0 -65
  469. package/dist/react-core/app.js.map +0 -1
  470. package/dist/react-core/use-account-state.d.ts +0 -4
  471. package/dist/react-core/use-account-state.d.ts.map +0 -1
  472. package/dist/react-core/use-account-state.js +0 -6
  473. package/dist/react-core/use-account-state.js.map +0 -1
  474. package/dist/react-core/use-local-first-auth.d.ts +0 -12
  475. package/dist/react-core/use-local-first-auth.d.ts.map +0 -1
  476. package/dist/react-core/use-local-first-auth.js +0 -14
  477. package/dist/react-core/use-local-first-auth.js.map +0 -1
  478. package/dist/react-native/session.d.ts +0 -10
  479. package/dist/react-native/session.d.ts.map +0 -1
  480. package/dist/react-native/session.js +0 -5
  481. package/dist/react-native/session.js.map +0 -1
  482. package/dist/react-native/use-local-first-auth.d.ts +0 -15
  483. package/dist/react-native/use-local-first-auth.d.ts.map +0 -1
  484. package/dist/react-native/use-local-first-auth.js +0 -14
  485. package/dist/react-native/use-local-first-auth.js.map +0 -1
  486. package/dist/runtime/local-first-auth-controller.d.ts +0 -29
  487. package/dist/runtime/local-first-auth-controller.d.ts.map +0 -1
  488. package/dist/runtime/local-first-auth-controller.js +0 -101
  489. package/dist/runtime/local-first-auth-controller.js.map +0 -1
  490. package/dist/session/app.d.ts +0 -58
  491. package/dist/session/app.d.ts.map +0 -1
  492. package/dist/session/app.js +0 -325
  493. package/dist/session/app.js.map +0 -1
  494. package/dist/session/create-jazz-app.d.ts +0 -11
  495. package/dist/session/create-jazz-app.d.ts.map +0 -1
  496. package/dist/session/create-jazz-app.js +0 -11
  497. package/dist/session/create-jazz-app.js.map +0 -1
  498. package/dist/solid/app.d.ts +0 -30
  499. package/dist/solid/app.d.ts.map +0 -1
  500. package/dist/solid/app.js +0 -95
  501. package/dist/solid/app.js.map +0 -1
  502. package/dist/solid/app.ssr.js +0 -109
  503. package/dist/solid/app.ssr.js.map +0 -1
  504. package/dist/solid/create-account-state.d.ts +0 -4
  505. package/dist/solid/create-account-state.d.ts.map +0 -1
  506. package/dist/solid/create-account-state.js +0 -10
  507. package/dist/solid/create-account-state.js.map +0 -1
  508. package/dist/solid/create-account-state.ssr.js +0 -12
  509. package/dist/solid/create-account-state.ssr.js.map +0 -1
  510. package/dist/solid/use-local-first-auth.d.ts +0 -11
  511. package/dist/solid/use-local-first-auth.d.ts.map +0 -1
  512. package/dist/solid/use-local-first-auth.js +0 -30
  513. package/dist/solid/use-local-first-auth.js.map +0 -1
  514. package/dist/solid/use-local-first-auth.ssr.js +0 -31
  515. package/dist/solid/use-local-first-auth.ssr.js.map +0 -1
  516. package/dist/svelte/JazzSessionClientProvider.svelte +0 -42
  517. package/dist/svelte/JazzSessionClientProvider.svelte.d.ts +0 -13
  518. package/dist/svelte/JazzSessionClientProvider.svelte.d.ts.map +0 -1
  519. package/dist/svelte/JazzSessionProvider.svelte +0 -68
  520. package/dist/svelte/JazzSessionProvider.svelte.d.ts +0 -19
  521. package/dist/svelte/JazzSessionProvider.svelte.d.ts.map +0 -1
  522. package/dist/svelte/account-state.d.ts +0 -5
  523. package/dist/svelte/account-state.d.ts.map +0 -1
  524. package/dist/svelte/account-state.js +0 -9
  525. package/dist/svelte/auth-state.d.ts +0 -23
  526. package/dist/svelte/auth-state.d.ts.map +0 -1
  527. package/dist/svelte/auth-state.js +0 -16
  528. package/dist/svelte/local-first-auth.svelte.d.ts +0 -50
  529. package/dist/svelte/local-first-auth.svelte.d.ts.map +0 -1
  530. package/dist/svelte/local-first-auth.svelte.js +0 -58
  531. package/dist/vue/app.d.ts +0 -76
  532. package/dist/vue/app.d.ts.map +0 -1
  533. package/dist/vue/app.js +0 -100
  534. package/dist/vue/app.js.map +0 -1
  535. package/dist/vue/use-account-state.d.ts +0 -5
  536. package/dist/vue/use-account-state.d.ts.map +0 -1
  537. package/dist/vue/use-account-state.js +0 -10
  538. package/dist/vue/use-account-state.js.map +0 -1
  539. package/dist/vue/use-local-first-auth.d.ts +0 -53
  540. package/dist/vue/use-local-first-auth.d.ts.map +0 -1
  541. package/dist/vue/use-local-first-auth.js +0 -67
  542. package/dist/vue/use-local-first-auth.js.map +0 -1
  543. /package/dist/dev/inspector-overlay/embedded/assets/{esm-CH5eVyQQ.js → esm-xNe3wI_B.js} +0 -0
  544. /package/dist/dev/inspector-overlay/embedded/assets/{node-foreground-node-lease.browser-Bm3gYjlT.js → node-foreground-node-lease.browser-CH8w-D6S.js} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"early-db.d.ts","sourceRoot":"","sources":["../../src/backend/early-db.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,EAAE,EAKH,MAAM,kBAAkB,CAAC;AAgC1B,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,YAAY,CAK9F;AAkDD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC,4EAA4E;AAC5E,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,gFAAgF;IAChF,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,OAAO,CAuIpF"}
1
+ {"version":3,"file":"early-db.d.ts","sourceRoot":"","sources":["../../src/backend/early-db.ts"],"names":[],"mappings":"AAMA,OAAO,EACL,EAAE,EAKH,MAAM,kBAAkB,CAAC;AAiC1B,6FAA6F;AAC7F,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,WAAW,GAAG,YAAY,CAK9F;AAkDD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAS,CAAC;AAEvC,4EAA4E;AAC5E,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,EAAE,EAAE,EAAE,CAAC;IAChB;;;OAGG;IACH,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IACvB,gFAAgF;IAChF,OAAO,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,SAAS,GAAG,OAAO,CAuIpF"}
@@ -25,6 +25,7 @@ const WAITS = new Set([
25
25
  "reconnect",
26
26
  "upgradeToLocalFirst",
27
27
  "deleteClientStorage",
28
+ "wipeClientStorage",
28
29
  "logout",
29
30
  "shutdown",
30
31
  ]);
@@ -1 +1 @@
1
- {"version":3,"file":"early-db.js","sourceRoot":"","sources":["../../src/backend/early-db.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,WAAW,GAGZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,EAAE,EACF,iBAAiB,EACjB,YAAY,GAGb,MAAM,kBAAkB,CAAC;AAE1B,mEAAmE;AACnE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAC;AAE5E,0EAA0E;AAC1E,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC;IACpB,KAAK;IACL,KAAK;IACL,WAAW;IACX,SAAS;IACT,WAAW;IACX,WAAW;IACX,aAAa;IACb,yBAAyB;IACzB,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,iBAAiB;IACjB,aAAa;IACb,oBAAoB;IACpB,uBAAuB;IACvB,gBAAgB;IAChB,0BAA0B;IAC1B,YAAY;IACZ,WAAW;IACX,qBAAqB;IACrB,qBAAqB;IACrB,QAAQ;IACR,UAAU;CACX,CAAC,CAAC;AAEH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G,EAAE,CAAC;YACjB,IAAI,EAAE,EAAE,CAAC;gBACP,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAY,CAAC;gBACnD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAC1E,CAAC;YACD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;KACF,CAAC,CAAC;IACH,OAAO;QACL,EAAE;QACF,KAAK,CAAC,KAAK;YACT,MAAM,GAAG,IAAI,CAAC;YACd,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ;gBAAE,MAAM,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n WriteHandle,\n WriteResult,\n type JazzClient,\n type WriteWaitOptions,\n} from \"../runtime/client.js\";\nimport {\n Db,\n previewWrittenRow,\n reserveRowId,\n type DbSubscriptionCallbacks,\n type TableProxy,\n} from \"../runtime/db.js\";\n\n/** Writes that return at once and apply once the store is open. */\nconst WRITES = new Set([\"insert\", \"restore\", \"update\", \"upsert\", \"delete\"]);\n\n/** Methods that already answer later: they wait for the store to open. */\nconst WAITS = new Set([\n \"all\",\n \"one\",\n \"canInsert\",\n \"canRead\",\n \"canUpdate\",\n \"canDelete\",\n \"transaction\",\n \"serializableTransaction\",\n \"insertStreaming\",\n \"updateStreaming\",\n \"upsertStreaming\",\n \"captureSnapshot\",\n \"waitForSync\",\n \"refreshAccountAuth\",\n \"refreshOwnAccountAuth\",\n \"stopOwnRuntime\",\n \"openInspectorControlPort\",\n \"disconnect\",\n \"reconnect\",\n \"upgradeToLocalFirst\",\n \"deleteClientStorage\",\n \"logout\",\n \"shutdown\",\n]);\n\n/** @internal How the early db treats each `Db` method before the store opens (for tests). */\nexport function earlyDbMethodKind(name: string): \"write\" | \"waits\" | \"subscribe\" | \"needs-open\" {\n if (WRITES.has(name)) return \"write\";\n if (WAITS.has(name)) return \"waits\";\n if (name === \"subscribe\") return \"subscribe\";\n return \"needs-open\";\n}\n\ntype AnyHandle = WriteHandle<unknown, unknown>;\n\n/** A write made before the store opened, waiting on the write it becomes. */\nclass EarlyWriteResult<T> extends WriteResult<T> {\n readonly #applied: Promise<AnyHandle>;\n\n constructor(value: T, applied: Promise<AnyHandle>) {\n super(\n value,\n applied.then((handle) => handle.txId),\n undefined as unknown as JazzClient,\n );\n this.#applied = applied;\n }\n\n override async wait(options: WriteWaitOptions): Promise<T> {\n await (await this.#applied).wait(options);\n return this.value;\n }\n\n override mapValue<U>(transformValue: (value: T) => U): WriteResult<U> {\n return new EarlyWriteResult(transformValue(this.value), this.#applied);\n }\n}\n\nclass EarlyWriteHandle extends WriteHandle {\n readonly #applied: Promise<AnyHandle>;\n\n constructor(applied: Promise<AnyHandle>) {\n super(\n applied.then((handle) => handle.txId),\n undefined as unknown as JazzClient,\n );\n this.#applied = applied;\n }\n\n override async wait(options: WriteWaitOptions): Promise<void> {\n await (await this.#applied).wait(options);\n }\n}\n\ninterface QueuedWrite {\n apply(db: Db): void;\n fail(error: unknown): void;\n}\n\ntype Method = (...args: unknown[]) => unknown;\n\n/**\n * At most this many writes wait for the store to open: past it a write\n * throws, so a store that is slow to open never grows the queue unbounded.\n */\nexport const MAX_EARLY_WRITES = 10_000;\n\n/** The backend's own database, as `earlyDb` makes it, and its lifecycle. */\nexport interface EarlyDb {\n readonly db: Db;\n /**\n * Close it: from now on every call throws. Resolves once the writes made\n * before have been applied to the open store (or failed with its open).\n */\n drain(): Promise<void>;\n /** Fail the writes still waiting with `error` (a close gave up on the open). */\n abandon(error: unknown): void;\n}\n\n/**\n * The backend's own database before its store has opened, and after: once\n * open, every call goes to the `Db` that `live` names then (a reload moves\n * it). Before that, writes return at once (an insert's row, id included)\n * and apply, in order, as the store opens; reads and other async calls\n * wait for it; a subscription starts then. Calls that must answer now,\n * like `getSyncStatus()`, throw until it has opened.\n */\nexport function earlyDb(open: () => Promise<Db>, live: () => Db | undefined): EarlyDb {\n let queue: QueuedWrite[] = [];\n let flushing: Promise<Db> | undefined;\n let closed = false;\n\n /** The open db, with the writes queued so far applied to it first. */\n function opened(): Promise<Db> {\n flushing ??= open().then(\n (db) => {\n flushing = undefined;\n const batch = queue;\n queue = [];\n for (const write of batch) write.apply(db);\n return db;\n },\n (error: unknown) => {\n flushing = undefined;\n abandon(error);\n throw error;\n },\n );\n return flushing;\n }\n\n function abandon(error: unknown): void {\n const batch = queue;\n queue = [];\n for (const write of batch) write.fail(error);\n }\n\n // Queued writes go first, so a write made now never overtakes them.\n const now = () => (closed || queue.length > 0 ? undefined : live());\n\n function enqueue(write: (db: Db) => AnyHandle): Promise<AnyHandle> {\n if (queue.length >= MAX_EARLY_WRITES) {\n throw new Error(\n `jazz.db: ${MAX_EARLY_WRITES} writes are already waiting for the store to open; \\`await jazz.ready()\\` before writing more`,\n );\n }\n const applied = new Promise<AnyHandle>((resolve, reject) => {\n queue.push({\n apply(db) {\n try {\n resolve(write(db));\n } catch (error) {\n reject(error);\n }\n },\n fail: reject,\n });\n });\n // A caller that never waits must not see an unhandled rejection.\n applied.catch(() => {});\n opened().catch(() => {});\n return applied;\n }\n\n function call(db: Db, name: string, args: unknown[]): unknown {\n return (Reflect.get(db, name, db) as Method).apply(db, args);\n }\n\n function early(name: string): unknown {\n if (name === \"insert\" || name === \"restore\") {\n return (table: TableProxy<unknown, unknown>, ...rest: unknown[]) => {\n const insert = name === \"insert\";\n const options = (insert ? rest[1] : rest[2]) as { id?: string } | undefined;\n const id = insert ? (options?.id ?? reserveRowId()) : (rest[0] as string);\n const data = insert ? rest[0] : rest[1];\n // The row it writes, from the schema alone, as `Db` gives it.\n const value = previewWrittenRow(table, insert ? \"Insert\" : \"Restore\", id, data);\n const args = insert ? [table, data, { ...options, id }] : [table, ...rest];\n return new EarlyWriteResult(\n value,\n enqueue((db) => call(db, name, args) as AnyHandle),\n );\n };\n }\n if (WRITES.has(name)) {\n return (...args: unknown[]) =>\n new EarlyWriteHandle(enqueue((db) => call(db, name, args) as AnyHandle));\n }\n if (WAITS.has(name)) {\n return async (...args: unknown[]) => call(await opened(), name, args);\n }\n if (name === \"subscribe\") {\n return (...args: unknown[]) => {\n let stop: (() => void) | undefined;\n let stopped = false;\n opened().then(\n (db) => {\n if (!stopped) stop = call(db, \"subscribe\", args) as () => void;\n },\n (error: unknown) => {\n const callbacks = args[1] as DbSubscriptionCallbacks<{ id: string }> | Method;\n const onError = typeof callbacks === \"function\" ? undefined : callbacks.onError;\n if (onError) onError(error as Error);\n else console.error(\"jazz: a subscription could not start\", error);\n },\n );\n return () => {\n stopped = true;\n stop?.();\n };\n };\n }\n throw new Error(\n `jazz.db.${name} is not available until the store has opened: \\`await jazz.ready()\\` first`,\n );\n }\n\n const db = new Proxy(Object.create(Db.prototype) as Db, {\n get(_target, name) {\n // Not a thenable, and no well-known symbols: `await jazz.db` stays the db.\n if (typeof name === \"symbol\" || name === \"then\") return undefined;\n if (closed) {\n return () => {\n throw new Error(`jazz.db.${name}: this Jazz was closed`);\n };\n }\n const db = now();\n if (db) {\n const value = Reflect.get(db, name, db) as unknown;\n return typeof value === \"function\" ? (value as Method).bind(db) : value;\n }\n return early(name);\n },\n });\n return {\n db,\n async drain() {\n closed = true;\n if (queue.length > 0 || flushing) await opened().catch(() => {});\n },\n abandon,\n };\n}\n"]}
1
+ {"version":3,"file":"early-db.js","sourceRoot":"","sources":["../../src/backend/early-db.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,EACX,WAAW,GAGZ,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,EAAE,EACF,iBAAiB,EACjB,YAAY,GAGb,MAAM,kBAAkB,CAAC;AAE1B,mEAAmE;AACnE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,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,KAAK,CACb,WAAW,IAAI,4EAA4E,CAC5F,CAAC;IACJ,CAAC;IAED,MAAM,EAAE,GAAG,IAAI,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,SAAS,CAAO,EAAE;QACtD,GAAG,CAAC,OAAO,EAAE,IAAI;YACf,2EAA2E;YAC3E,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,KAAK,MAAM;gBAAE,OAAO,SAAS,CAAC;YAClE,IAAI,MAAM,EAAE,CAAC;gBACX,OAAO,GAAG,EAAE;oBACV,MAAM,IAAI,KAAK,CAAC,WAAW,IAAI,wBAAwB,CAAC,CAAC;gBAC3D,CAAC,CAAC;YACJ,CAAC;YACD,MAAM,EAAE,GAAG,GAAG,EAAE,CAAC;YACjB,IAAI,EAAE,EAAE,CAAC;gBACP,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,CAAY,CAAC;gBACnD,OAAO,OAAO,KAAK,KAAK,UAAU,CAAC,CAAC,CAAE,KAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;YAC1E,CAAC;YACD,OAAO,KAAK,CAAC,IAAI,CAAC,CAAC;QACrB,CAAC;KACF,CAAC,CAAC;IACH,OAAO;QACL,EAAE;QACF,KAAK,CAAC,KAAK;YACT,MAAM,GAAG,IAAI,CAAC;YACd,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,QAAQ;gBAAE,MAAM,MAAM,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACnE,CAAC;QACD,OAAO;KACR,CAAC;AACJ,CAAC","sourcesContent":["import {\n WriteHandle,\n WriteResult,\n type JazzClient,\n type WriteWaitOptions,\n} from \"../runtime/client.js\";\nimport {\n Db,\n previewWrittenRow,\n reserveRowId,\n type DbSubscriptionCallbacks,\n type TableProxy,\n} from \"../runtime/db.js\";\n\n/** Writes that return at once and apply once the store is open. */\nconst WRITES = new Set([\"insert\", \"restore\", \"update\", \"upsert\", \"delete\"]);\n\n/** Methods that already answer later: they wait for the store to open. */\nconst WAITS = new Set([\n \"all\",\n \"one\",\n \"canInsert\",\n \"canRead\",\n \"canUpdate\",\n \"canDelete\",\n \"transaction\",\n \"serializableTransaction\",\n \"insertStreaming\",\n \"updateStreaming\",\n \"upsertStreaming\",\n \"captureSnapshot\",\n \"waitForSync\",\n \"refreshAccountAuth\",\n \"refreshOwnAccountAuth\",\n \"stopOwnRuntime\",\n \"openInspectorControlPort\",\n \"disconnect\",\n \"reconnect\",\n \"upgradeToLocalFirst\",\n \"deleteClientStorage\",\n \"wipeClientStorage\",\n \"logout\",\n \"shutdown\",\n]);\n\n/** @internal How the early db treats each `Db` method before the store opens (for tests). */\nexport function earlyDbMethodKind(name: string): \"write\" | \"waits\" | \"subscribe\" | \"needs-open\" {\n if (WRITES.has(name)) return \"write\";\n if (WAITS.has(name)) return \"waits\";\n if (name === \"subscribe\") return \"subscribe\";\n return \"needs-open\";\n}\n\ntype AnyHandle = WriteHandle<unknown, unknown>;\n\n/** A write made before the store opened, waiting on the write it becomes. */\nclass EarlyWriteResult<T> extends WriteResult<T> {\n readonly #applied: Promise<AnyHandle>;\n\n constructor(value: T, applied: Promise<AnyHandle>) {\n super(\n value,\n applied.then((handle) => handle.txId),\n undefined as unknown as JazzClient,\n );\n this.#applied = applied;\n }\n\n override async wait(options: WriteWaitOptions): Promise<T> {\n await (await this.#applied).wait(options);\n return this.value;\n }\n\n override mapValue<U>(transformValue: (value: T) => U): WriteResult<U> {\n return new EarlyWriteResult(transformValue(this.value), this.#applied);\n }\n}\n\nclass EarlyWriteHandle extends WriteHandle {\n readonly #applied: Promise<AnyHandle>;\n\n constructor(applied: Promise<AnyHandle>) {\n super(\n applied.then((handle) => handle.txId),\n undefined as unknown as JazzClient,\n );\n this.#applied = applied;\n }\n\n override async wait(options: WriteWaitOptions): Promise<void> {\n await (await this.#applied).wait(options);\n }\n}\n\ninterface QueuedWrite {\n apply(db: Db): void;\n fail(error: unknown): void;\n}\n\ntype Method = (...args: unknown[]) => unknown;\n\n/**\n * At most this many writes wait for the store to open: past it a write\n * throws, so a store that is slow to open never grows the queue unbounded.\n */\nexport const MAX_EARLY_WRITES = 10_000;\n\n/** The backend's own database, as `earlyDb` makes it, and its lifecycle. */\nexport interface EarlyDb {\n readonly db: Db;\n /**\n * Close it: from now on every call throws. Resolves once the writes made\n * before have been applied to the open store (or failed with its open).\n */\n drain(): Promise<void>;\n /** Fail the writes still waiting with `error` (a close gave up on the open). */\n abandon(error: unknown): void;\n}\n\n/**\n * The backend's own database before its store has opened, and after: once\n * open, every call goes to the `Db` that `live` names then (a reload moves\n * it). Before that, writes return at once (an insert's row, id included)\n * and apply, in order, as the store opens; reads and other async calls\n * wait for it; a subscription starts then. Calls that must answer now,\n * like `getSyncStatus()`, throw until it has opened.\n */\nexport function earlyDb(open: () => Promise<Db>, live: () => Db | undefined): EarlyDb {\n let queue: QueuedWrite[] = [];\n let flushing: Promise<Db> | undefined;\n let closed = false;\n\n /** The open db, with the writes queued so far applied to it first. */\n function opened(): Promise<Db> {\n flushing ??= open().then(\n (db) => {\n flushing = undefined;\n const batch = queue;\n queue = [];\n for (const write of batch) write.apply(db);\n return db;\n },\n (error: unknown) => {\n flushing = undefined;\n abandon(error);\n throw error;\n },\n );\n return flushing;\n }\n\n function abandon(error: unknown): void {\n const batch = queue;\n queue = [];\n for (const write of batch) write.fail(error);\n }\n\n // Queued writes go first, so a write made now never overtakes them.\n const now = () => (closed || queue.length > 0 ? undefined : live());\n\n function enqueue(write: (db: Db) => AnyHandle): Promise<AnyHandle> {\n if (queue.length >= MAX_EARLY_WRITES) {\n throw new Error(\n `jazz.db: ${MAX_EARLY_WRITES} writes are already waiting for the store to open; \\`await jazz.ready()\\` before writing more`,\n );\n }\n const applied = new Promise<AnyHandle>((resolve, reject) => {\n queue.push({\n apply(db) {\n try {\n resolve(write(db));\n } catch (error) {\n reject(error);\n }\n },\n fail: reject,\n });\n });\n // A caller that never waits must not see an unhandled rejection.\n applied.catch(() => {});\n opened().catch(() => {});\n return applied;\n }\n\n function call(db: Db, name: string, args: unknown[]): unknown {\n return (Reflect.get(db, name, db) as Method).apply(db, args);\n }\n\n function early(name: string): unknown {\n if (name === \"insert\" || name === \"restore\") {\n return (table: TableProxy<unknown, unknown>, ...rest: unknown[]) => {\n const insert = name === \"insert\";\n const options = (insert ? rest[1] : rest[2]) as { id?: string } | undefined;\n const id = insert ? (options?.id ?? reserveRowId()) : (rest[0] as string);\n const data = insert ? rest[0] : rest[1];\n // The row it writes, from the schema alone, as `Db` gives it.\n const value = previewWrittenRow(table, insert ? \"Insert\" : \"Restore\", id, data);\n const args = insert ? [table, data, { ...options, id }] : [table, ...rest];\n return new EarlyWriteResult(\n value,\n enqueue((db) => call(db, name, args) as AnyHandle),\n );\n };\n }\n if (WRITES.has(name)) {\n return (...args: unknown[]) =>\n new EarlyWriteHandle(enqueue((db) => call(db, name, args) as AnyHandle));\n }\n if (WAITS.has(name)) {\n return async (...args: unknown[]) => call(await opened(), name, args);\n }\n if (name === \"subscribe\") {\n return (...args: unknown[]) => {\n let stop: (() => void) | undefined;\n let stopped = false;\n opened().then(\n (db) => {\n if (!stopped) stop = call(db, \"subscribe\", args) as () => void;\n },\n (error: unknown) => {\n const callbacks = args[1] as DbSubscriptionCallbacks<{ id: string }> | Method;\n const onError = typeof callbacks === \"function\" ? undefined : callbacks.onError;\n if (onError) onError(error as Error);\n else console.error(\"jazz: a subscription could not start\", error);\n },\n );\n return () => {\n stopped = true;\n stop?.();\n };\n };\n }\n throw new Error(\n `jazz.db.${name} is not available until the store has opened: \\`await jazz.ready()\\` first`,\n );\n }\n\n const db = new Proxy(Object.create(Db.prototype) as Db, {\n get(_target, name) {\n // Not a thenable, and no well-known symbols: `await jazz.db` stays the db.\n if (typeof name === \"symbol\" || name === \"then\") return undefined;\n if (closed) {\n return () => {\n throw new Error(`jazz.db.${name}: this Jazz was closed`);\n };\n }\n const db = now();\n if (db) {\n const value = Reflect.get(db, name, db) as unknown;\n return typeof value === \"function\" ? (value as Method).bind(db) : value;\n }\n return early(name);\n },\n });\n return {\n db,\n async drain() {\n closed = true;\n if (queue.length > 0 || flushing) await opened().catch(() => {});\n },\n abandon,\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import { type BackendJwtPublicKey } from "./external-jwt.js";
2
- import type { JazzUser } from "./create-jazz.js";
2
+ import type { AuthenticatedUser } from "./create-jazz.js";
3
3
  export interface FromJWTOptions {
4
4
  /** The issuer's JWKS endpoint. HTTPS, or HTTP on loopback in development. */
5
5
  jwksUrl?: string;
@@ -58,5 +58,5 @@ export interface FromJWTOptions {
58
58
  * });
59
59
  * ```
60
60
  */
61
- export declare function fromJWT(options: FromJWTOptions): (request: Request) => Promise<JazzUser | null>;
61
+ export declare function fromJWT(options: FromJWTOptions): (request: Request) => Promise<AuthenticatedUser | null>;
62
62
  //# sourceMappingURL=from-jwt.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"from-jwt.d.ts","sourceRoot":"","sources":["../../src/backend/from-jwt.ts"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAGjD,MAAM,WAAW,cAAc;IAC7B,6EAA6E;IAC7E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,yEAAyE;IACzE,SAAS,CAAC,EAAE,mBAAmB,CAAC;IAChC,wFAAwF;IACxF,MAAM,EAAE,MAAM,CAAC;IACf;;;;;OAKG;IACH,QAAQ,EAAE,MAAM,GAAG,SAAS,MAAM,EAAE,GAAG,KAAK,CAAC;IAC7C,wEAAwE;IACxE,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,KAAK,CAAC,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,MAAM,G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;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,OAAO,CACrB,OAAO,EAAE,cAAc,GACtB,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CA2DzD"}
@@ -90,7 +90,13 @@ export function fromJWT(options) {
90
90
  return null;
91
91
  throw error;
92
92
  }
93
- return { userId: payload.sub, claims: readClaims(payload) };
93
+ // Verified with `requireExp`, so the token says until when it holds; it
94
+ // is accepted up to the clock tolerance past that, and so holds as long.
95
+ return {
96
+ userId: payload.sub,
97
+ claims: readClaims(payload),
98
+ expiresAt: payload.exp + lifetime.clockToleranceSeconds,
99
+ };
94
100
  };
95
101
  }
96
102
  //# sourceMappingURL=from-jwt.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"from-jwt.js","sourceRoot":"","sources":["../../src/backend/from-jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAmB,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAA4B,MAAM,mBAAmB,CAAC;AAEhF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AA+BjE,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAErF,SAAS,WAAW,CAAC,OAAgB;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACpD,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD,OAAO,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,IAAI,CAAC;AACvD,CAAC;AAED,SAAS,gBAAgB,CAAC,MAAc;IACtC,OAAO,MAAM,CAAC,UAAU,CAAC,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;YACf,+DAA+D;YAC/D,mDAAmD;YACnD,IAAI,4BAA4B,CAAC,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YACrD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC,EAAE,CAAC;IAC9D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { parseJwtPayload, type JwtPayload } from \"../runtime/client-session.js\";\nimport { verifyExternalJwt, type BackendJwtPublicKey } from \"./external-jwt.js\";\nimport type { JazzUser } from \"./create-jazz.js\";\nimport { isRequestAuthenticationError } from \"./request-auth.js\";\n\nexport interface FromJWTOptions {\n /** The issuer's JWKS endpoint. HTTPS, or HTTP on loopback in development. */\n jwksUrl?: string;\n /** The issuer's public key (PEM, X.509 or JWK), instead of `jwksUrl`. */\n publicKey?: BackendJwtPublicKey;\n /** The `iss` every accepted token carries. Tokens from any other issuer are refused. */\n issuer: string;\n /**\n * The `aud` values that name this app. Required: an issuer shared by\n * several apps (an Auth0 or Clerk tenant) signs tokens for all of them.\n * Pass `false` only when the issuer itself is this app's alone (WorkOS's\n * issuer names your client id) and its tokens carry no audience.\n */\n audience: string | readonly string[] | false;\n /** Seconds of clock skew allowed on `exp` and `nbf`. Defaults to 60. */\n clockToleranceSeconds?: number;\n /**\n * Where the token comes from. Defaults to the `Authorization: Bearer`\n * header. Return null when the request carries none.\n */\n token?: (request: Request) => string | null | undefined | Promise<string | null | undefined>;\n /**\n * The claims your permissions read through `session.claims`. Defaults to\n * every claim in the token except the registered ones (`iss`, `sub`,\n * `aud`, `exp`, `nbf`, `iat`, `jti`).\n */\n claims?: (payload: Record<string, unknown>) => Record<string, unknown>;\n}\n\nconst REGISTERED_CLAIMS = new Set([\"iss\", \"sub\", \"aud\", \"exp\", \"nbf\", \"iat\", \"jti\"]);\n\nfunction bearerToken(request: Request): string | null {\n const header = request.headers.get(\"authorization\");\n if (!header?.startsWith(\"Bearer \")) return null;\n return header.slice(\"Bearer \".length).trim() || null;\n}\n\nfunction isReservedIssuer(issuer: string): boolean {\n return issuer.startsWith(\"urn:jazz:\") || issuer.startsWith(\"jazz:\");\n}\n\n/**\n * An `authenticate` for {@link createJazz} that signs users in with JWTs\n * from your identity provider (WorkOS, Auth0, Clerk, any OIDC issuer).\n *\n * It verifies the token's signature, expiry (`exp` is required; 60 seconds\n * of clock skew are allowed), `nbf`, issuer and audience, and names the\n * user by its `sub`. A request without a token, or with one that does\n * not verify, is signed out (null). A JWKS that cannot be fetched is the\n * server's problem and throws, so clients retry instead of signing out.\n *\n * The JWKS is cached for up to five minutes, so a key your issuer drops is\n * accepted until then. A token naming a key the cached JWKS doesn't publish\n * fetches it again, at most once every 30 seconds, and is signed out if the\n * JWKS still doesn't publish its key; within 30 seconds of a fetch it is\n * signed out without one. So when rotating keys, publish the new key in\n * your JWKS before your issuer signs with it, as issuers that rotate keys\n * do; a key published less than 30 seconds before its first token may\n * refuse that token.\n *\n * ```ts\n * createJazz({\n * app, permissions, store,\n * authenticate: fromJWT({\n * jwksUrl: \"https://my-tenant.auth0.com/.well-known/jwks.json\",\n * issuer: \"https://my-tenant.auth0.com/\",\n * audience: \"https://api.my-app.com\",\n * }),\n * });\n * ```\n */\nexport function fromJWT(options: FromJWTOptions): (request: Request) => Promise<JazzUser | null> {\n if (!options.issuer) throw new Error(\"fromJWT: issuer is required\");\n if (isReservedIssuer(options.issuer)) {\n throw new Error(`fromJWT: ${options.issuer} is reserved for Jazz's own identities`);\n }\n if ((options.jwksUrl === undefined) === (options.publicKey === undefined)) {\n throw new Error(\"fromJWT: pass exactly one of jwksUrl and publicKey\");\n }\n const audience = options.audience as unknown;\n if (\n audience !== false &&\n !(typeof audience === \"string\" && audience !== \"\") &&\n !(\n Array.isArray(audience) &&\n audience.length > 0 &&\n audience.every((a) => typeof a === \"string\" && a !== \"\")\n )\n ) {\n throw new Error(\"fromJWT: audience is required (or false when the issuer is this app's alone)\");\n }\n const lifetime = {\n requireExp: true,\n checkNotBefore: true,\n clockToleranceSeconds: options.clockToleranceSeconds ?? 60,\n };\n const config = {\n appId: \"\",\n jwtIssuer: options.issuer,\n ...(options.jwksUrl === undefined ? {} : { jwksUrl: options.jwksUrl }),\n ...(options.publicKey === undefined ? {} : { jwtPublicKey: options.publicKey }),\n ...(options.audience === false ? {} : { jwtAudience: options.audience }),\n };\n const readToken = options.token ?? bearerToken;\n const readClaims =\n options.claims ??\n ((payload: JwtPayload) =>\n Object.fromEntries(Object.entries(payload).filter(([name]) => !REGISTERED_CLAIMS.has(name))));\n\n return async (request) => {\n const token = await readToken(request);\n if (!token) return null;\n const payload = parseJwtPayload(token);\n if (!payload || typeof payload.sub !== \"string\" || payload.sub === \"\") return null;\n try {\n await verifyExternalJwt(token, payload, config, lifetime);\n } catch (error) {\n // A token that does not verify signs nobody in; an unreachable\n // JWKS or an unusable key is the server's problem.\n if (isRequestAuthenticationError(error)) return null;\n throw error;\n }\n return { userId: payload.sub, claims: readClaims(payload) };\n };\n}\n"]}
1
+ {"version":3,"file":"from-jwt.js","sourceRoot":"","sources":["../../src/backend/from-jwt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAmB,MAAM,8BAA8B,CAAC;AAChF,OAAO,EAAE,iBAAiB,EAA4B,MAAM,mBAAmB,CAAC;AAEhF,OAAO,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAC;AA+BjE,MAAM,iBAAiB,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;AAErF,SAAS,WAAW,CAAC,OAAgB;IACnC,MAAM,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IACpD,IAAI,CAAC,MAAM,EAAE,UAAU,CAAC,SAAS,CAAC;QAAE,OAAO,IAAI,CAAC;IAChD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EAAE;YAAE,OAAO,IAAI,CAAC;QACnF,IAAI,CAAC;YACH,MAAM,iBAAiB,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;QAC5D,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,+DAA+D;YAC/D,mDAAmD;YACnD,IAAI,4BAA4B,CAAC,KAAK,CAAC;gBAAE,OAAO,IAAI,CAAC;YACrD,MAAM,KAAK,CAAC;QACd,CAAC;QACD,wEAAwE;QACxE,yEAAyE;QACzE,OAAO;YACL,MAAM,EAAE,OAAO,CAAC,GAAG;YACnB,MAAM,EAAE,UAAU,CAAC,OAAO,CAAC;YAC3B,SAAS,EAAG,OAAO,CAAC,GAAc,GAAG,QAAQ,CAAC,qBAAqB;SACpE,CAAC;IACJ,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import { parseJwtPayload, type JwtPayload } from \"../runtime/client-session.js\";\nimport { verifyExternalJwt, type BackendJwtPublicKey } from \"./external-jwt.js\";\nimport type { AuthenticatedUser } from \"./create-jazz.js\";\nimport { isRequestAuthenticationError } from \"./request-auth.js\";\n\nexport interface FromJWTOptions {\n /** The issuer's JWKS endpoint. HTTPS, or HTTP on loopback in development. */\n jwksUrl?: string;\n /** The issuer's public key (PEM, X.509 or JWK), instead of `jwksUrl`. */\n publicKey?: BackendJwtPublicKey;\n /** The `iss` every accepted token carries. Tokens from any other issuer are refused. */\n issuer: string;\n /**\n * The `aud` values that name this app. Required: an issuer shared by\n * several apps (an Auth0 or Clerk tenant) signs tokens for all of them.\n * Pass `false` only when the issuer itself is this app's alone (WorkOS's\n * issuer names your client id) and its tokens carry no audience.\n */\n audience: string | readonly string[] | false;\n /** Seconds of clock skew allowed on `exp` and `nbf`. Defaults to 60. */\n clockToleranceSeconds?: number;\n /**\n * Where the token comes from. Defaults to the `Authorization: Bearer`\n * header. Return null when the request carries none.\n */\n token?: (request: Request) => string | null | undefined | Promise<string | null | undefined>;\n /**\n * The claims your permissions read through `session.claims`. Defaults to\n * every claim in the token except the registered ones (`iss`, `sub`,\n * `aud`, `exp`, `nbf`, `iat`, `jti`).\n */\n claims?: (payload: Record<string, unknown>) => Record<string, unknown>;\n}\n\nconst REGISTERED_CLAIMS = new Set([\"iss\", \"sub\", \"aud\", \"exp\", \"nbf\", \"iat\", \"jti\"]);\n\nfunction bearerToken(request: Request): string | null {\n const header = request.headers.get(\"authorization\");\n if (!header?.startsWith(\"Bearer \")) return null;\n return header.slice(\"Bearer \".length).trim() || null;\n}\n\nfunction isReservedIssuer(issuer: string): boolean {\n return issuer.startsWith(\"urn:jazz:\") || issuer.startsWith(\"jazz:\");\n}\n\n/**\n * An `authenticate` for {@link createJazz} that signs users in with JWTs\n * from your identity provider (WorkOS, Auth0, Clerk, any OIDC issuer).\n *\n * It verifies the token's signature, expiry (`exp` is required; 60 seconds\n * of clock skew are allowed), `nbf`, issuer and audience, and names the\n * user by its `sub`. A request without a token, or with one that does\n * not verify, is signed out (null). A JWKS that cannot be fetched is the\n * server's problem and throws, so clients retry instead of signing out.\n *\n * The JWKS is cached for up to five minutes, so a key your issuer drops is\n * accepted until then. A token naming a key the cached JWKS doesn't publish\n * fetches it again, at most once every 30 seconds, and is signed out if the\n * JWKS still doesn't publish its key; within 30 seconds of a fetch it is\n * signed out without one. So when rotating keys, publish the new key in\n * your JWKS before your issuer signs with it, as issuers that rotate keys\n * do; a key published less than 30 seconds before its first token may\n * refuse that token.\n *\n * ```ts\n * createJazz({\n * app, permissions, store,\n * authenticate: fromJWT({\n * jwksUrl: \"https://my-tenant.auth0.com/.well-known/jwks.json\",\n * issuer: \"https://my-tenant.auth0.com/\",\n * audience: \"https://api.my-app.com\",\n * }),\n * });\n * ```\n */\nexport function fromJWT(\n options: FromJWTOptions,\n): (request: Request) => Promise<AuthenticatedUser | null> {\n if (!options.issuer) throw new Error(\"fromJWT: issuer is required\");\n if (isReservedIssuer(options.issuer)) {\n throw new Error(`fromJWT: ${options.issuer} is reserved for Jazz's own identities`);\n }\n if ((options.jwksUrl === undefined) === (options.publicKey === undefined)) {\n throw new Error(\"fromJWT: pass exactly one of jwksUrl and publicKey\");\n }\n const audience = options.audience as unknown;\n if (\n audience !== false &&\n !(typeof audience === \"string\" && audience !== \"\") &&\n !(\n Array.isArray(audience) &&\n audience.length > 0 &&\n audience.every((a) => typeof a === \"string\" && a !== \"\")\n )\n ) {\n throw new Error(\"fromJWT: audience is required (or false when the issuer is this app's alone)\");\n }\n const lifetime = {\n requireExp: true,\n checkNotBefore: true,\n clockToleranceSeconds: options.clockToleranceSeconds ?? 60,\n };\n const config = {\n appId: \"\",\n jwtIssuer: options.issuer,\n ...(options.jwksUrl === undefined ? {} : { jwksUrl: options.jwksUrl }),\n ...(options.publicKey === undefined ? {} : { jwtPublicKey: options.publicKey }),\n ...(options.audience === false ? {} : { jwtAudience: options.audience }),\n };\n const readToken = options.token ?? bearerToken;\n const readClaims =\n options.claims ??\n ((payload: JwtPayload) =>\n Object.fromEntries(Object.entries(payload).filter(([name]) => !REGISTERED_CLAIMS.has(name))));\n\n return async (request) => {\n const token = await readToken(request);\n if (!token) return null;\n const payload = parseJwtPayload(token);\n if (!payload || typeof payload.sub !== \"string\" || payload.sub === \"\") return null;\n try {\n await verifyExternalJwt(token, payload, config, lifetime);\n } catch (error) {\n // A token that does not verify signs nobody in; an unreachable\n // JWKS or an unusable key is the server's problem.\n if (isRequestAuthenticationError(error)) return null;\n throw error;\n }\n // Verified with `requireExp`, so the token says until when it holds; it\n // is accepted up to the clock tolerance past that, and so holds as long.\n return {\n userId: payload.sub,\n claims: readClaims(payload),\n expiresAt: (payload.exp as number) + lifetime.clockToleranceSeconds,\n };\n };\n}\n"]}
@@ -8,5 +8,6 @@ export { Db, type QueryBuilder, type QueryOptions, type TableProxy } from "../ru
8
8
  export { type SnapshotRef, parseSnapshotRef, serializeSnapshotRef, SnapshotRefFormatError, UnsupportedSnapshotError, } from "../runtime/snapshot-ref.js";
9
9
  export { trustWorkload, type BackendClientTrust } from "./backend-clients.js";
10
10
  export { fromJWT, type FromJWTOptions } from "./from-jwt.js";
11
- export { createJazz, files, memory, remote, s3, sqlite, vercel, vercelBlob, type BlobStore, type S3BlobStore, type VercelBlobStore, type CreateJazzOptions, type Jazz, type JazzStore, type BackendCredential, type JazzUser, type LocalFirstGuest, acceptLocalFirstAuth, type VercelStoreOptions, type WsLikeSocket, } from "./create-jazz.js";
11
+ export { createJazz, files, memory, remote, s3, sqlite, vercel, vercelBlob, type BlobStore, type S3BlobStore, type VercelBlobStore, type CreateJazzOptions, type Jazz, type JazzStore, type BackendCredential, type JazzUser, type LocalFirstGuest, acceptDeviceAccounts, type VercelStoreOptions, type WsLikeSocket, type InspectEvent, type InspectGrant, type InspectHook, type InspectorOptions, } from "./create-jazz.js";
12
+ export { acceptLocalFirstAuth } from "../removed-api.js";
12
13
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,EAChB,KAAK,yBAAyB,EAC9B,KAAK,oBAAoB,EACzB,KAAK,gBAAgB,EACrB,KAAK,UAAU,GAChB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,KAAK,wBAAwB,EAC7B,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AACjF,YAAY,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,EAAE,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EACL,KAAK,WAAW,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AK,WAAW,EAChB,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,KAAK,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAE,KAAK,cAAc,EAAE,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,EAAE,EACF,MAAM,EACN,MAAM,EACN,UAAU,EACV,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,IAAI,EACT,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,oBAAoB,EACpB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,GACtB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC"}
@@ -5,5 +5,7 @@ export { Db } from "../runtime/db.js";
5
5
  export { parseSnapshotRef, serializeSnapshotRef, SnapshotRefFormatError, UnsupportedSnapshotError, } from "../runtime/snapshot-ref.js";
6
6
  export { trustWorkload } from "./backend-clients.js";
7
7
  export { fromJWT } from "./from-jwt.js";
8
- export { createJazz, files, memory, remote, s3, sqlite, vercel, vercelBlob, acceptLocalFirstAuth, } from "./create-jazz.js";
8
+ export { createJazz, files, memory, remote, s3, sqlite, vercel, vercelBlob, acceptDeviceAccounts, } from "./create-jazz.js";
9
+ // Removed in alpha.61: stubs that throw, naming the replacement (one release).
10
+ export { acceptLocalFirstAuth } from "../removed-api.js";
9
11
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAKjB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGjF,OAAO,EAAE,EAAE,EAAyD,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAEL,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAA2B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAuB,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,EAAE,EACF,MAAM,EACN,MAAM,EACN,UAAU,EAUV,oBAAoB,GAGrB,MAAM,kBAAkB,CAAC","sourcesContent":["export {\n createJazzClient,\n type BackendClientCloseOptions,\n type BackendClientSession,\n type JazzClientConfig,\n type JazzClient,\n} from \"./create-jazz-session.js\";\nexport {\n type BackendQuerySchemaSource,\n type BackendSchemaInput,\n type BackendSchemaSource,\n} from \"./create-jazz-context.js\";\nexport { isRequestAuthenticationError, RequestAuthenticationError } from \"./request-auth.js\";\nexport { isNoJazzAccountError, NoJazzAccountError } from \"./no-account-error.js\";\nexport type { WasmSchema } from \"../drivers/types.js\";\nexport type { PublicSession } from \"../runtime/context.js\";\nexport { Db, type QueryBuilder, type QueryOptions, type TableProxy } from \"../runtime/db.js\";\nexport {\n type SnapshotRef,\n parseSnapshotRef,\n serializeSnapshotRef,\n SnapshotRefFormatError,\n UnsupportedSnapshotError,\n} from \"../runtime/snapshot-ref.js\";\nexport { trustWorkload, type BackendClientTrust } from \"./backend-clients.js\";\nexport { fromJWT, type FromJWTOptions } from \"./from-jwt.js\";\nexport {\n createJazz,\n files,\n memory,\n remote,\n s3,\n sqlite,\n vercel,\n vercelBlob,\n type BlobStore,\n type S3BlobStore,\n type VercelBlobStore,\n type CreateJazzOptions,\n type Jazz,\n type JazzStore,\n type BackendCredential,\n type JazzUser,\n type LocalFirstGuest,\n acceptLocalFirstAuth,\n type VercelStoreOptions,\n type WsLikeSocket,\n} from \"./create-jazz.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/backend/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,gBAAgB,GAKjB,MAAM,0BAA0B,CAAC;AAMlC,OAAO,EAAE,4BAA4B,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC7F,OAAO,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAGjF,OAAO,EAAE,EAAE,EAAyD,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EAEL,gBAAgB,EAChB,oBAAoB,EACpB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,aAAa,EAA2B,MAAM,sBAAsB,CAAC;AAC9E,OAAO,EAAE,OAAO,EAAuB,MAAM,eAAe,CAAC;AAC7D,OAAO,EACL,UAAU,EACV,KAAK,EACL,MAAM,EACN,MAAM,EACN,EAAE,EACF,MAAM,EACN,MAAM,EACN,UAAU,EAUV,oBAAoB,GAOrB,MAAM,kBAAkB,CAAC;AAE1B,+EAA+E;AAC/E,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC","sourcesContent":["export {\n createJazzClient,\n type BackendClientCloseOptions,\n type BackendClientSession,\n type JazzClientConfig,\n type JazzClient,\n} from \"./create-jazz-session.js\";\nexport {\n type BackendQuerySchemaSource,\n type BackendSchemaInput,\n type BackendSchemaSource,\n} from \"./create-jazz-context.js\";\nexport { isRequestAuthenticationError, RequestAuthenticationError } from \"./request-auth.js\";\nexport { isNoJazzAccountError, NoJazzAccountError } from \"./no-account-error.js\";\nexport type { WasmSchema } from \"../drivers/types.js\";\nexport type { PublicSession } from \"../runtime/context.js\";\nexport { Db, type QueryBuilder, type QueryOptions, type TableProxy } from \"../runtime/db.js\";\nexport {\n type SnapshotRef,\n parseSnapshotRef,\n serializeSnapshotRef,\n SnapshotRefFormatError,\n UnsupportedSnapshotError,\n} from \"../runtime/snapshot-ref.js\";\nexport { trustWorkload, type BackendClientTrust } from \"./backend-clients.js\";\nexport { fromJWT, type FromJWTOptions } from \"./from-jwt.js\";\nexport {\n createJazz,\n files,\n memory,\n remote,\n s3,\n sqlite,\n vercel,\n vercelBlob,\n type BlobStore,\n type S3BlobStore,\n type VercelBlobStore,\n type CreateJazzOptions,\n type Jazz,\n type JazzStore,\n type BackendCredential,\n type JazzUser,\n type LocalFirstGuest,\n acceptDeviceAccounts,\n type VercelStoreOptions,\n type WsLikeSocket,\n type InspectEvent,\n type InspectGrant,\n type InspectHook,\n type InspectorOptions,\n} from \"./create-jazz.js\";\n\n// Removed in alpha.61: stubs that throw, naming the replacement (one release).\nexport { acceptLocalFirstAuth } from \"../removed-api.js\";\n"]}
@@ -0,0 +1,14 @@
1
+ /** The directory holding the backend Inspector build, or null when this install has none. */
2
+ export declare function resolveInspectorUiDir(): string | null;
3
+ /**
4
+ * The page as served at `<basePath>/inspect`, without the trailing slash.
5
+ * Vite builds it with relative URLs (`./assets/...`), which there would
6
+ * resolve beside `inspect` rather than below it, so point them below it.
7
+ */
8
+ export declare function pageWithoutTrailingSlash(html: string): string;
9
+ /**
10
+ * Serve the Inspector UI: from `dir` when given (null: there is none), else
11
+ * the one this install carries, loaded on the first request.
12
+ */
13
+ export declare function createInspectorUi(dir?: string | null): (_request: Request, path: string) => Promise<Response | null>;
14
+ //# sourceMappingURL=inspect-ui.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect-ui.d.ts","sourceRoot":"","sources":["../../src/backend/inspect-ui.ts"],"names":[],"mappings":"AAiCA,6FAA6F;AAC7F,wBAAgB,qBAAqB,IAAI,MAAM,GAAG,IAAI,CASrD;AAkBD;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE7D;AAqCD;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,IAAI,IAarB,UAAU,OAAO,EAAE,MAAM,MAAM,KAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC,CAuCzF"}
@@ -0,0 +1,156 @@
1
+ // The Inspector UI an app's backend serves at `<basePath>/inspect/`: the
2
+ // inspector package's `backend.html` build, and at
3
+ // `<basePath>/inspect/embedded.html` the overlay for local-first pages.
4
+ // Published jazz-tools carries it as modules, `inspector-ui-files.js`
5
+ // (generated with the overlay's embedded build, see
6
+ // scripts/stage-inspector-overlay.mjs), so that it ships wherever the code
7
+ // does: Next.js's output file tracing leaves files read from disk behind. In
8
+ // this monorepo it is read from the inspector package's build output.
9
+ //
10
+ // The page and its scripts are public code; what they can see is decided by
11
+ // the API next to them. Nothing here reads a credential.
12
+ import { existsSync } from "node:fs";
13
+ import { readFile } from "node:fs/promises";
14
+ import { dirname, join, normalize, sep } from "node:path";
15
+ import { fileURLToPath } from "node:url";
16
+ const PAGE = "backend.html";
17
+ // The overlay a local-first page frames (`jazz-tools/inspector`). It reads only
18
+ // the framing page's own Db, through the window, never this backend's API.
19
+ const OVERLAY_PAGE = "embedded.html";
20
+ const TYPES = {
21
+ ".html": "text/html; charset=utf-8",
22
+ ".js": "text/javascript; charset=utf-8",
23
+ ".css": "text/css; charset=utf-8",
24
+ ".wasm": "application/wasm",
25
+ ".json": "application/json; charset=utf-8",
26
+ ".svg": "image/svg+xml",
27
+ ".png": "image/png",
28
+ ".woff2": "font/woff2",
29
+ };
30
+ /** The directory holding the backend Inspector build, or null when this install has none. */
31
+ export function resolveInspectorUiDir() {
32
+ const here = dirname(fileURLToPath(import.meta.url)); // .../jazz-tools/{src,dist}/backend
33
+ for (const dir of [
34
+ join(here, "../dev/inspector-overlay/embedded"),
35
+ join(here, "../../../inspector/dist-embedded"),
36
+ ]) {
37
+ if (existsSync(join(dir, PAGE)))
38
+ return dir;
39
+ }
40
+ return null;
41
+ }
42
+ /** Headers for the page: no framing (the approval page must not be clickjacked), no referrer. */
43
+ const PAGE_HEADERS = {
44
+ "Cache-Control": "no-store",
45
+ "Content-Security-Policy": "frame-ancestors 'none'; base-uri 'none'; object-src 'none'",
46
+ "X-Frame-Options": "DENY",
47
+ "Referrer-Policy": "no-referrer",
48
+ "X-Content-Type-Options": "nosniff",
49
+ };
50
+ /** Headers for the overlay page: framed only by pages on this origin. */
51
+ const OVERLAY_HEADERS = {
52
+ ...PAGE_HEADERS,
53
+ "Content-Security-Policy": "frame-ancestors 'self'; base-uri 'none'; object-src 'none'",
54
+ "X-Frame-Options": "SAMEORIGIN",
55
+ };
56
+ /**
57
+ * The page as served at `<basePath>/inspect`, without the trailing slash.
58
+ * Vite builds it with relative URLs (`./assets/...`), which there would
59
+ * resolve beside `inspect` rather than below it, so point them below it.
60
+ */
61
+ export function pageWithoutTrailingSlash(html) {
62
+ return html.replaceAll('="./', '="inspect/');
63
+ }
64
+ function filesInDir(dir) {
65
+ return async (file) => {
66
+ try {
67
+ return new Uint8Array(await readFile(join(dir, file)));
68
+ }
69
+ catch {
70
+ return null;
71
+ }
72
+ };
73
+ }
74
+ function filesInModules(files) {
75
+ return async (file) => {
76
+ const path = file.split(sep).join("/");
77
+ if (!Object.hasOwn(files, path))
78
+ return null;
79
+ const { default: encoded } = await files[path]();
80
+ const binary = atob(encoded);
81
+ const bytes = new Uint8Array(binary.length);
82
+ for (let i = 0; i < binary.length; i++)
83
+ bytes[i] = binary.charCodeAt(i);
84
+ return bytes;
85
+ };
86
+ }
87
+ /** The installed UI: the generated module, else (in this monorepo) the build directory. */
88
+ async function installedUi() {
89
+ const { INSPECTOR_UI_FILES } = await import("./inspector-ui-files.js");
90
+ if (INSPECTOR_UI_FILES)
91
+ return filesInModules(INSPECTOR_UI_FILES);
92
+ const dir = resolveInspectorUiDir();
93
+ return dir ? filesInDir(dir) : null;
94
+ }
95
+ /**
96
+ * Serve the Inspector UI: from `dir` when given (null: there is none), else
97
+ * the one this install carries, loaded on the first request.
98
+ */
99
+ export function createInspectorUi(dir) {
100
+ let ui = dir === undefined ? undefined : Promise.resolve(dir === null ? null : filesInDir(dir));
101
+ const read = async (file) => {
102
+ ui ??= installedUi();
103
+ const files = await ui;
104
+ return files ? files(file) : null;
105
+ };
106
+ /**
107
+ * The file for `path` below `/inspect`, or null. The page is at `/`, and at
108
+ * `""` too: Next.js (and other hosts) redirect `/inspect/` to `/inspect`,
109
+ * so redirecting back would loop.
110
+ */
111
+ return async function serveUi(_request, path) {
112
+ if (path === "/" || path === "") {
113
+ const page = await read(PAGE);
114
+ if (!page)
115
+ return null;
116
+ const html = new TextDecoder().decode(page);
117
+ return new Response(path === "" ? pageWithoutTrailingSlash(html) : html, {
118
+ headers: { "Content-Type": TYPES[".html"], ...PAGE_HEADERS },
119
+ });
120
+ }
121
+ if (path === `/${OVERLAY_PAGE}`) {
122
+ const overlay = await read(OVERLAY_PAGE);
123
+ if (!overlay)
124
+ return null;
125
+ return new Response(overlay, {
126
+ headers: { "Content-Type": TYPES[".html"], ...OVERLAY_HEADERS },
127
+ });
128
+ }
129
+ // Only the build's hashed assets, nothing else in the directory.
130
+ let relative;
131
+ try {
132
+ relative = decodeURIComponent(path.slice(1));
133
+ }
134
+ catch {
135
+ return null;
136
+ }
137
+ const file = normalize(relative);
138
+ if (!file.startsWith(`assets${sep}`) || file.includes(`..`) || file.includes("\0")) {
139
+ return null;
140
+ }
141
+ const type = TYPES[file.slice(file.lastIndexOf("."))];
142
+ if (!type)
143
+ return null;
144
+ const body = await read(file);
145
+ if (!body)
146
+ return null;
147
+ return new Response(body, {
148
+ headers: {
149
+ "Content-Type": type,
150
+ "Cache-Control": "public, max-age=31536000, immutable",
151
+ "X-Content-Type-Options": "nosniff",
152
+ },
153
+ });
154
+ };
155
+ }
156
+ //# sourceMappingURL=inspect-ui.js.map
@@ -0,0 +1 @@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C,GAAG,CAAC,CAAC,CAAC,CAAC;QACtD,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9B,IAAI,CAAC,IAAI;YAAE,OAAO,IAAI,CAAC;QACvB,OAAO,IAAI,QAAQ,CAAC,IAAI,EAAE;YACxB,OAAO,EAAE;gBACP,cAAc,EAAE,IAAI;gBACpB,eAAe,EAAE,qCAAqC;gBACtD,wBAAwB,EAAE,SAAS;aACpC;SACF,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC","sourcesContent":["// The Inspector UI an app's backend serves at `<basePath>/inspect/`: the\n// inspector package's `backend.html` build, and at\n// `<basePath>/inspect/embedded.html` the overlay for local-first pages.\n// Published jazz-tools carries it as modules, `inspector-ui-files.js`\n// (generated with the overlay's embedded build, see\n// scripts/stage-inspector-overlay.mjs), so that it ships wherever the code\n// does: Next.js's output file tracing leaves files read from disk behind. In\n// this monorepo it is read from the inspector package's build output.\n//\n// The page and its scripts are public code; what they can see is decided by\n// the API next to them. Nothing here reads a credential.\n\nimport { existsSync } from \"node:fs\";\nimport { readFile } from \"node:fs/promises\";\nimport { dirname, join, normalize, sep } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nconst PAGE = \"backend.html\";\n// The overlay a local-first page frames (`jazz-tools/inspector`). It reads only\n// the framing page's own Db, through the window, never this backend's API.\nconst OVERLAY_PAGE = \"embedded.html\";\n\nconst TYPES: Record<string, string> = {\n \".html\": \"text/html; charset=utf-8\",\n \".js\": \"text/javascript; charset=utf-8\",\n \".css\": \"text/css; charset=utf-8\",\n \".wasm\": \"application/wasm\",\n \".json\": \"application/json; charset=utf-8\",\n \".svg\": \"image/svg+xml\",\n \".png\": \"image/png\",\n \".woff2\": \"font/woff2\",\n};\n\n/** The directory holding the backend Inspector build, or null when this install has none. */\nexport function resolveInspectorUiDir(): string | null {\n const here = dirname(fileURLToPath(import.meta.url)); // .../jazz-tools/{src,dist}/backend\n for (const dir of [\n join(here, \"../dev/inspector-overlay/embedded\"),\n join(here, \"../../../inspector/dist-embedded\"),\n ]) {\n if (existsSync(join(dir, PAGE))) return dir;\n }\n return null;\n}\n\n/** Headers for the page: no framing (the approval page must not be clickjacked), no referrer. */\nconst PAGE_HEADERS = {\n \"Cache-Control\": \"no-store\",\n \"Content-Security-Policy\": \"frame-ancestors 'none'; base-uri 'none'; object-src 'none'\",\n \"X-Frame-Options\": \"DENY\",\n \"Referrer-Policy\": \"no-referrer\",\n \"X-Content-Type-Options\": \"nosniff\",\n};\n\n/** Headers for the overlay page: framed only by pages on this origin. */\nconst OVERLAY_HEADERS = {\n ...PAGE_HEADERS,\n \"Content-Security-Policy\": \"frame-ancestors 'self'; base-uri 'none'; object-src 'none'\",\n \"X-Frame-Options\": \"SAMEORIGIN\",\n};\n\n/**\n * The page as served at `<basePath>/inspect`, without the trailing slash.\n * Vite builds it with relative URLs (`./assets/...`), which there would\n * resolve beside `inspect` rather than below it, so point them below it.\n */\nexport function pageWithoutTrailingSlash(html: string): string {\n return html.replaceAll('=\"./', '=\"inspect/');\n}\n\n/** Reads a file of the UI build by its path below the build, or null. */\ntype UiFiles = (file: string) => Promise<Uint8Array<ArrayBuffer> | null>;\n\nfunction filesInDir(dir: string): UiFiles {\n return async (file) => {\n try {\n return new Uint8Array(await readFile(join(dir, file)));\n } catch {\n return null;\n }\n };\n}\n\nfunction filesInModules(\n files: Readonly<Record<string, () => Promise<{ default: string }>>>,\n): UiFiles {\n return async (file) => {\n const path = file.split(sep).join(\"/\");\n if (!Object.hasOwn(files, path)) return null;\n const { default: encoded } = await files[path]!();\n const binary = atob(encoded);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);\n return bytes;\n };\n}\n\n/** The installed UI: the generated module, else (in this monorepo) the build directory. */\nasync function installedUi(): Promise<UiFiles | null> {\n const { INSPECTOR_UI_FILES } = await import(\"./inspector-ui-files.js\");\n if (INSPECTOR_UI_FILES) return filesInModules(INSPECTOR_UI_FILES);\n const dir = resolveInspectorUiDir();\n return dir ? filesInDir(dir) : null;\n}\n\n/**\n * Serve the Inspector UI: from `dir` when given (null: there is none), else\n * the one this install carries, loaded on the first request.\n */\nexport function createInspectorUi(dir?: string | null) {\n let ui: Promise<UiFiles | null> | undefined =\n dir === undefined ? undefined : Promise.resolve(dir === null ? null : filesInDir(dir));\n const read = async (file: string) => {\n ui ??= installedUi();\n const files = await ui;\n return files ? files(file) : null;\n };\n /**\n * The file for `path` below `/inspect`, or null. The page is at `/`, and at\n * `\"\"` too: Next.js (and other hosts) redirect `/inspect/` to `/inspect`,\n * so redirecting back would loop.\n */\n return async function serveUi(_request: Request, path: string): Promise<Response | null> {\n if (path === \"/\" || path === \"\") {\n const page = await read(PAGE);\n if (!page) return null;\n const html = new TextDecoder().decode(page);\n return new Response(path === \"\" ? pageWithoutTrailingSlash(html) : html, {\n headers: { \"Content-Type\": TYPES[\".html\"]!, ...PAGE_HEADERS },\n });\n }\n if (path === `/${OVERLAY_PAGE}`) {\n const overlay = await read(OVERLAY_PAGE);\n if (!overlay) return null;\n return new Response(overlay, {\n headers: { \"Content-Type\": TYPES[\".html\"]!, ...OVERLAY_HEADERS },\n });\n }\n // Only the build's hashed assets, nothing else in the directory.\n let relative: string;\n try {\n relative = decodeURIComponent(path.slice(1));\n } catch {\n return null;\n }\n const file = normalize(relative);\n if (!file.startsWith(`assets${sep}`) || file.includes(`..`) || file.includes(\"\\0\")) {\n return null;\n }\n const type = TYPES[file.slice(file.lastIndexOf(\".\"))];\n if (!type) return null;\n const body = await read(file);\n if (!body) return null;\n return new Response(body, {\n headers: {\n \"Content-Type\": type,\n \"Cache-Control\": \"public, max-age=31536000, immutable\",\n \"X-Content-Type-Options\": \"nosniff\",\n },\n });\n };\n}\n"]}
@@ -0,0 +1,129 @@
1
+ import type { WasmSchema } from "../drivers/types.js";
2
+ import type { Db } from "../runtime/db.js";
3
+ import { type InspectErrorCode, type InspectRequest, type InspectSessionInfo, type InspectVia } from "../inspect/protocol.js";
4
+ /** Who is inspecting, as the app's `inspect` hook decides. */
5
+ export interface InspectGrant {
6
+ /** Who this is, for the audit log (an email, a staff id). */
7
+ by: string;
8
+ /** Whether they may write. Defaults to false. */
9
+ write?: boolean;
10
+ }
11
+ /**
12
+ * Decide whether `request` may inspect this app's data, and as whom. Return
13
+ * null to refuse. **A grant reads and, with `write`, changes every row of
14
+ * every table, with your permissions not checked.** Grant it only to people
15
+ * who may see all of your users' data, and prefer a gate in front of the app
16
+ * that is separate from your users' sign-in (Vercel deployment protection,
17
+ * Cloudflare Access, a VPN or SSO proxy) over a flag on a user account.
18
+ */
19
+ export type InspectHook = (request: Request) => InspectGrant | null | undefined | Promise<InspectGrant | null | undefined>;
20
+ /** One audited Inspector call. */
21
+ export interface InspectEvent {
22
+ /** Unix milliseconds. */
23
+ at: number;
24
+ by: string;
25
+ via: InspectVia;
26
+ op: InspectRequest["op"];
27
+ table?: string;
28
+ /** The user whose permissions the call ran under, if not the backend's. */
29
+ as?: string;
30
+ /** The names (not values) of the claims given for `as`, when some were. */
31
+ asClaims?: string[];
32
+ /** Rows the answer carried, or rows the write touched. */
33
+ rows?: number;
34
+ write: boolean;
35
+ /** The id of the agent token, when one was used. */
36
+ tokenId?: string;
37
+ /** Set when the call was refused or failed. */
38
+ error?: InspectErrorCode;
39
+ }
40
+ export interface InspectorOptions {
41
+ /**
42
+ * Columns agent tokens never see, by table (e.g. `{ users: ["email"] }`).
43
+ * Their values read as `"[redacted]"`, and a token can't filter, sort or
44
+ * write by them. People let in by the hook see them.
45
+ */
46
+ redact?: Record<string, string[]>;
47
+ /**
48
+ * Called for every Inspector call, allowed or refused. Defaults to one
49
+ * `console.info` line per call. Send it to your own audit log in production.
50
+ */
51
+ audit?: (event: InspectEvent) => void;
52
+ /**
53
+ * The secret agent tokens are signed with, shared by every instance of this
54
+ * backend. Needed where the store has no secret of its own to derive it from
55
+ * (`vercel()`, and `remote()` with a `backendCredential`). Changing it
56
+ * revokes every token.
57
+ */
58
+ tokenSecret?: string;
59
+ /** Tokens issued before this moment no longer work: revoke all tokens without changing the secret. */
60
+ tokensIssuedAfter?: Date | number;
61
+ /** The longest a token may live. Defaults to one day. */
62
+ maxTokenTtlSeconds?: number;
63
+ }
64
+ /** What the inspector needs from the createJazz it serves. */
65
+ export interface InspectorDeps {
66
+ appId: string;
67
+ basePath: string;
68
+ /** The URLs browsers reach this backend's `basePath` at, when configured. */
69
+ publicUrls: string[];
70
+ schema(): WasmSchema;
71
+ permissions: unknown;
72
+ /** The backend's own database (backend authority). */
73
+ db(): Db;
74
+ /** The database as `userId`, judged by the app's permissions. */
75
+ dbAs(user: {
76
+ userId: string;
77
+ claims?: Record<string, unknown>;
78
+ }): Promise<Db>;
79
+ sessions(): InspectSessionInfo[];
80
+ hook: InspectHook | undefined;
81
+ options: InspectorOptions;
82
+ /** The secret agent tokens are signed with, or null where the store has none. */
83
+ tokenSecret(): Promise<string | null>;
84
+ /** The peer address a request came from, where the host knows it. */
85
+ remoteAddress(request: Request): string | undefined;
86
+ /** The Inspector UI's file at `path` (`/`, or below it), or null when there is none. */
87
+ serveUi(request: Request, path: string): Promise<Response | null>;
88
+ env?: NodeJS.ProcessEnv;
89
+ now?: () => number;
90
+ }
91
+ interface Admitted {
92
+ by: string;
93
+ via: InspectVia;
94
+ write: boolean;
95
+ tables?: string[];
96
+ expiresAt?: number;
97
+ tokenId?: string;
98
+ }
99
+ /** {@link InspectorOptions} as the Inspector applies them. */
100
+ interface InspectorSettings {
101
+ redact: Map<string, Set<string>>;
102
+ audit: (event: InspectEvent) => void;
103
+ /** Tokens issued before this (Unix seconds) are refused. */
104
+ issuedAfter: number | undefined;
105
+ maxTtl: number;
106
+ }
107
+ /**
108
+ * Check `options` and read them as the Inspector applies them. createJazz
109
+ * calls it when it starts and on each reload, so bad options fail there,
110
+ * not on the next Inspector call.
111
+ */
112
+ export declare function inspectorSettings(options: InspectorOptions): InspectorSettings;
113
+ export declare function createInspector(deps: InspectorDeps): {
114
+ /** Answer a request for `path` (below `basePath`), which starts with `/inspect`. */
115
+ handle(request: Request, path: string): Promise<Response>;
116
+ mintToken: (admitted: Admitted, request: Extract<InspectRequest, {
117
+ op: "mint_token";
118
+ }>) => Promise<{
119
+ token: string;
120
+ expiresAt: number;
121
+ tokenId: string;
122
+ }>;
123
+ verifyToken: (token: string) => Promise<Admitted>;
124
+ };
125
+ export type Inspector = ReturnType<typeof createInspector>;
126
+ /** A random secret for stores that keep one beside their data. */
127
+ export declare function newTokenSecret(): string;
128
+ export {};
129
+ //# sourceMappingURL=inspect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspect.d.ts","sourceRoot":"","sources":["../../src/backend/inspect.ts"],"names":[],"mappings":"AAqBA,OAAO,KAAK,EAAc,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,KAAK,EAAE,EAAE,EAA4B,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAgBL,KAAK,gBAAgB,EAErB,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EAGhB,MAAM,wBAAwB,CAAC;AAEhC,8DAA8D;AAC9D,MAAM,WAAW,YAAY;IAC3B,6DAA6D;IAC7D,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GAAG,CACxB,OAAO,EAAE,OAAO,KACb,YAAY,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC,YAAY,GAAG,IAAI,GAAG,SAAS,CAAC,CAAC;AAEhF,kCAAkC;AAClC,MAAM,WAAW,YAAY;IAC3B,yBAAyB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,UAAU,CAAC;IAChB,EAAE,EAAE,cAAc,CAAC,IAAI,CAA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