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

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 (719) 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 +13 -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 +38 -2
  19. package/dist/accounts/persistence.d.ts.map +1 -1
  20. package/dist/accounts/persistence.js +123 -6
  21. package/dist/accounts/persistence.js.map +1 -1
  22. package/dist/accounts/registry-client.d.ts +29 -0
  23. package/dist/accounts/registry-client.d.ts.map +1 -1
  24. package/dist/accounts/registry-client.js +45 -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-context.d.ts +7 -0
  30. package/dist/backend/create-jazz-context.d.ts.map +1 -1
  31. package/dist/backend/create-jazz-context.js +115 -18
  32. package/dist/backend/create-jazz-context.js.map +1 -1
  33. package/dist/backend/create-jazz-session.d.ts +9 -7
  34. package/dist/backend/create-jazz-session.d.ts.map +1 -1
  35. package/dist/backend/create-jazz-session.js +55 -17
  36. package/dist/backend/create-jazz-session.js.map +1 -1
  37. package/dist/backend/create-jazz.d.ts +196 -38
  38. package/dist/backend/create-jazz.d.ts.map +1 -1
  39. package/dist/backend/create-jazz.js +935 -147
  40. package/dist/backend/create-jazz.js.map +1 -1
  41. package/dist/backend/early-db.d.ts.map +1 -1
  42. package/dist/backend/early-db.js +1 -0
  43. package/dist/backend/early-db.js.map +1 -1
  44. package/dist/backend/external-jwt.d.ts.map +1 -1
  45. package/dist/backend/external-jwt.js +34 -10
  46. package/dist/backend/external-jwt.js.map +1 -1
  47. package/dist/backend/from-jwt.d.ts +6 -4
  48. package/dist/backend/from-jwt.d.ts.map +1 -1
  49. package/dist/backend/from-jwt.js +11 -3
  50. package/dist/backend/from-jwt.js.map +1 -1
  51. package/dist/backend/index.d.ts +2 -1
  52. package/dist/backend/index.d.ts.map +1 -1
  53. package/dist/backend/index.js +3 -1
  54. package/dist/backend/index.js.map +1 -1
  55. package/dist/backend/inspect-ui.d.ts +14 -0
  56. package/dist/backend/inspect-ui.d.ts.map +1 -0
  57. package/dist/backend/inspect-ui.js +156 -0
  58. package/dist/backend/inspect-ui.js.map +1 -0
  59. package/dist/backend/inspect.d.ts +133 -0
  60. package/dist/backend/inspect.d.ts.map +1 -0
  61. package/dist/backend/inspect.js +983 -0
  62. package/dist/backend/inspect.js.map +1 -0
  63. package/dist/backend/inspector-ui/0.js +2 -0
  64. package/dist/backend/inspector-ui/1.js +2 -0
  65. package/dist/backend/inspector-ui/10.js +2 -0
  66. package/dist/backend/inspector-ui/11.js +2 -0
  67. package/dist/backend/inspector-ui/12.js +2 -0
  68. package/dist/backend/inspector-ui/13.js +2 -0
  69. package/dist/backend/inspector-ui/14.js +2 -0
  70. package/dist/backend/inspector-ui/15.js +2 -0
  71. package/dist/backend/inspector-ui/16.js +2 -0
  72. package/dist/backend/inspector-ui/17.js +2 -0
  73. package/dist/backend/inspector-ui/18.js +2 -0
  74. package/dist/backend/inspector-ui/19.js +2 -0
  75. package/dist/backend/inspector-ui/2.js +2 -0
  76. package/dist/backend/inspector-ui/20.js +2 -0
  77. package/dist/backend/inspector-ui/3.js +2 -0
  78. package/dist/backend/inspector-ui/4.js +2 -0
  79. package/dist/backend/inspector-ui/5.js +2 -0
  80. package/dist/backend/inspector-ui/6.js +2 -0
  81. package/dist/backend/inspector-ui/7.js +2 -0
  82. package/dist/backend/inspector-ui/8.js +2 -0
  83. package/dist/backend/inspector-ui/9.js +2 -0
  84. package/dist/backend/inspector-ui-files.d.ts +4 -0
  85. package/dist/backend/inspector-ui-files.d.ts.map +1 -0
  86. package/dist/backend/inspector-ui-files.js +25 -0
  87. package/dist/backend/request-auth.d.ts +11 -0
  88. package/dist/backend/request-auth.d.ts.map +1 -1
  89. package/dist/backend/request-auth.js +14 -0
  90. package/dist/backend/request-auth.js.map +1 -1
  91. package/dist/backend/session-expiry.d.ts +61 -0
  92. package/dist/backend/session-expiry.d.ts.map +1 -0
  93. package/dist/backend/session-expiry.js +102 -0
  94. package/dist/backend/session-expiry.js.map +1 -0
  95. package/dist/backend/signing-key.d.ts +10 -0
  96. package/dist/backend/signing-key.d.ts.map +1 -0
  97. package/dist/backend/signing-key.js +15 -0
  98. package/dist/backend/signing-key.js.map +1 -0
  99. package/dist/backend/store-log.d.ts +3 -0
  100. package/dist/backend/store-log.d.ts.map +1 -0
  101. package/dist/backend/store-log.js +16 -0
  102. package/dist/backend/store-log.js.map +1 -0
  103. package/dist/backend/upgrade-status.d.ts +19 -0
  104. package/dist/backend/upgrade-status.d.ts.map +1 -0
  105. package/dist/backend/upgrade-status.js +55 -0
  106. package/dist/backend/upgrade-status.js.map +1 -0
  107. package/dist/backend/vercel-store.d.ts +88 -12
  108. package/dist/backend/vercel-store.d.ts.map +1 -1
  109. package/dist/backend/vercel-store.js +303 -44
  110. package/dist/backend/vercel-store.js.map +1 -1
  111. package/dist/backend/ws-peer.d.ts +32 -0
  112. package/dist/backend/ws-peer.d.ts.map +1 -0
  113. package/dist/backend/ws-peer.js +40 -0
  114. package/dist/backend/ws-peer.js.map +1 -0
  115. package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.d.ts +134 -0
  116. package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.d.ts.map +1 -0
  117. package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.js +121 -0
  118. package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.js.map +1 -0
  119. package/dist/better-auth-adapter/fixtures/schema.d.ts +2 -1
  120. package/dist/better-auth-adapter/fixtures/schema.d.ts.map +1 -1
  121. package/dist/better-auth-adapter/fixtures/schema.js +2 -1
  122. package/dist/better-auth-adapter/fixtures/schema.js.map +1 -1
  123. package/dist/better-auth-adapter/index.d.ts.map +1 -1
  124. package/dist/better-auth-adapter/index.js +47 -0
  125. package/dist/better-auth-adapter/index.js.map +1 -1
  126. package/dist/classic-api.d.ts.map +1 -1
  127. package/dist/classic-api.js +36 -0
  128. package/dist/classic-api.js.map +1 -1
  129. package/dist/cli.d.ts.map +1 -1
  130. package/dist/cli.js +54 -11
  131. package/dist/cli.js.map +1 -1
  132. package/dist/client/index.d.ts +2 -6
  133. package/dist/client/index.d.ts.map +1 -1
  134. package/dist/client/index.js +2 -3
  135. package/dist/client/index.js.map +1 -1
  136. package/dist/cloud/credentials.d.ts +1 -1
  137. package/dist/cloud/credentials.d.ts.map +1 -1
  138. package/dist/cloud/credentials.js.map +1 -1
  139. package/dist/dev/catalogue-project.d.ts +12 -3
  140. package/dist/dev/catalogue-project.d.ts.map +1 -1
  141. package/dist/dev/catalogue-project.js +29 -4
  142. package/dist/dev/catalogue-project.js.map +1 -1
  143. package/dist/dev/catalogue.d.ts +12 -0
  144. package/dist/dev/catalogue.d.ts.map +1 -1
  145. package/dist/dev/catalogue.js +94 -15
  146. package/dist/dev/catalogue.js.map +1 -1
  147. package/dist/dev/dev-server.d.ts +4 -1
  148. package/dist/dev/dev-server.d.ts.map +1 -1
  149. package/dist/dev/dev-server.js +41 -3
  150. package/dist/dev/dev-server.js.map +1 -1
  151. package/dist/dev/inspector-overlay/embedded/assets/backend-C6JfNAB2.js +1 -0
  152. package/dist/dev/inspector-overlay/embedded/assets/backend-DHeT1LCS.css +1 -0
  153. package/dist/dev/inspector-overlay/embedded/assets/{create-legacy-browser-delegate-X_T_QKCN.js → create-legacy-browser-delegate-Bf58kV5i.js} +1 -1
  154. package/dist/dev/inspector-overlay/embedded/assets/{esm-aRzpnC3u.js → esm-B8Fn7-qJ.js} +1 -1
  155. package/dist/dev/inspector-overlay/embedded/assets/{esm-ezD5H765.js → esm-C3BWHq-S.js} +1 -1
  156. package/dist/dev/inspector-overlay/embedded/assets/esm-DC_mAoiW.js +1 -0
  157. package/dist/dev/inspector-overlay/embedded/assets/{esm-7mP3GQX4.js → esm-D_R-EGgt.js} +1 -1
  158. package/dist/dev/inspector-overlay/embedded/assets/{esm-BX6IY2Mv.js → esm-WihpI9g6.js} +1 -1
  159. package/dist/dev/inspector-overlay/embedded/assets/index-C_pcvEcg.js +1 -0
  160. package/dist/dev/inspector-overlay/embedded/assets/{jazz-broker-worker-XRRxJUcx.js → jazz-broker-worker-Cv6-V0tc.js} +787 -608
  161. package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-Db-pNME-.js +5 -0
  162. package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-CTwPHZcZ.js +1 -0
  163. package/dist/dev/inspector-overlay/embedded/assets/{jazz_wasm_bg-KR7h3v27.wasm → jazz_wasm_bg-HpkRDlj-.wasm} +0 -0
  164. package/dist/dev/inspector-overlay/embedded/assets/src-B5UtjtXQ.js +22 -0
  165. package/dist/dev/inspector-overlay/embedded/assets/{index-C78Pprka.css → src-Cq8gSOLx.css} +1 -1
  166. package/dist/dev/inspector-overlay/embedded/assets/{trace-api-B5CaetI0.js → trace-api-BctnwbUf.js} +1 -1
  167. package/dist/dev/inspector-overlay/embedded/backend.html +16 -0
  168. package/dist/dev/inspector-overlay/embedded/embedded.html +3 -2
  169. package/dist/dev/inspector-overlay/host-bridge.d.ts.map +1 -1
  170. package/dist/dev/inspector-overlay/host-bridge.js +4 -1
  171. package/dist/dev/inspector-overlay/host-bridge.js.map +1 -1
  172. package/dist/dev/inspector-overlay/loader.d.ts +12 -1
  173. package/dist/dev/inspector-overlay/loader.d.ts.map +1 -1
  174. package/dist/dev/inspector-overlay/loader.js +31 -4
  175. package/dist/dev/inspector-overlay/loader.js.map +1 -1
  176. package/dist/dev/migrations.d.ts.map +1 -1
  177. package/dist/dev/migrations.js +53 -7
  178. package/dist/dev/migrations.js.map +1 -1
  179. package/dist/drivers/schema-wire.d.ts +6 -2
  180. package/dist/drivers/schema-wire.d.ts.map +1 -1
  181. package/dist/drivers/schema-wire.js +6 -2
  182. package/dist/drivers/schema-wire.js.map +1 -1
  183. package/dist/effect/jazz.d.ts +12 -5
  184. package/dist/effect/jazz.d.ts.map +1 -1
  185. package/dist/effect/jazz.js +28 -5
  186. package/dist/effect/jazz.js.map +1 -1
  187. package/dist/expo/create-account-manager.d.ts +1 -1
  188. package/dist/expo/create-account-manager.d.ts.map +1 -1
  189. package/dist/expo/create-jazz-session.d.ts +37 -17
  190. package/dist/expo/create-jazz-session.d.ts.map +1 -1
  191. package/dist/expo/create-jazz-session.js +53 -10
  192. package/dist/expo/create-jazz-session.js.map +1 -1
  193. package/dist/expo/index.d.ts +5 -8
  194. package/dist/expo/index.d.ts.map +1 -1
  195. package/dist/expo/index.js +5 -7
  196. package/dist/expo/index.js.map +1 -1
  197. package/dist/expo/metro.d.ts +20 -0
  198. package/dist/expo/metro.d.ts.map +1 -0
  199. package/dist/expo/metro.js +58 -0
  200. package/dist/expo/metro.js.map +1 -0
  201. package/dist/expo/provider.d.ts +6 -3
  202. package/dist/expo/provider.d.ts.map +1 -1
  203. package/dist/expo/provider.js +7 -6
  204. package/dist/expo/provider.js.map +1 -1
  205. package/dist/index.d.ts +3 -2
  206. package/dist/index.d.ts.map +1 -1
  207. package/dist/index.js +3 -1
  208. package/dist/index.js.map +1 -1
  209. package/dist/inspect/cli.d.ts +12 -0
  210. package/dist/inspect/cli.d.ts.map +1 -0
  211. package/dist/inspect/cli.js +320 -0
  212. package/dist/inspect/cli.js.map +1 -0
  213. package/dist/inspect/client.d.ts +67 -0
  214. package/dist/inspect/client.d.ts.map +1 -0
  215. package/dist/inspect/client.js +254 -0
  216. package/dist/inspect/client.js.map +1 -0
  217. package/dist/inspect/mcp.d.ts +28 -0
  218. package/dist/inspect/mcp.d.ts.map +1 -0
  219. package/dist/inspect/mcp.js +441 -0
  220. package/dist/inspect/mcp.js.map +1 -0
  221. package/dist/inspect/protocol.d.ts +317 -0
  222. package/dist/inspect/protocol.d.ts.map +1 -0
  223. package/dist/inspect/protocol.js +544 -0
  224. package/dist/inspect/protocol.js.map +1 -0
  225. package/dist/inspector/index.d.ts +10 -0
  226. package/dist/inspector/index.d.ts.map +1 -0
  227. package/dist/inspector/index.js +27 -0
  228. package/dist/inspector/index.js.map +1 -0
  229. package/dist/local-first/index.d.ts +2 -0
  230. package/dist/local-first/index.d.ts.map +1 -1
  231. package/dist/local-first/index.js +2 -0
  232. package/dist/local-first/index.js.map +1 -1
  233. package/dist/migrations.d.ts +23 -3
  234. package/dist/migrations.d.ts.map +1 -1
  235. package/dist/migrations.js +28 -6
  236. package/dist/migrations.js.map +1 -1
  237. package/dist/module-interop.d.ts +17 -0
  238. package/dist/module-interop.d.ts.map +1 -0
  239. package/dist/module-interop.js +32 -0
  240. package/dist/module-interop.js.map +1 -0
  241. package/dist/permissions/index.d.ts +1 -1
  242. package/dist/permissions/index.d.ts.map +1 -1
  243. package/dist/permissions/index.js +31 -10
  244. package/dist/permissions/index.js.map +1 -1
  245. package/dist/prosemirror/sync.d.ts.map +1 -1
  246. package/dist/prosemirror/sync.js +43 -21
  247. package/dist/prosemirror/sync.js.map +1 -1
  248. package/dist/react/index.d.ts +4 -9
  249. package/dist/react/index.d.ts.map +1 -1
  250. package/dist/react/index.js +4 -6
  251. package/dist/react/index.js.map +1 -1
  252. package/dist/react/provider-props.d.ts +7 -0
  253. package/dist/react/provider-props.d.ts.map +1 -0
  254. package/dist/react/provider-props.js +15 -0
  255. package/dist/react/provider-props.js.map +1 -0
  256. package/dist/react/provider.d.ts +9 -15
  257. package/dist/react/provider.d.ts.map +1 -1
  258. package/dist/react/provider.js +19 -38
  259. package/dist/react/provider.js.map +1 -1
  260. package/dist/react-core/index.d.ts +3 -4
  261. package/dist/react-core/index.d.ts.map +1 -1
  262. package/dist/react-core/index.js +8 -4
  263. package/dist/react-core/index.js.map +1 -1
  264. package/dist/react-core/provider.d.ts +6 -6
  265. package/dist/react-core/provider.d.ts.map +1 -1
  266. package/dist/react-core/provider.js +5 -6
  267. package/dist/react-core/provider.js.map +1 -1
  268. package/dist/react-core/session.d.ts +41 -33
  269. package/dist/react-core/session.d.ts.map +1 -1
  270. package/dist/react-core/session.js +42 -90
  271. package/dist/react-core/session.js.map +1 -1
  272. package/dist/react-native/account-session.js +1 -1
  273. package/dist/react-native/account-session.js.map +1 -1
  274. package/dist/react-native/create-account-manager.d.ts +1 -1
  275. package/dist/react-native/create-account-manager.d.ts.map +1 -1
  276. package/dist/react-native/create-jazz-session.d.ts +37 -17
  277. package/dist/react-native/create-jazz-session.d.ts.map +1 -1
  278. package/dist/react-native/create-jazz-session.js +53 -10
  279. package/dist/react-native/create-jazz-session.js.map +1 -1
  280. package/dist/react-native/index.d.ts +5 -10
  281. package/dist/react-native/index.d.ts.map +1 -1
  282. package/dist/react-native/index.js +5 -7
  283. package/dist/react-native/index.js.map +1 -1
  284. package/dist/react-native/native-foreground-db.d.ts +21 -0
  285. package/dist/react-native/native-foreground-db.d.ts.map +1 -1
  286. package/dist/react-native/native-foreground-db.js +47 -1
  287. package/dist/react-native/native-foreground-db.js.map +1 -1
  288. package/dist/react-native/provider.d.ts +14 -19
  289. package/dist/react-native/provider.d.ts.map +1 -1
  290. package/dist/react-native/provider.js +19 -18
  291. package/dist/react-native/provider.js.map +1 -1
  292. package/dist/react-native/runtime-source.d.ts +22 -0
  293. package/dist/react-native/runtime-source.d.ts.map +1 -1
  294. package/dist/react-native/runtime-source.js +68 -5
  295. package/dist/react-native/runtime-source.js.map +1 -1
  296. package/dist/removed-api.d.ts +87 -0
  297. package/dist/removed-api.d.ts.map +1 -0
  298. package/dist/removed-api.js +95 -0
  299. package/dist/removed-api.js.map +1 -0
  300. package/dist/runtime/auth-secret-store.d.ts +0 -44
  301. package/dist/runtime/auth-secret-store.d.ts.map +1 -1
  302. package/dist/runtime/auth-secret-store.js +1 -103
  303. package/dist/runtime/auth-secret-store.js.map +1 -1
  304. package/dist/runtime/authority-changed-error.d.ts +5 -3
  305. package/dist/runtime/authority-changed-error.d.ts.map +1 -1
  306. package/dist/runtime/authority-changed-error.js +5 -3
  307. package/dist/runtime/authority-changed-error.js.map +1 -1
  308. package/dist/runtime/browser-worker-assets.d.ts +19 -1
  309. package/dist/runtime/browser-worker-assets.d.ts.map +1 -1
  310. package/dist/runtime/browser-worker-assets.js +23 -1
  311. package/dist/runtime/browser-worker-assets.js.map +1 -1
  312. package/dist/runtime/browser-worker-assets.metro.d.ts +28 -0
  313. package/dist/runtime/browser-worker-assets.metro.d.ts.map +1 -0
  314. package/dist/runtime/browser-worker-assets.metro.js +52 -0
  315. package/dist/runtime/browser-worker-assets.metro.js.map +1 -0
  316. package/dist/runtime/browser-worker-assets.native.d.ts +2 -0
  317. package/dist/runtime/browser-worker-assets.native.d.ts.map +1 -1
  318. package/dist/runtime/browser-worker-assets.native.js +2 -0
  319. package/dist/runtime/browser-worker-assets.native.js.map +1 -1
  320. package/dist/runtime/browser-worker-config.d.ts +23 -0
  321. package/dist/runtime/browser-worker-config.d.ts.map +1 -1
  322. package/dist/runtime/browser-worker-config.js +72 -4
  323. package/dist/runtime/browser-worker-config.js.map +1 -1
  324. package/dist/runtime/client-migrations.d.ts +6 -4
  325. package/dist/runtime/client-migrations.d.ts.map +1 -1
  326. package/dist/runtime/client-migrations.js +20 -2
  327. package/dist/runtime/client-migrations.js.map +1 -1
  328. package/dist/runtime/client.d.ts +46 -6
  329. package/dist/runtime/client.d.ts.map +1 -1
  330. package/dist/runtime/client.js +65 -13
  331. package/dist/runtime/client.js.map +1 -1
  332. package/dist/runtime/connection-manager/browser-connection-manager.d.ts +5 -1
  333. package/dist/runtime/connection-manager/browser-connection-manager.d.ts.map +1 -1
  334. package/dist/runtime/connection-manager/browser-connection-manager.js +38 -2
  335. package/dist/runtime/connection-manager/browser-connection-manager.js.map +1 -1
  336. package/dist/runtime/connection-manager/direct-connection-manager.d.ts +3 -1
  337. package/dist/runtime/connection-manager/direct-connection-manager.d.ts.map +1 -1
  338. package/dist/runtime/connection-manager/direct-connection-manager.js +7 -3
  339. package/dist/runtime/connection-manager/direct-connection-manager.js.map +1 -1
  340. package/dist/runtime/connection-manager/types.d.ts +23 -2
  341. package/dist/runtime/connection-manager/types.d.ts.map +1 -1
  342. package/dist/runtime/connection-manager/types.js +49 -6
  343. package/dist/runtime/connection-manager/types.js.map +1 -1
  344. package/dist/runtime/context.d.ts +5 -1
  345. package/dist/runtime/context.d.ts.map +1 -1
  346. package/dist/runtime/context.js.map +1 -1
  347. package/dist/runtime/core-tick-failed-error.d.ts +31 -0
  348. package/dist/runtime/core-tick-failed-error.d.ts.map +1 -0
  349. package/dist/runtime/core-tick-failed-error.js +45 -0
  350. package/dist/runtime/core-tick-failed-error.js.map +1 -0
  351. package/dist/runtime/credentialed-transport.d.ts +18 -3
  352. package/dist/runtime/credentialed-transport.d.ts.map +1 -1
  353. package/dist/runtime/credentialed-transport.js +34 -11
  354. package/dist/runtime/credentialed-transport.js.map +1 -1
  355. package/dist/runtime/db-replaced-error.d.ts +3 -1
  356. package/dist/runtime/db-replaced-error.d.ts.map +1 -1
  357. package/dist/runtime/db-replaced-error.js +4 -2
  358. package/dist/runtime/db-replaced-error.js.map +1 -1
  359. package/dist/runtime/db.d.ts +40 -8
  360. package/dist/runtime/db.d.ts.map +1 -1
  361. package/dist/runtime/db.js +76 -9
  362. package/dist/runtime/db.js.map +1 -1
  363. package/dist/runtime/default-runtime-source.d.ts.map +1 -1
  364. package/dist/runtime/default-runtime-source.js +6 -1
  365. package/dist/runtime/default-runtime-source.js.map +1 -1
  366. package/dist/runtime/delete-local-first-store.d.ts +12 -0
  367. package/dist/runtime/delete-local-first-store.d.ts.map +1 -0
  368. package/dist/runtime/delete-local-first-store.js +12 -0
  369. package/dist/runtime/delete-local-first-store.js.map +1 -0
  370. package/dist/runtime/index.d.ts +4 -4
  371. package/dist/runtime/index.d.ts.map +1 -1
  372. package/dist/runtime/index.js +2 -2
  373. package/dist/runtime/index.js.map +1 -1
  374. package/dist/runtime/local-first-upgrade.d.ts +9 -0
  375. package/dist/runtime/local-first-upgrade.d.ts.map +1 -1
  376. package/dist/runtime/local-first-upgrade.js.map +1 -1
  377. package/dist/runtime/metro-setup-error.d.ts +20 -0
  378. package/dist/runtime/metro-setup-error.d.ts.map +1 -0
  379. package/dist/runtime/metro-setup-error.js +22 -0
  380. package/dist/runtime/metro-setup-error.js.map +1 -0
  381. package/dist/runtime/native-artifact-fingerprint-napi.d.ts +1 -1
  382. package/dist/runtime/native-artifact-fingerprint-napi.js +1 -1
  383. package/dist/runtime/native-artifact-fingerprint-napi.js.map +1 -1
  384. package/dist/runtime/native-artifact-fingerprint-wasm.d.ts +1 -1
  385. package/dist/runtime/native-artifact-fingerprint-wasm.js +1 -1
  386. package/dist/runtime/native-artifact-fingerprint-wasm.js.map +1 -1
  387. package/dist/runtime/native-artifact-fingerprints.d.ts +2 -2
  388. package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts +4 -1
  389. package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts.map +1 -1
  390. package/dist/runtime/native-runtime/attached-browser-worker-connection.js +3 -0
  391. package/dist/runtime/native-runtime/attached-browser-worker-connection.js.map +1 -1
  392. package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts +34 -0
  393. package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts.map +1 -0
  394. package/dist/runtime/native-runtime/broker-worker-load-failure.js +61 -0
  395. package/dist/runtime/native-runtime/broker-worker-load-failure.js.map +1 -0
  396. package/dist/runtime/native-runtime/browser-follower-connection.d.ts +6 -1
  397. package/dist/runtime/native-runtime/browser-follower-connection.d.ts.map +1 -1
  398. package/dist/runtime/native-runtime/browser-follower-connection.js +9 -3
  399. package/dist/runtime/native-runtime/browser-follower-connection.js.map +1 -1
  400. package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts +12 -1
  401. package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts.map +1 -1
  402. package/dist/runtime/native-runtime/browser-shared-worker-connection.js +140 -7
  403. package/dist/runtime/native-runtime/browser-shared-worker-connection.js.map +1 -1
  404. package/dist/runtime/native-runtime/browser-worker-protocol.d.ts +29 -1
  405. package/dist/runtime/native-runtime/browser-worker-protocol.d.ts.map +1 -1
  406. package/dist/runtime/native-runtime/browser-worker-protocol.js.map +1 -1
  407. package/dist/runtime/native-runtime/http-stream-socket.d.ts +25 -7
  408. package/dist/runtime/native-runtime/http-stream-socket.d.ts.map +1 -1
  409. package/dist/runtime/native-runtime/http-stream-socket.js +148 -44
  410. package/dist/runtime/native-runtime/http-stream-socket.js.map +1 -1
  411. package/dist/runtime/native-runtime/native-error-code.d.ts +1 -1
  412. package/dist/runtime/native-runtime/native-error-code.d.ts.map +1 -1
  413. package/dist/runtime/native-runtime/native-error-code.js +1 -0
  414. package/dist/runtime/native-runtime/native-error-code.js.map +1 -1
  415. package/dist/runtime/native-runtime/native-runtime-adapter.d.ts +105 -7
  416. package/dist/runtime/native-runtime/native-runtime-adapter.d.ts.map +1 -1
  417. package/dist/runtime/native-runtime/native-runtime-adapter.js +306 -27
  418. package/dist/runtime/native-runtime/native-runtime-adapter.js.map +1 -1
  419. package/dist/runtime/native-runtime/session-renewal-wire.d.ts +48 -0
  420. package/dist/runtime/native-runtime/session-renewal-wire.d.ts.map +1 -0
  421. package/dist/runtime/native-runtime/session-renewal-wire.js +107 -0
  422. package/dist/runtime/native-runtime/session-renewal-wire.js.map +1 -0
  423. package/dist/runtime/native-runtime/stream-endpoint-memory.d.ts +22 -0
  424. package/dist/runtime/native-runtime/stream-endpoint-memory.d.ts.map +1 -0
  425. package/dist/runtime/native-runtime/stream-endpoint-memory.js +69 -0
  426. package/dist/runtime/native-runtime/stream-endpoint-memory.js.map +1 -0
  427. package/dist/runtime/native-runtime/websocket.d.ts +51 -1
  428. package/dist/runtime/native-runtime/websocket.d.ts.map +1 -1
  429. package/dist/runtime/native-runtime/websocket.js +187 -7
  430. package/dist/runtime/native-runtime/websocket.js.map +1 -1
  431. package/dist/runtime/page-handle.d.ts +83 -0
  432. package/dist/runtime/page-handle.d.ts.map +1 -0
  433. package/dist/runtime/page-handle.js +151 -0
  434. package/dist/runtime/page-handle.js.map +1 -0
  435. package/dist/runtime/removed-provider-props.d.ts +17 -0
  436. package/dist/runtime/removed-provider-props.d.ts.map +1 -0
  437. package/dist/runtime/removed-provider-props.js +16 -0
  438. package/dist/runtime/removed-provider-props.js.map +1 -0
  439. package/dist/runtime/row-transformer.d.ts.map +1 -1
  440. package/dist/runtime/row-transformer.js +20 -0
  441. package/dist/runtime/row-transformer.js.map +1 -1
  442. package/dist/runtime/runtime-config.d.ts +5 -1
  443. package/dist/runtime/runtime-config.d.ts.map +1 -1
  444. package/dist/runtime/runtime-config.js +5 -1
  445. package/dist/runtime/runtime-config.js.map +1 -1
  446. package/dist/runtime/runtime-source.d.ts +6 -1
  447. package/dist/runtime/runtime-source.d.ts.map +1 -1
  448. package/dist/runtime/runtime-source.js.map +1 -1
  449. package/dist/runtime/schema-metadata.d.ts +17 -0
  450. package/dist/runtime/schema-metadata.d.ts.map +1 -1
  451. package/dist/runtime/schema-metadata.js +28 -0
  452. package/dist/runtime/schema-metadata.js.map +1 -1
  453. package/dist/runtime/store-held-by-another-tab-error.d.ts +11 -0
  454. package/dist/runtime/store-held-by-another-tab-error.d.ts.map +1 -1
  455. package/dist/runtime/store-held-by-another-tab-error.js +11 -0
  456. package/dist/runtime/store-held-by-another-tab-error.js.map +1 -1
  457. package/dist/runtime/sync-status.d.ts +60 -1
  458. package/dist/runtime/sync-status.d.ts.map +1 -1
  459. package/dist/runtime/sync-status.js +64 -4
  460. package/dist/runtime/sync-status.js.map +1 -1
  461. package/dist/runtime/wasm-loader.d.ts.map +1 -1
  462. package/dist/runtime/wasm-loader.js +8 -1
  463. package/dist/runtime/wasm-loader.js.map +1 -1
  464. package/dist/schema-loader.d.ts +2 -0
  465. package/dist/schema-loader.d.ts.map +1 -1
  466. package/dist/schema-loader.js +7 -2
  467. package/dist/schema-loader.js.map +1 -1
  468. package/dist/schema-permissions.d.ts.map +1 -1
  469. package/dist/schema-permissions.js +19 -0
  470. package/dist/schema-permissions.js.map +1 -1
  471. package/dist/schema-source.d.ts.map +1 -1
  472. package/dist/schema-source.js +14 -0
  473. package/dist/schema-source.js.map +1 -1
  474. package/dist/session/backend-watch.d.ts +56 -15
  475. package/dist/session/backend-watch.d.ts.map +1 -1
  476. package/dist/session/backend-watch.js +127 -31
  477. package/dist/session/backend-watch.js.map +1 -1
  478. package/dist/session/config-options.d.ts +15 -0
  479. package/dist/session/config-options.d.ts.map +1 -0
  480. package/dist/session/config-options.js +55 -0
  481. package/dist/session/config-options.js.map +1 -0
  482. package/dist/session/consumer.d.ts +1 -1
  483. package/dist/session/consumer.js +1 -1
  484. package/dist/session/consumer.js.map +1 -1
  485. package/dist/session/create-jazz-session.d.ts +55 -21
  486. package/dist/session/create-jazz-session.d.ts.map +1 -1
  487. package/dist/session/create-jazz-session.js +215 -166
  488. package/dist/session/create-jazz-session.js.map +1 -1
  489. package/dist/session/follow-user.d.ts +30 -11
  490. package/dist/session/follow-user.d.ts.map +1 -1
  491. package/dist/session/follow-user.js +49 -9
  492. package/dist/session/follow-user.js.map +1 -1
  493. package/dist/session/jazz-session.d.ts +182 -0
  494. package/dist/session/jazz-session.d.ts.map +1 -0
  495. package/dist/session/jazz-session.js +459 -0
  496. package/dist/session/jazz-session.js.map +1 -0
  497. package/dist/session/no-kept-device-account-error.d.ts +6 -0
  498. package/dist/session/no-kept-device-account-error.d.ts.map +1 -0
  499. package/dist/session/no-kept-device-account-error.js +8 -0
  500. package/dist/session/no-kept-device-account-error.js.map +1 -0
  501. package/dist/session/replica-ledger.d.ts +164 -0
  502. package/dist/session/replica-ledger.d.ts.map +1 -0
  503. package/dist/session/replica-ledger.js +450 -0
  504. package/dist/session/replica-ledger.js.map +1 -0
  505. package/dist/session/state.d.ts +50 -13
  506. package/dist/session/state.d.ts.map +1 -1
  507. package/dist/session/state.js +158 -29
  508. package/dist/session/state.js.map +1 -1
  509. package/dist/solid/index.d.ts +3 -9
  510. package/dist/solid/index.d.ts.map +1 -1
  511. package/dist/solid/index.js +8 -11
  512. package/dist/solid/index.ssr.js +3 -6
  513. package/dist/solid/provider.d.ts +3 -3
  514. package/dist/solid/provider.d.ts.map +1 -1
  515. package/dist/solid/provider.js +23 -39
  516. package/dist/solid/provider.js.map +1 -1
  517. package/dist/solid/provider.ssr.js +6 -23
  518. package/dist/solid/provider.ssr.js.map +1 -1
  519. package/dist/solid/session.d.ts +42 -12
  520. package/dist/solid/session.d.ts.map +1 -1
  521. package/dist/solid/session.js +82 -35
  522. package/dist/solid/session.js.map +1 -1
  523. package/dist/solid/session.ssr.js +86 -23
  524. package/dist/solid/session.ssr.js.map +1 -1
  525. package/dist/svelte/JazzProvider.svelte +54 -20
  526. package/dist/svelte/JazzProvider.svelte.d.ts +14 -4
  527. package/dist/svelte/JazzProvider.svelte.d.ts.map +1 -1
  528. package/dist/svelte/JazzSvelteClientProvider.svelte +1 -7
  529. package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts +0 -1
  530. package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts.map +1 -1
  531. package/dist/svelte/JazzSvelteProvider.svelte +5 -4
  532. package/dist/svelte/JazzSvelteProvider.svelte.d.ts +2 -2
  533. package/dist/svelte/JazzSvelteProvider.svelte.d.ts.map +1 -1
  534. package/dist/svelte/index.d.ts +4 -12
  535. package/dist/svelte/index.d.ts.map +1 -1
  536. package/dist/svelte/index.js +4 -8
  537. package/dist/svelte/session-state.d.ts +14 -4
  538. package/dist/svelte/session-state.d.ts.map +1 -1
  539. package/dist/svelte/session-state.js +10 -4
  540. package/dist/testing/client-migrations.d.ts +8 -1
  541. package/dist/testing/client-migrations.d.ts.map +1 -1
  542. package/dist/testing/client-migrations.js +11 -0
  543. package/dist/testing/client-migrations.js.map +1 -1
  544. package/dist/testing/policy-test-app.d.ts.map +1 -1
  545. package/dist/testing/policy-test-app.js +5 -4
  546. package/dist/testing/policy-test-app.js.map +1 -1
  547. package/dist/testing/test-jazz.d.ts +2 -2
  548. package/dist/testing/test-jazz.d.ts.map +1 -1
  549. package/dist/testing/test-jazz.js +6 -3
  550. package/dist/testing/test-jazz.js.map +1 -1
  551. package/dist/thin/index.d.ts +7 -10
  552. package/dist/thin/index.d.ts.map +1 -1
  553. package/dist/thin/index.js +28 -11
  554. package/dist/thin/index.js.map +1 -1
  555. package/dist/thin/thin-runtime.d.ts +53 -3
  556. package/dist/thin/thin-runtime.d.ts.map +1 -1
  557. package/dist/thin/thin-runtime.js +256 -33
  558. package/dist/thin/thin-runtime.js.map +1 -1
  559. package/dist/typed-app.d.ts +10 -4
  560. package/dist/typed-app.d.ts.map +1 -1
  561. package/dist/typed-app.js +44 -18
  562. package/dist/typed-app.js.map +1 -1
  563. package/dist/vue/index.d.ts +3 -8
  564. package/dist/vue/index.d.ts.map +1 -1
  565. package/dist/vue/index.js +3 -5
  566. package/dist/vue/index.js.map +1 -1
  567. package/dist/vue/provider.d.ts +6 -27
  568. package/dist/vue/provider.d.ts.map +1 -1
  569. package/dist/vue/provider.js +10 -19
  570. package/dist/vue/provider.js.map +1 -1
  571. package/dist/vue/session.d.ts +29 -28
  572. package/dist/vue/session.d.ts.map +1 -1
  573. package/dist/vue/session.js +80 -23
  574. package/dist/vue/session.js.map +1 -1
  575. package/dist/web/create-jazz-client.d.ts +5 -1
  576. package/dist/web/create-jazz-client.d.ts.map +1 -1
  577. package/dist/web/create-jazz-client.js +30 -3
  578. package/dist/web/create-jazz-client.js.map +1 -1
  579. package/dist/window-client-storage.d.ts +4 -30
  580. package/dist/window-client-storage.d.ts.map +1 -1
  581. package/dist/window-client-storage.js +2 -63
  582. package/dist/window-client-storage.js.map +1 -1
  583. package/dist/worker/jazz-broker-worker-core.d.ts.map +1 -1
  584. package/dist/worker/jazz-broker-worker-core.js +118 -20
  585. package/dist/worker/jazz-broker-worker-core.js.map +1 -1
  586. package/dist/worker/jazz-broker-worker.js +787 -608
  587. package/dist/worker/jazz_wasm_bg.wasm +0 -0
  588. package/dist/worker/runtime-admission.d.ts +19 -0
  589. package/dist/worker/runtime-admission.d.ts.map +1 -0
  590. package/dist/worker/runtime-admission.js +34 -0
  591. package/dist/worker/runtime-admission.js.map +1 -0
  592. package/dist/worker/vite-dev-broker.d.ts +2 -0
  593. package/dist/worker/vite-dev-broker.d.ts.map +1 -0
  594. package/dist/worker/vite-dev-broker.js +8 -0
  595. package/dist/worker/vite-dev-broker.js.map +1 -0
  596. package/package.json +30 -10
  597. package/dist/backend/session-recheck.d.ts +0 -18
  598. package/dist/backend/session-recheck.d.ts.map +0 -1
  599. package/dist/backend/session-recheck.js +0 -57
  600. package/dist/backend/session-recheck.js.map +0 -1
  601. package/dist/dev/inspector-overlay/embedded/assets/esm-k3rsq4Gn.js +0 -1
  602. package/dist/dev/inspector-overlay/embedded/assets/index-C-btvLcw.js +0 -20
  603. package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-CAMcDeUa.js +0 -3
  604. package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-Cc71x_6y.js +0 -1
  605. package/dist/dev/inspector-overlay/serve.d.ts +0 -46
  606. package/dist/dev/inspector-overlay/serve.d.ts.map +0 -1
  607. package/dist/dev/inspector-overlay/serve.js +0 -131
  608. package/dist/dev/inspector-overlay/serve.js.map +0 -1
  609. package/dist/dev-tools/auto-attach.d.ts +0 -11
  610. package/dist/dev-tools/auto-attach.d.ts.map +0 -1
  611. package/dist/dev-tools/auto-attach.js +0 -26
  612. package/dist/dev-tools/auto-attach.js.map +0 -1
  613. package/dist/expo/auth-secret-store.d.ts +0 -37
  614. package/dist/expo/auth-secret-store.d.ts.map +0 -1
  615. package/dist/expo/auth-secret-store.js +0 -139
  616. package/dist/expo/auth-secret-store.js.map +0 -1
  617. package/dist/expo/session.d.ts +0 -10
  618. package/dist/expo/session.d.ts.map +0 -1
  619. package/dist/expo/session.js +0 -5
  620. package/dist/expo/session.js.map +0 -1
  621. package/dist/expo/use-local-first-auth.d.ts +0 -12
  622. package/dist/expo/use-local-first-auth.d.ts.map +0 -1
  623. package/dist/expo/use-local-first-auth.js +0 -13
  624. package/dist/expo/use-local-first-auth.js.map +0 -1
  625. package/dist/react/devtools-auto-attach.d.ts +0 -2
  626. package/dist/react/devtools-auto-attach.d.ts.map +0 -1
  627. package/dist/react/devtools-auto-attach.js +0 -11
  628. package/dist/react/devtools-auto-attach.js.map +0 -1
  629. package/dist/react/session.d.ts +0 -18
  630. package/dist/react/session.d.ts.map +0 -1
  631. package/dist/react/session.js +0 -28
  632. package/dist/react/session.js.map +0 -1
  633. package/dist/react/use-local-first-auth.d.ts +0 -11
  634. package/dist/react/use-local-first-auth.d.ts.map +0 -1
  635. package/dist/react/use-local-first-auth.js +0 -13
  636. package/dist/react/use-local-first-auth.js.map +0 -1
  637. package/dist/react-core/app.d.ts +0 -31
  638. package/dist/react-core/app.d.ts.map +0 -1
  639. package/dist/react-core/app.js +0 -65
  640. package/dist/react-core/app.js.map +0 -1
  641. package/dist/react-core/use-account-state.d.ts +0 -4
  642. package/dist/react-core/use-account-state.d.ts.map +0 -1
  643. package/dist/react-core/use-account-state.js +0 -6
  644. package/dist/react-core/use-account-state.js.map +0 -1
  645. package/dist/react-core/use-local-first-auth.d.ts +0 -12
  646. package/dist/react-core/use-local-first-auth.d.ts.map +0 -1
  647. package/dist/react-core/use-local-first-auth.js +0 -14
  648. package/dist/react-core/use-local-first-auth.js.map +0 -1
  649. package/dist/react-native/session.d.ts +0 -10
  650. package/dist/react-native/session.d.ts.map +0 -1
  651. package/dist/react-native/session.js +0 -5
  652. package/dist/react-native/session.js.map +0 -1
  653. package/dist/react-native/use-local-first-auth.d.ts +0 -15
  654. package/dist/react-native/use-local-first-auth.d.ts.map +0 -1
  655. package/dist/react-native/use-local-first-auth.js +0 -14
  656. package/dist/react-native/use-local-first-auth.js.map +0 -1
  657. package/dist/runtime/local-first-auth-controller.d.ts +0 -29
  658. package/dist/runtime/local-first-auth-controller.d.ts.map +0 -1
  659. package/dist/runtime/local-first-auth-controller.js +0 -101
  660. package/dist/runtime/local-first-auth-controller.js.map +0 -1
  661. package/dist/session/app.d.ts +0 -58
  662. package/dist/session/app.d.ts.map +0 -1
  663. package/dist/session/app.js +0 -325
  664. package/dist/session/app.js.map +0 -1
  665. package/dist/session/create-jazz-app.d.ts +0 -11
  666. package/dist/session/create-jazz-app.d.ts.map +0 -1
  667. package/dist/session/create-jazz-app.js +0 -11
  668. package/dist/session/create-jazz-app.js.map +0 -1
  669. package/dist/session/left-behind-replicas.d.ts +0 -62
  670. package/dist/session/left-behind-replicas.d.ts.map +0 -1
  671. package/dist/session/left-behind-replicas.js +0 -146
  672. package/dist/session/left-behind-replicas.js.map +0 -1
  673. package/dist/solid/app.d.ts +0 -30
  674. package/dist/solid/app.d.ts.map +0 -1
  675. package/dist/solid/app.js +0 -95
  676. package/dist/solid/app.js.map +0 -1
  677. package/dist/solid/app.ssr.js +0 -109
  678. package/dist/solid/app.ssr.js.map +0 -1
  679. package/dist/solid/create-account-state.d.ts +0 -4
  680. package/dist/solid/create-account-state.d.ts.map +0 -1
  681. package/dist/solid/create-account-state.js +0 -10
  682. package/dist/solid/create-account-state.js.map +0 -1
  683. package/dist/solid/create-account-state.ssr.js +0 -12
  684. package/dist/solid/create-account-state.ssr.js.map +0 -1
  685. package/dist/solid/use-local-first-auth.d.ts +0 -11
  686. package/dist/solid/use-local-first-auth.d.ts.map +0 -1
  687. package/dist/solid/use-local-first-auth.js +0 -30
  688. package/dist/solid/use-local-first-auth.js.map +0 -1
  689. package/dist/solid/use-local-first-auth.ssr.js +0 -31
  690. package/dist/solid/use-local-first-auth.ssr.js.map +0 -1
  691. package/dist/svelte/JazzSessionClientProvider.svelte +0 -42
  692. package/dist/svelte/JazzSessionClientProvider.svelte.d.ts +0 -13
  693. package/dist/svelte/JazzSessionClientProvider.svelte.d.ts.map +0 -1
  694. package/dist/svelte/JazzSessionProvider.svelte +0 -68
  695. package/dist/svelte/JazzSessionProvider.svelte.d.ts +0 -19
  696. package/dist/svelte/JazzSessionProvider.svelte.d.ts.map +0 -1
  697. package/dist/svelte/account-state.d.ts +0 -5
  698. package/dist/svelte/account-state.d.ts.map +0 -1
  699. package/dist/svelte/account-state.js +0 -9
  700. package/dist/svelte/auth-state.d.ts +0 -23
  701. package/dist/svelte/auth-state.d.ts.map +0 -1
  702. package/dist/svelte/auth-state.js +0 -16
  703. package/dist/svelte/local-first-auth.svelte.d.ts +0 -50
  704. package/dist/svelte/local-first-auth.svelte.d.ts.map +0 -1
  705. package/dist/svelte/local-first-auth.svelte.js +0 -58
  706. package/dist/vue/app.d.ts +0 -76
  707. package/dist/vue/app.d.ts.map +0 -1
  708. package/dist/vue/app.js +0 -100
  709. package/dist/vue/app.js.map +0 -1
  710. package/dist/vue/use-account-state.d.ts +0 -5
  711. package/dist/vue/use-account-state.d.ts.map +0 -1
  712. package/dist/vue/use-account-state.js +0 -10
  713. package/dist/vue/use-account-state.js.map +0 -1
  714. package/dist/vue/use-local-first-auth.d.ts +0 -53
  715. package/dist/vue/use-local-first-auth.d.ts.map +0 -1
  716. package/dist/vue/use-local-first-auth.js +0 -67
  717. package/dist/vue/use-local-first-auth.js.map +0 -1
  718. /package/dist/dev/inspector-overlay/embedded/assets/{esm-CH5eVyQQ.js → esm-xNe3wI_B.js} +0 -0
  719. /package/dist/dev/inspector-overlay/embedded/assets/{node-foreground-node-lease.browser-Bm3gYjlT.js → node-foreground-node-lease.browser-CH8w-D6S.js} +0 -0
@@ -0,0 +1,164 @@
1
+ /**
2
+ * The lifecycle of this browser's per-account local-first stores under
3
+ * `clearOnSignOut` (#5250): which accounts' data may be on the device, who
4
+ * holds it open, and who may wipe it. Everything about wiping in the
5
+ * browser lives here; the session only calls `hold`, `signedOut` and
6
+ * `reconcile`.
7
+ *
8
+ * A store is in one of four states, derived from two facts and nothing
9
+ * else: the **ledger** (localStorage, below), and the per-account **Web
10
+ * Lock** every tab with the store open holds shared (the browser releases
11
+ * it when a tab closes, crashes or is discarded).
12
+ *
13
+ * - **Absent**: no ledger entry; nothing of the account is on the device.
14
+ * - **Held(n)**: n ≥ 1 tabs hold the lock. Nothing wipes it.
15
+ * - **Orphaned**: an entry, no tab holds the lock, no wipe began. A tab
16
+ * closed while signed in, or a sign-out happened where no page saw it.
17
+ * It is wiped only with proof that no one can open it again: a backend
18
+ * user the backend no longer names (twice), or a device account whose
19
+ * key the device no longer keeps.
20
+ * - **Wiping**: the entry is marked `wiping` (written before the delete
21
+ * starts). A crash mid-delete leaves it so; it is finished before the
22
+ * account opens again, without further proof: the data is already partly
23
+ * gone.
24
+ *
25
+ * One owner per transition:
26
+ * - opening (`hold`): the opening tab records the entry, then takes the
27
+ * lock, then records it again (a wipe may have forgotten it meanwhile);
28
+ * - the last tab out signing out (`signedOut`): that tab wipes at once, with
29
+ * no further proof. A tab that signs out while another holds the store
30
+ * does nothing: the last holder decides, by signing out too, or by
31
+ * closing, which leaves the store Orphaned;
32
+ * - Orphaned and Wiping stores (`reconcile`): any page, on load and on the
33
+ * triggers the session wires up. There is no polling.
34
+ *
35
+ * `wipeOne` is the only code that deletes, always under the exclusive lock
36
+ * and only while no tab holds the store.
37
+ */
38
+ /** What the ledger keeps of an account: enough to find its store, no claims, never a credential. */
39
+ export type ReplicaEntry = {
40
+ account: string;
41
+ /** A user the backend signed in, or a device account (a guest). */
42
+ kind: "backend" | "device";
43
+ identity: {
44
+ issuer: string;
45
+ subject: string;
46
+ };
47
+ /** Set before a delete begins and kept until it finished. */
48
+ wiping?: true;
49
+ };
50
+ /**
51
+ * The durable list of accounts whose store may be on this device: one
52
+ * localStorage key per account. An entry is written before its store opens
53
+ * and dropped only once it is wiped.
54
+ */
55
+ export declare function replicaLedger(registry: string): {
56
+ /** The keys this ledger's entries live under start with it (for `storage` events). */
57
+ prefix: string;
58
+ legacyKey: string;
59
+ /** Whether entries persist here: without storage (disabled, or not a browser) nothing is recorded. */
60
+ durable(): boolean;
61
+ read(): ReplicaEntry[];
62
+ get: (account: string) => ReplicaEntry | undefined;
63
+ /** `entry`'s account is about to keep a store here. A wipe already marked stays marked. */
64
+ record(entry: Omit<ReplicaEntry, "wiping">): void;
65
+ markWiping(account: string, wiping: boolean): void;
66
+ forget(account: string): void;
67
+ };
68
+ export type ReplicaLedger = ReturnType<typeof replicaLedger>;
69
+ export type Locks = {
70
+ query?(): Promise<{
71
+ held?: {
72
+ name?: string;
73
+ mode?: string;
74
+ }[];
75
+ pending?: {
76
+ name?: string;
77
+ mode?: string;
78
+ }[];
79
+ }>;
80
+ request(name: string, options: {
81
+ mode: "shared" | "exclusive";
82
+ ifAvailable?: boolean;
83
+ }, callback: (lock: unknown) => Promise<unknown>): Promise<unknown>;
84
+ };
85
+ /**
86
+ * Hold `account`'s store open in this tab until the returned release is
87
+ * called, so no tab wipes it meanwhile. Every browser tab with a
88
+ * local-first client holds it, with `clearOnSignOut` or without: a store
89
+ * delete (`delete-store`) relies on it to know no tab is joining. Without Web Locks there is nothing to
90
+ * hold, and none is needed: persistent browser storage requires them.
91
+ */
92
+ /**
93
+ * Hold `account`'s store open, as a page without `clearOnSignOut` (or a
94
+ * client opened directly) does: nothing is recorded, but a wipe a crash left
95
+ * unfinished is finished first (through `deleteStore`), so the store is
96
+ * never opened half-deleted.
97
+ */
98
+ export declare function holdReplicaStore(registry: string, account: string, deleteStore: () => Promise<"deleted" | "held">): Promise<() => Promise<void>>;
99
+ /** As the backend watch confirms a signed-out answer before it signs anyone out. */
100
+ export declare const CONFIRM_SIGNED_OUT_MS = 2000;
101
+ export type WipeOutcome = "wiped" | "held" | "skipped";
102
+ export declare function replicaLifecycle(options: {
103
+ registry: string;
104
+ ledger: ReplicaLedger;
105
+ /** Whether this page has `account` open, or is opening it. */
106
+ heldHere(account: string): boolean;
107
+ /** Whether this page has closed its session: it reconciles nothing then. */
108
+ stopped?(): boolean;
109
+ /**
110
+ * Delete `account`'s store. `"held"` without deleting anything while a tab
111
+ * (of any build) still has it open.
112
+ */
113
+ deleteStore(account: string): Promise<"deleted" | "held">;
114
+ /** Who the backend signs in now. Throws when it can't be asked. */
115
+ backendUser(): Promise<{
116
+ issuer: string;
117
+ subject: string;
118
+ } | null>;
119
+ /** Whether this device's account store still keeps device account `account`'s key. */
120
+ deviceKeyKept(account: string): Promise<boolean>;
121
+ confirmMs?: number;
122
+ /** The browser's Web Locks, by default. */
123
+ locks?: Locks;
124
+ }): {
125
+ ledger: {
126
+ /** The keys this ledger's entries live under start with it (for `storage` events). */
127
+ prefix: string;
128
+ legacyKey: string;
129
+ /** Whether entries persist here: without storage (disabled, or not a browser) nothing is recorded. */
130
+ durable(): boolean;
131
+ read(): ReplicaEntry[];
132
+ get: (account: string) => ReplicaEntry | undefined;
133
+ /** `entry`'s account is about to keep a store here. A wipe already marked stays marked. */
134
+ record(entry: Omit<ReplicaEntry, "wiping">): void;
135
+ markWiping(account: string, wiping: boolean): void;
136
+ forget(account: string): void;
137
+ };
138
+ /**
139
+ * Record `entry` and hold its store open in this tab, until the returned
140
+ * release is called. A wipe a crash left unfinished is finished first:
141
+ * a store is never opened half-deleted.
142
+ */
143
+ hold(entry: Omit<ReplicaEntry, "wiping"> | {
144
+ account: string;
145
+ }): Promise<() => Promise<void>>;
146
+ /** Whether a tab holds `account`'s store open (a look, taking no lock). */
147
+ heldByATab(account: string): Promise<boolean>;
148
+ /**
149
+ * This tab signed `account` out and closed its client (letting go of its
150
+ * hold). As the last tab out it wipes now; while another tab holds the
151
+ * store it does nothing, and that tab decides. `pendingUploads` is what
152
+ * the store held unconfirmed, for the warning.
153
+ */
154
+ signedOut(account: string, pendingUploads: number): Promise<WipeOutcome>;
155
+ /**
156
+ * Wipe every Orphaned store no one can open again (a backend user the
157
+ * backend no longer names, twice; a device account whose key the device
158
+ * no longer keeps) and finish every Wiping one. Single-flight: a
159
+ * call while one runs runs once more after it.
160
+ */
161
+ reconcile(): Promise<void>;
162
+ };
163
+ export type ReplicaLifecycle = ReturnType<typeof replicaLifecycle>;
164
+ //# sourceMappingURL=replica-ledger.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"replica-ledger.d.ts","sourceRoot":"","sources":["../../src/session/replica-ledger.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAEH,oGAAoG;AACpG,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,mEAAmE;IACnE,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,QAAQ,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;IAC9C,6DAA6D;IAC7D,MAAM,CAAC,EAAE,IAAI,CAAC;CACf,CAAC;AAOF;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM;IA0C1C,sFAAsF;;;IAGtF,sGAAsG;eAC3F,OAAO;YAOV,YAAY,EAAE;mBAbF,MAAM;IA4B1B,2FAA2F;kBAC7E,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC;wBAWtB,MAAM,UAAU,OAAO;oBAM3B,MAAM;EAazB;AAED,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;AAoB7D,MAAM,MAAM,KAAK,GAAG;IAClB,KAAK,CAAC,IAAI,OAAO,CAAC;QAChB,IAAI,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;QAC1C,OAAO,CAAC,EAAE;YAAE,IAAI,CAAC,EAAE,MAAM,CAAC;YAAC,IAAI,CAAC,EAAE,MAAM,CAAA;SAAE,EAAE,CAAC;KAC9C,CAAC,CAAC;IACH,OAAO,CACL,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,CAAC;QAAC,WAAW,CAAC,EAAE,OAAO,CAAA;KAAE,EAChE,QAAQ,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,OAAO,CAAC,OAAO,CAAC,GAC5C,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB,CAAC;AAMF;;;;;;GAMG;AACH;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,EACf,WAAW,EAAE,MAAM,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,GAC7C,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAW9B;AA0ED,oFAAoF;AACpF,eAAO,MAAM,qBAAqB,OAAQ,CAAC;AAS3C,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;AAEvD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE;IACxC,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,aAAa,CAAC;IACtB,8DAA8D;IAC9D,QAAQ,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC;IACnC,4EAA4E;IAC5E,OAAO,CAAC,IAAI,OAAO,CAAC;IACpB;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,MAAM,CAAC,CAAC;IAC1D,mEAAmE;IACnE,WAAW,IAAI,OAAO,CAAC;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC,CAAC;IACnE,sFAAsF;IACtF,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IACjD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,KAAK,CAAC,EAAE,KAAK,CAAC;CACf;;QApOG,sFAAsF;;;QAGtF,sGAAsG;mBAC3F,OAAO;gBAOV,YAAY,EAAE;uBAbF,MAAM;QA4B1B,2FAA2F;sBAC7E,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC;4BAWtB,MAAM,UAAU,OAAO;wBAM3B,MAAM;;IA2StB;;;;OAIG;gBAEM,IAAI,CAAC,YAAY,EAAE,QAAQ,CAAC,GAAG;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GACxD,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IA6B/B,2EAA2E;wBACvD,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAG7C;;;;;OAKG;uBACsB,MAAM,kBAAkB,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAe9E;;;;;OAKG;iBACU,OAAO,CAAC,IAAI,CAAC;EAkB7B;AAED,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,450 @@
1
+ /**
2
+ * The lifecycle of this browser's per-account local-first stores under
3
+ * `clearOnSignOut` (#5250): which accounts' data may be on the device, who
4
+ * holds it open, and who may wipe it. Everything about wiping in the
5
+ * browser lives here; the session only calls `hold`, `signedOut` and
6
+ * `reconcile`.
7
+ *
8
+ * A store is in one of four states, derived from two facts and nothing
9
+ * else: the **ledger** (localStorage, below), and the per-account **Web
10
+ * Lock** every tab with the store open holds shared (the browser releases
11
+ * it when a tab closes, crashes or is discarded).
12
+ *
13
+ * - **Absent**: no ledger entry; nothing of the account is on the device.
14
+ * - **Held(n)**: n ≥ 1 tabs hold the lock. Nothing wipes it.
15
+ * - **Orphaned**: an entry, no tab holds the lock, no wipe began. A tab
16
+ * closed while signed in, or a sign-out happened where no page saw it.
17
+ * It is wiped only with proof that no one can open it again: a backend
18
+ * user the backend no longer names (twice), or a device account whose
19
+ * key the device no longer keeps.
20
+ * - **Wiping**: the entry is marked `wiping` (written before the delete
21
+ * starts). A crash mid-delete leaves it so; it is finished before the
22
+ * account opens again, without further proof: the data is already partly
23
+ * gone.
24
+ *
25
+ * One owner per transition:
26
+ * - opening (`hold`): the opening tab records the entry, then takes the
27
+ * lock, then records it again (a wipe may have forgotten it meanwhile);
28
+ * - the last tab out signing out (`signedOut`): that tab wipes at once, with
29
+ * no further proof. A tab that signs out while another holds the store
30
+ * does nothing: the last holder decides, by signing out too, or by
31
+ * closing, which leaves the store Orphaned;
32
+ * - Orphaned and Wiping stores (`reconcile`): any page, on load and on the
33
+ * triggers the session wires up. There is no polling.
34
+ *
35
+ * `wipeOne` is the only code that deletes, always under the exclusive lock
36
+ * and only while no tab holds the store.
37
+ */
38
+ /** Each account's entry is its own key, so tabs writing at once never overwrite each other's. */
39
+ const ledgerPrefix = (registry) => `jazz-replica-v2:${encodeURIComponent(registry)}:`;
40
+ /** alpha.61's record of backend users only; read alongside, until the next breaking alpha. */
41
+ const legacyKey = (registry) => `jazz-clear-on-sign-out-v1:${encodeURIComponent(registry)}`;
42
+ /**
43
+ * The durable list of accounts whose store may be on this device: one
44
+ * localStorage key per account. An entry is written before its store opens
45
+ * and dropped only once it is wiped.
46
+ */
47
+ export function replicaLedger(registry) {
48
+ const prefix = ledgerPrefix(registry);
49
+ const legacy = legacyKey(registry);
50
+ const storage = () => {
51
+ try {
52
+ return globalThis.localStorage;
53
+ }
54
+ catch {
55
+ return undefined;
56
+ }
57
+ };
58
+ const parseEntry = (account) => {
59
+ try {
60
+ const value = JSON.parse(storage()?.getItem(prefix + account) ?? "null");
61
+ return isEntry(value) && value.account === account ? value : undefined;
62
+ }
63
+ catch {
64
+ return undefined;
65
+ }
66
+ };
67
+ const legacyOwners = () => {
68
+ try {
69
+ const value = JSON.parse(storage()?.getItem(legacy) ?? "[]");
70
+ return Array.isArray(value) ? value : [];
71
+ }
72
+ catch {
73
+ return [];
74
+ }
75
+ };
76
+ const legacyEntry = (account) => {
77
+ const owner = legacyOwners().find((candidate) => isIdentified(candidate) && candidate.account === account);
78
+ return owner && { account, kind: "backend", identity: owner.identity };
79
+ };
80
+ const put = (entry) => {
81
+ try {
82
+ storage()?.setItem(prefix + entry.account, JSON.stringify(entry));
83
+ }
84
+ catch {
85
+ // Without storage there is no later page to wipe on either.
86
+ }
87
+ };
88
+ const get = (account) => parseEntry(account) ?? legacyEntry(account);
89
+ return {
90
+ /** The keys this ledger's entries live under start with it (for `storage` events). */
91
+ prefix,
92
+ legacyKey: legacy,
93
+ /** Whether entries persist here: without storage (disabled, or not a browser) nothing is recorded. */
94
+ durable() {
95
+ try {
96
+ return typeof storage()?.getItem === "function";
97
+ }
98
+ catch {
99
+ return false;
100
+ }
101
+ },
102
+ read() {
103
+ const accounts = new Set();
104
+ const store = storage();
105
+ try {
106
+ for (let i = 0; i < (store?.length ?? 0); i++) {
107
+ const key = store.key(i);
108
+ if (key?.startsWith(prefix))
109
+ accounts.add(key.slice(prefix.length));
110
+ }
111
+ }
112
+ catch {
113
+ // Unreadable storage records nothing.
114
+ }
115
+ for (const owner of legacyOwners())
116
+ if (isIdentified(owner))
117
+ accounts.add(owner.account);
118
+ return [...accounts].map(get).filter((entry) => entry !== undefined);
119
+ },
120
+ get,
121
+ /** `entry`'s account is about to keep a store here. A wipe already marked stays marked. */
122
+ record(entry) {
123
+ const { account, kind, identity } = entry;
124
+ const recorded = get(account);
125
+ const next = {
126
+ account,
127
+ kind,
128
+ identity: { issuer: identity.issuer, subject: identity.subject },
129
+ ...(recorded?.wiping ? { wiping: true } : {}),
130
+ };
131
+ if (JSON.stringify(parseEntry(account)) !== JSON.stringify(next))
132
+ put(next);
133
+ },
134
+ markWiping(account, wiping) {
135
+ const recorded = get(account);
136
+ if (!recorded)
137
+ return;
138
+ const { wiping: _wiping, ...entry } = recorded;
139
+ put(wiping ? { ...entry, wiping } : entry);
140
+ },
141
+ forget(account) {
142
+ try {
143
+ storage()?.removeItem(prefix + account);
144
+ const owners = legacyOwners();
145
+ const kept = owners.filter((owner) => !(isIdentified(owner) && owner.account === account));
146
+ if (kept.length === owners.length)
147
+ return;
148
+ if (kept.length === 0)
149
+ storage()?.removeItem(legacy);
150
+ else
151
+ storage()?.setItem(legacy, JSON.stringify(kept));
152
+ }
153
+ catch {
154
+ // Nothing recorded, nothing to forget.
155
+ }
156
+ },
157
+ };
158
+ }
159
+ function isIdentified(value) {
160
+ const entry = value;
161
+ return (typeof entry?.account === "string" &&
162
+ typeof entry.identity?.issuer === "string" &&
163
+ typeof entry.identity.subject === "string");
164
+ }
165
+ function isEntry(value) {
166
+ const entry = value;
167
+ return (isIdentified(value) &&
168
+ (entry.kind === "backend" || entry.kind === "device") &&
169
+ (entry.wiping === undefined || entry.wiping === true));
170
+ }
171
+ const webLocks = () => globalThis.navigator?.locks;
172
+ /** Unchanged since alpha.61, so tabs of either build see each other's holds. */
173
+ const lockName = (registry, account) => `jazz-replica-v1:${registry}:${account}`;
174
+ /**
175
+ * Hold `account`'s store open in this tab until the returned release is
176
+ * called, so no tab wipes it meanwhile. Every browser tab with a
177
+ * local-first client holds it, with `clearOnSignOut` or without: a store
178
+ * delete (`delete-store`) relies on it to know no tab is joining. Without Web Locks there is nothing to
179
+ * hold, and none is needed: persistent browser storage requires them.
180
+ */
181
+ /**
182
+ * Hold `account`'s store open, as a page without `clearOnSignOut` (or a
183
+ * client opened directly) does: nothing is recorded, but a wipe a crash left
184
+ * unfinished is finished first (through `deleteStore`), so the store is
185
+ * never opened half-deleted.
186
+ */
187
+ export function holdReplicaStore(registry, account, deleteStore) {
188
+ return replicaLifecycle({
189
+ registry,
190
+ ledger: replicaLedger(registry),
191
+ heldHere: () => false,
192
+ deleteStore,
193
+ backendUser: async () => {
194
+ throw new Error("not asked: this page only holds the store");
195
+ },
196
+ deviceKeyKept: async () => true,
197
+ }).hold({ account });
198
+ }
199
+ async function holdLock(locks, registry, account) {
200
+ if (!locks)
201
+ return async () => { };
202
+ let release;
203
+ const released = new Promise((resolve) => (release = resolve));
204
+ let held;
205
+ await new Promise((acquired) => {
206
+ held = locks.request(lockName(registry, account), { mode: "shared" }, async () => {
207
+ acquired();
208
+ await released;
209
+ });
210
+ });
211
+ // Resolves once the lock is gone, not merely asked to go: a wipe that
212
+ // checks right after must not find this tab still holding it.
213
+ return async () => {
214
+ release();
215
+ await held.catch(() => { });
216
+ };
217
+ }
218
+ /** Whether a tab holds `account`'s store or waits to: a look, taking no lock. */
219
+ async function lockHeld(locks, registry, account) {
220
+ const state = await locks?.query?.();
221
+ if (!state)
222
+ return false;
223
+ const name = lockName(registry, account);
224
+ return [...(state.held ?? []), ...(state.pending ?? [])].some((lock) => lock.name === name);
225
+ }
226
+ /**
227
+ * Whether only an exclusive hold (another page's wipe or check, which ends
228
+ * soon) keeps `account`'s lock busy: no tab holds or waits to hold it open.
229
+ */
230
+ async function onlyBeingChecked(locks, registry, account) {
231
+ const state = await locks?.query?.();
232
+ if (!state)
233
+ return false;
234
+ const name = lockName(registry, account);
235
+ const locksOf = [...(state.held ?? []), ...(state.pending ?? [])].filter((lock) => lock.name === name);
236
+ return locksOf.length > 0 && locksOf.every((lock) => lock.mode === "exclusive");
237
+ }
238
+ /** Run `run` under the exclusive lock, or resolve `undefined` without running it while any tab holds it. */
239
+ async function whileNoTabHolds(locks, registry, account, run) {
240
+ if (!locks)
241
+ return run();
242
+ let result;
243
+ await locks.request(lockName(registry, account), { mode: "exclusive", ifAvailable: true }, async (lock) => {
244
+ if (lock)
245
+ result = await run();
246
+ });
247
+ return result;
248
+ }
249
+ /** As the backend watch confirms a signed-out answer before it signs anyone out. */
250
+ export const CONFIRM_SIGNED_OUT_MS = 2_000;
251
+ /** How long an open waits for an unfinished wipe it can't finish yet: at most ~10 s. */
252
+ const FINISH_WIPE_RETRY_MS = 100;
253
+ const FINISH_WIPE_RETRIES = 100;
254
+ /** How long the last tab out waits for another page's wipe or check to end: at most ~10 s. */
255
+ const SIGNED_OUT_RETRY_MS = 50;
256
+ const SIGNED_OUT_RETRIES = 200;
257
+ export function replicaLifecycle(options) {
258
+ const { registry, ledger } = options;
259
+ const locks = "locks" in options ? options.locks : webLocks();
260
+ const confirmMs = options.confirmMs ?? CONFIRM_SIGNED_OUT_MS;
261
+ /**
262
+ * The only wiper. Under the exclusive lock (so only while no tab holds
263
+ * the store), and only while the entry is still there and this page isn't
264
+ * on the account: marks it `wiping`, deletes, forgets it.
265
+ */
266
+ const wipeOne = async (account, { pendingUploads = 0, byThisPage = false } = {}) => {
267
+ const outcome = await whileNoTabHolds(locks, registry, account, async () => {
268
+ // Another tab wiped it first, or this page is on the account again
269
+ // (unless this page wipes it on purpose: its own sign-out, which still
270
+ // shows the account until it settles, or its own open finishing a wipe).
271
+ // Without durable storage nothing was recorded, and a page's own
272
+ // sign-out wipes anyway: clearOnSignOut never depends on the ledger.
273
+ const recorded = ledger.get(account) !== undefined || (byThisPage && !ledger.durable());
274
+ if (!recorded || (!byThisPage && options.heldHere(account)))
275
+ return "skipped";
276
+ // A closed page wipes nothing it didn't sign out itself.
277
+ if (!byThisPage && options.stopped?.())
278
+ return "skipped";
279
+ // A mark an earlier, crashed delete left must survive this attempt.
280
+ const crashed = ledger.get(account)?.wiping === true;
281
+ ledger.markWiping(account, true);
282
+ // A delete that fails leaves the mark: whether any of it went is
283
+ // unknown, so the account's next open or a later reconcile finishes it.
284
+ const deleted = await options.deleteStore(account);
285
+ if (deleted === "held") {
286
+ // Nothing was deleted now: a tab (of any build) still has it open,
287
+ // or its worker is closing. Unmarked, unless an earlier delete crashed.
288
+ ledger.markWiping(account, crashed);
289
+ return "held";
290
+ }
291
+ ledger.forget(account);
292
+ if (pendingUploads > 0)
293
+ console.warn(`Jazz signed out and wiped ${pendingUploads} write(s) the server hadn't confirmed, as clearOnSignOut asks. They are gone from this device; any the server did receive stay there.`);
294
+ return "wiped";
295
+ });
296
+ return outcome ?? "held";
297
+ };
298
+ /**
299
+ * Proof that no one is signed in as these backend users: two answers,
300
+ * `confirmMs` apart, neither naming them (so one failed session refresh
301
+ * in the app's `authenticate` wipes nothing). Asked once for all of them.
302
+ */
303
+ const backendSignedOut = async (entries) => {
304
+ const out = new Set();
305
+ if (entries.length === 0)
306
+ return out;
307
+ const names = (user, entry) => user?.issuer === entry.identity.issuer && user.subject === entry.identity.subject;
308
+ try {
309
+ const first = await options.backendUser();
310
+ const candidates = entries.filter((entry) => !names(first, entry));
311
+ if (candidates.length === 0)
312
+ return out;
313
+ await new Promise((resolve) => setTimeout(resolve, confirmMs));
314
+ const second = await options.backendUser();
315
+ for (const entry of candidates)
316
+ if (!names(second, entry))
317
+ out.add(entry.account);
318
+ }
319
+ catch {
320
+ // A backend that can't be asked proves nothing.
321
+ }
322
+ return out;
323
+ };
324
+ let reconciling;
325
+ let again = false;
326
+ const reconcileOnce = async () => {
327
+ if (options.stopped?.())
328
+ return;
329
+ const orphans = [];
330
+ for (const entry of ledger.read()) {
331
+ if (options.heldHere(entry.account))
332
+ continue;
333
+ if (await lockHeld(locks, registry, entry.account))
334
+ continue;
335
+ orphans.push(entry);
336
+ }
337
+ if (orphans.length === 0)
338
+ return;
339
+ // A device account whose key the device keeps can be opened again (it
340
+ // signed out, or another user signed in over it): its data stays. Only
341
+ // once the key is gone is its data no one's.
342
+ const keyGone = new Set();
343
+ for (const entry of orphans) {
344
+ if (entry.kind !== "device" || entry.wiping)
345
+ continue;
346
+ const kept = await options.deviceKeyKept(entry.account).catch(() => true);
347
+ if (!kept)
348
+ keyGone.add(entry.account);
349
+ }
350
+ const signedOut = await backendSignedOut(orphans.filter((entry) => entry.kind === "backend" && !entry.wiping));
351
+ for (const entry of orphans) {
352
+ const proven = entry.wiping ||
353
+ (entry.kind === "device" ? keyGone.has(entry.account) : signedOut.has(entry.account));
354
+ if (!proven)
355
+ continue;
356
+ try {
357
+ await wipeOne(entry.account);
358
+ }
359
+ catch (error) {
360
+ console.warn("Jazz could not wipe the local data a signed-out user left on this device (clearOnSignOut); it tries again later.", error);
361
+ }
362
+ }
363
+ };
364
+ return {
365
+ ledger,
366
+ /**
367
+ * Record `entry` and hold its store open in this tab, until the returned
368
+ * release is called. A wipe a crash left unfinished is finished first:
369
+ * a store is never opened half-deleted.
370
+ */
371
+ async hold(entry) {
372
+ const { account } = entry;
373
+ // Only a clearOnSignOut page records what it opens; any page finishes
374
+ // a wipe it finds unfinished, and holds the store.
375
+ const record = () => {
376
+ if ("kind" in entry)
377
+ ledger.record(entry);
378
+ };
379
+ for (let attempt = 0;; attempt++) {
380
+ // A store marked `wiping` (a crashed delete) is finished first: it is
381
+ // never opened half-deleted. A failing delete fails the open.
382
+ if (ledger.get(account)?.wiping)
383
+ await wipeOne(account, { byThisPage: true });
384
+ if (ledger.get(account)?.wiping) {
385
+ // "held": a tab, or a closing worker, still has it. Wait for it.
386
+ if (attempt >= FINISH_WIPE_RETRIES)
387
+ throw new Error("Jazz can't open this account's local data yet: a wipe of it (clearOnSignOut) is unfinished while another tab still has it open. Close the account's other tabs and try again.");
388
+ await new Promise((resolve) => setTimeout(resolve, FINISH_WIPE_RETRY_MS));
389
+ continue;
390
+ }
391
+ record();
392
+ const release = await holdLock(locks, registry, account);
393
+ // Again once held: another tab's wipe may have forgotten it before.
394
+ record();
395
+ if (!ledger.get(account)?.wiping)
396
+ return release;
397
+ // Another tab's delete failed between the check and the lock.
398
+ await release();
399
+ }
400
+ },
401
+ /** Whether a tab holds `account`'s store open (a look, taking no lock). */
402
+ heldByATab(account) {
403
+ return lockHeld(locks, registry, account);
404
+ },
405
+ /**
406
+ * This tab signed `account` out and closed its client (letting go of its
407
+ * hold). As the last tab out it wipes now; while another tab holds the
408
+ * store it does nothing, and that tab decides. `pendingUploads` is what
409
+ * the store held unconfirmed, for the warning.
410
+ */
411
+ async signedOut(account, pendingUploads) {
412
+ for (let attempt = 0;; attempt++) {
413
+ const outcome = await wipeOne(account, { pendingUploads, byThisPage: true });
414
+ // Held only by another page's wipe or check (both tabs signing out
415
+ // at once): that ends in moments, and the last tab out must not
416
+ // leave its store for a later page to find. Held by a tab: it decides.
417
+ if (outcome !== "held" ||
418
+ attempt >= SIGNED_OUT_RETRIES ||
419
+ !(await onlyBeingChecked(locks, registry, account)))
420
+ return outcome;
421
+ await new Promise((resolve) => setTimeout(resolve, SIGNED_OUT_RETRY_MS));
422
+ }
423
+ },
424
+ /**
425
+ * Wipe every Orphaned store no one can open again (a backend user the
426
+ * backend no longer names, twice; a device account whose key the device
427
+ * no longer keeps) and finish every Wiping one. Single-flight: a
428
+ * call while one runs runs once more after it.
429
+ */
430
+ reconcile() {
431
+ if (reconciling) {
432
+ again = true;
433
+ return reconciling;
434
+ }
435
+ reconciling = (async () => {
436
+ try {
437
+ do {
438
+ again = false;
439
+ await reconcileOnce();
440
+ } while (again);
441
+ }
442
+ finally {
443
+ reconciling = undefined;
444
+ }
445
+ })();
446
+ return reconciling;
447
+ },
448
+ };
449
+ }
450
+ //# sourceMappingURL=replica-ledger.js.map