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.
- package/README.md +1 -1
- package/bin/jazz-tools.js +3 -0
- package/dist/_dev/native-account-session.d.ts +8 -1
- package/dist/_dev/native-account-session.d.ts.map +1 -1
- package/dist/_dev/native-account-session.js +10 -0
- package/dist/_dev/native-account-session.js.map +1 -1
- package/dist/accounts/account-manager-core.d.ts +6 -0
- package/dist/accounts/account-manager-core.d.ts.map +1 -1
- package/dist/accounts/account-manager-core.js +26 -2
- package/dist/accounts/account-manager-core.js.map +1 -1
- package/dist/accounts/enrollment.d.ts.map +1 -1
- package/dist/accounts/enrollment.js +13 -4
- package/dist/accounts/enrollment.js.map +1 -1
- package/dist/accounts/exports.d.ts +1 -2
- package/dist/accounts/exports.d.ts.map +1 -1
- package/dist/accounts/exports.js +4 -1
- package/dist/accounts/exports.js.map +1 -1
- package/dist/accounts/persistence.d.ts +38 -2
- package/dist/accounts/persistence.d.ts.map +1 -1
- package/dist/accounts/persistence.js +123 -6
- package/dist/accounts/persistence.js.map +1 -1
- package/dist/accounts/registry-client.d.ts +29 -0
- package/dist/accounts/registry-client.d.ts.map +1 -1
- package/dist/accounts/registry-client.js +45 -0
- package/dist/accounts/registry-client.js.map +1 -1
- package/dist/accounts/state.d.ts.map +1 -1
- package/dist/accounts/state.js +2 -1
- package/dist/accounts/state.js.map +1 -1
- package/dist/backend/create-jazz-context.d.ts +7 -0
- package/dist/backend/create-jazz-context.d.ts.map +1 -1
- package/dist/backend/create-jazz-context.js +115 -18
- package/dist/backend/create-jazz-context.js.map +1 -1
- package/dist/backend/create-jazz-session.d.ts +9 -7
- package/dist/backend/create-jazz-session.d.ts.map +1 -1
- package/dist/backend/create-jazz-session.js +55 -17
- package/dist/backend/create-jazz-session.js.map +1 -1
- package/dist/backend/create-jazz.d.ts +196 -38
- package/dist/backend/create-jazz.d.ts.map +1 -1
- package/dist/backend/create-jazz.js +935 -147
- package/dist/backend/create-jazz.js.map +1 -1
- package/dist/backend/early-db.d.ts.map +1 -1
- package/dist/backend/early-db.js +1 -0
- package/dist/backend/early-db.js.map +1 -1
- package/dist/backend/external-jwt.d.ts.map +1 -1
- package/dist/backend/external-jwt.js +34 -10
- package/dist/backend/external-jwt.js.map +1 -1
- package/dist/backend/from-jwt.d.ts +6 -4
- package/dist/backend/from-jwt.d.ts.map +1 -1
- package/dist/backend/from-jwt.js +11 -3
- package/dist/backend/from-jwt.js.map +1 -1
- package/dist/backend/index.d.ts +2 -1
- package/dist/backend/index.d.ts.map +1 -1
- package/dist/backend/index.js +3 -1
- package/dist/backend/index.js.map +1 -1
- package/dist/backend/inspect-ui.d.ts +14 -0
- package/dist/backend/inspect-ui.d.ts.map +1 -0
- package/dist/backend/inspect-ui.js +156 -0
- package/dist/backend/inspect-ui.js.map +1 -0
- package/dist/backend/inspect.d.ts +133 -0
- package/dist/backend/inspect.d.ts.map +1 -0
- package/dist/backend/inspect.js +983 -0
- package/dist/backend/inspect.js.map +1 -0
- package/dist/backend/inspector-ui/0.js +2 -0
- package/dist/backend/inspector-ui/1.js +2 -0
- package/dist/backend/inspector-ui/10.js +2 -0
- package/dist/backend/inspector-ui/11.js +2 -0
- package/dist/backend/inspector-ui/12.js +2 -0
- package/dist/backend/inspector-ui/13.js +2 -0
- package/dist/backend/inspector-ui/14.js +2 -0
- package/dist/backend/inspector-ui/15.js +2 -0
- package/dist/backend/inspector-ui/16.js +2 -0
- package/dist/backend/inspector-ui/17.js +2 -0
- package/dist/backend/inspector-ui/18.js +2 -0
- package/dist/backend/inspector-ui/19.js +2 -0
- package/dist/backend/inspector-ui/2.js +2 -0
- package/dist/backend/inspector-ui/20.js +2 -0
- package/dist/backend/inspector-ui/3.js +2 -0
- package/dist/backend/inspector-ui/4.js +2 -0
- package/dist/backend/inspector-ui/5.js +2 -0
- package/dist/backend/inspector-ui/6.js +2 -0
- package/dist/backend/inspector-ui/7.js +2 -0
- package/dist/backend/inspector-ui/8.js +2 -0
- package/dist/backend/inspector-ui/9.js +2 -0
- package/dist/backend/inspector-ui-files.d.ts +4 -0
- package/dist/backend/inspector-ui-files.d.ts.map +1 -0
- package/dist/backend/inspector-ui-files.js +25 -0
- package/dist/backend/request-auth.d.ts +11 -0
- package/dist/backend/request-auth.d.ts.map +1 -1
- package/dist/backend/request-auth.js +14 -0
- package/dist/backend/request-auth.js.map +1 -1
- package/dist/backend/session-expiry.d.ts +61 -0
- package/dist/backend/session-expiry.d.ts.map +1 -0
- package/dist/backend/session-expiry.js +102 -0
- package/dist/backend/session-expiry.js.map +1 -0
- package/dist/backend/signing-key.d.ts +10 -0
- package/dist/backend/signing-key.d.ts.map +1 -0
- package/dist/backend/signing-key.js +15 -0
- package/dist/backend/signing-key.js.map +1 -0
- package/dist/backend/store-log.d.ts +3 -0
- package/dist/backend/store-log.d.ts.map +1 -0
- package/dist/backend/store-log.js +16 -0
- package/dist/backend/store-log.js.map +1 -0
- package/dist/backend/upgrade-status.d.ts +19 -0
- package/dist/backend/upgrade-status.d.ts.map +1 -0
- package/dist/backend/upgrade-status.js +55 -0
- package/dist/backend/upgrade-status.js.map +1 -0
- package/dist/backend/vercel-store.d.ts +88 -12
- package/dist/backend/vercel-store.d.ts.map +1 -1
- package/dist/backend/vercel-store.js +303 -44
- package/dist/backend/vercel-store.js.map +1 -1
- package/dist/backend/ws-peer.d.ts +32 -0
- package/dist/backend/ws-peer.d.ts.map +1 -0
- package/dist/backend/ws-peer.js +40 -0
- package/dist/backend/ws-peer.js.map +1 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.d.ts +134 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.d.ts.map +1 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.js +121 -0
- package/dist/better-auth-adapter/fixtures/issuer-upgrade-schema.js.map +1 -0
- package/dist/better-auth-adapter/fixtures/schema.d.ts +2 -1
- package/dist/better-auth-adapter/fixtures/schema.d.ts.map +1 -1
- package/dist/better-auth-adapter/fixtures/schema.js +2 -1
- package/dist/better-auth-adapter/fixtures/schema.js.map +1 -1
- package/dist/better-auth-adapter/index.d.ts.map +1 -1
- package/dist/better-auth-adapter/index.js +47 -0
- package/dist/better-auth-adapter/index.js.map +1 -1
- package/dist/classic-api.d.ts.map +1 -1
- package/dist/classic-api.js +36 -0
- package/dist/classic-api.js.map +1 -1
- package/dist/cli.d.ts.map +1 -1
- package/dist/cli.js +54 -11
- package/dist/cli.js.map +1 -1
- package/dist/client/index.d.ts +2 -6
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -3
- package/dist/client/index.js.map +1 -1
- package/dist/cloud/credentials.d.ts +1 -1
- package/dist/cloud/credentials.d.ts.map +1 -1
- package/dist/cloud/credentials.js.map +1 -1
- package/dist/dev/catalogue-project.d.ts +12 -3
- package/dist/dev/catalogue-project.d.ts.map +1 -1
- package/dist/dev/catalogue-project.js +29 -4
- package/dist/dev/catalogue-project.js.map +1 -1
- package/dist/dev/catalogue.d.ts +12 -0
- package/dist/dev/catalogue.d.ts.map +1 -1
- package/dist/dev/catalogue.js +94 -15
- package/dist/dev/catalogue.js.map +1 -1
- package/dist/dev/dev-server.d.ts +4 -1
- package/dist/dev/dev-server.d.ts.map +1 -1
- package/dist/dev/dev-server.js +41 -3
- package/dist/dev/dev-server.js.map +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/backend-C6JfNAB2.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/backend-DHeT1LCS.css +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{create-legacy-browser-delegate-X_T_QKCN.js → create-legacy-browser-delegate-Bf58kV5i.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{esm-aRzpnC3u.js → esm-B8Fn7-qJ.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{esm-ezD5H765.js → esm-C3BWHq-S.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/esm-DC_mAoiW.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{esm-7mP3GQX4.js → esm-D_R-EGgt.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{esm-BX6IY2Mv.js → esm-WihpI9g6.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/index-C_pcvEcg.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{jazz-broker-worker-XRRxJUcx.js → jazz-broker-worker-Cv6-V0tc.js} +787 -608
- package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-Db-pNME-.js +5 -0
- package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-CTwPHZcZ.js +1 -0
- package/dist/dev/inspector-overlay/embedded/assets/{jazz_wasm_bg-KR7h3v27.wasm → jazz_wasm_bg-HpkRDlj-.wasm} +0 -0
- package/dist/dev/inspector-overlay/embedded/assets/src-B5UtjtXQ.js +22 -0
- package/dist/dev/inspector-overlay/embedded/assets/{index-C78Pprka.css → src-Cq8gSOLx.css} +1 -1
- package/dist/dev/inspector-overlay/embedded/assets/{trace-api-B5CaetI0.js → trace-api-BctnwbUf.js} +1 -1
- package/dist/dev/inspector-overlay/embedded/backend.html +16 -0
- package/dist/dev/inspector-overlay/embedded/embedded.html +3 -2
- package/dist/dev/inspector-overlay/host-bridge.d.ts.map +1 -1
- package/dist/dev/inspector-overlay/host-bridge.js +4 -1
- package/dist/dev/inspector-overlay/host-bridge.js.map +1 -1
- package/dist/dev/inspector-overlay/loader.d.ts +12 -1
- package/dist/dev/inspector-overlay/loader.d.ts.map +1 -1
- package/dist/dev/inspector-overlay/loader.js +31 -4
- package/dist/dev/inspector-overlay/loader.js.map +1 -1
- package/dist/dev/migrations.d.ts.map +1 -1
- package/dist/dev/migrations.js +53 -7
- package/dist/dev/migrations.js.map +1 -1
- package/dist/drivers/schema-wire.d.ts +6 -2
- package/dist/drivers/schema-wire.d.ts.map +1 -1
- package/dist/drivers/schema-wire.js +6 -2
- package/dist/drivers/schema-wire.js.map +1 -1
- package/dist/effect/jazz.d.ts +12 -5
- package/dist/effect/jazz.d.ts.map +1 -1
- package/dist/effect/jazz.js +28 -5
- package/dist/effect/jazz.js.map +1 -1
- package/dist/expo/create-account-manager.d.ts +1 -1
- package/dist/expo/create-account-manager.d.ts.map +1 -1
- package/dist/expo/create-jazz-session.d.ts +37 -17
- package/dist/expo/create-jazz-session.d.ts.map +1 -1
- package/dist/expo/create-jazz-session.js +53 -10
- package/dist/expo/create-jazz-session.js.map +1 -1
- package/dist/expo/index.d.ts +5 -8
- package/dist/expo/index.d.ts.map +1 -1
- package/dist/expo/index.js +5 -7
- package/dist/expo/index.js.map +1 -1
- package/dist/expo/metro.d.ts +20 -0
- package/dist/expo/metro.d.ts.map +1 -0
- package/dist/expo/metro.js +58 -0
- package/dist/expo/metro.js.map +1 -0
- package/dist/expo/provider.d.ts +6 -3
- package/dist/expo/provider.d.ts.map +1 -1
- package/dist/expo/provider.js +7 -6
- package/dist/expo/provider.js.map +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/inspect/cli.d.ts +12 -0
- package/dist/inspect/cli.d.ts.map +1 -0
- package/dist/inspect/cli.js +320 -0
- package/dist/inspect/cli.js.map +1 -0
- package/dist/inspect/client.d.ts +67 -0
- package/dist/inspect/client.d.ts.map +1 -0
- package/dist/inspect/client.js +254 -0
- package/dist/inspect/client.js.map +1 -0
- package/dist/inspect/mcp.d.ts +28 -0
- package/dist/inspect/mcp.d.ts.map +1 -0
- package/dist/inspect/mcp.js +441 -0
- package/dist/inspect/mcp.js.map +1 -0
- package/dist/inspect/protocol.d.ts +317 -0
- package/dist/inspect/protocol.d.ts.map +1 -0
- package/dist/inspect/protocol.js +544 -0
- package/dist/inspect/protocol.js.map +1 -0
- package/dist/inspector/index.d.ts +10 -0
- package/dist/inspector/index.d.ts.map +1 -0
- package/dist/inspector/index.js +27 -0
- package/dist/inspector/index.js.map +1 -0
- package/dist/local-first/index.d.ts +2 -0
- package/dist/local-first/index.d.ts.map +1 -1
- package/dist/local-first/index.js +2 -0
- package/dist/local-first/index.js.map +1 -1
- package/dist/migrations.d.ts +23 -3
- package/dist/migrations.d.ts.map +1 -1
- package/dist/migrations.js +28 -6
- package/dist/migrations.js.map +1 -1
- package/dist/module-interop.d.ts +17 -0
- package/dist/module-interop.d.ts.map +1 -0
- package/dist/module-interop.js +32 -0
- package/dist/module-interop.js.map +1 -0
- package/dist/permissions/index.d.ts +1 -1
- package/dist/permissions/index.d.ts.map +1 -1
- package/dist/permissions/index.js +31 -10
- package/dist/permissions/index.js.map +1 -1
- package/dist/prosemirror/sync.d.ts.map +1 -1
- package/dist/prosemirror/sync.js +43 -21
- package/dist/prosemirror/sync.js.map +1 -1
- package/dist/react/index.d.ts +4 -9
- package/dist/react/index.d.ts.map +1 -1
- package/dist/react/index.js +4 -6
- package/dist/react/index.js.map +1 -1
- package/dist/react/provider-props.d.ts +7 -0
- package/dist/react/provider-props.d.ts.map +1 -0
- package/dist/react/provider-props.js +15 -0
- package/dist/react/provider-props.js.map +1 -0
- package/dist/react/provider.d.ts +9 -15
- package/dist/react/provider.d.ts.map +1 -1
- package/dist/react/provider.js +19 -38
- package/dist/react/provider.js.map +1 -1
- package/dist/react-core/index.d.ts +3 -4
- package/dist/react-core/index.d.ts.map +1 -1
- package/dist/react-core/index.js +8 -4
- package/dist/react-core/index.js.map +1 -1
- package/dist/react-core/provider.d.ts +6 -6
- package/dist/react-core/provider.d.ts.map +1 -1
- package/dist/react-core/provider.js +5 -6
- package/dist/react-core/provider.js.map +1 -1
- package/dist/react-core/session.d.ts +41 -33
- package/dist/react-core/session.d.ts.map +1 -1
- package/dist/react-core/session.js +42 -90
- package/dist/react-core/session.js.map +1 -1
- package/dist/react-native/account-session.js +1 -1
- package/dist/react-native/account-session.js.map +1 -1
- package/dist/react-native/create-account-manager.d.ts +1 -1
- package/dist/react-native/create-account-manager.d.ts.map +1 -1
- package/dist/react-native/create-jazz-session.d.ts +37 -17
- package/dist/react-native/create-jazz-session.d.ts.map +1 -1
- package/dist/react-native/create-jazz-session.js +53 -10
- package/dist/react-native/create-jazz-session.js.map +1 -1
- package/dist/react-native/index.d.ts +5 -10
- package/dist/react-native/index.d.ts.map +1 -1
- package/dist/react-native/index.js +5 -7
- package/dist/react-native/index.js.map +1 -1
- package/dist/react-native/native-foreground-db.d.ts +21 -0
- package/dist/react-native/native-foreground-db.d.ts.map +1 -1
- package/dist/react-native/native-foreground-db.js +47 -1
- package/dist/react-native/native-foreground-db.js.map +1 -1
- package/dist/react-native/provider.d.ts +14 -19
- package/dist/react-native/provider.d.ts.map +1 -1
- package/dist/react-native/provider.js +19 -18
- package/dist/react-native/provider.js.map +1 -1
- package/dist/react-native/runtime-source.d.ts +22 -0
- package/dist/react-native/runtime-source.d.ts.map +1 -1
- package/dist/react-native/runtime-source.js +68 -5
- package/dist/react-native/runtime-source.js.map +1 -1
- package/dist/removed-api.d.ts +87 -0
- package/dist/removed-api.d.ts.map +1 -0
- package/dist/removed-api.js +95 -0
- package/dist/removed-api.js.map +1 -0
- package/dist/runtime/auth-secret-store.d.ts +0 -44
- package/dist/runtime/auth-secret-store.d.ts.map +1 -1
- package/dist/runtime/auth-secret-store.js +1 -103
- package/dist/runtime/auth-secret-store.js.map +1 -1
- package/dist/runtime/authority-changed-error.d.ts +5 -3
- package/dist/runtime/authority-changed-error.d.ts.map +1 -1
- package/dist/runtime/authority-changed-error.js +5 -3
- package/dist/runtime/authority-changed-error.js.map +1 -1
- package/dist/runtime/browser-worker-assets.d.ts +19 -1
- package/dist/runtime/browser-worker-assets.d.ts.map +1 -1
- package/dist/runtime/browser-worker-assets.js +23 -1
- package/dist/runtime/browser-worker-assets.js.map +1 -1
- package/dist/runtime/browser-worker-assets.metro.d.ts +28 -0
- package/dist/runtime/browser-worker-assets.metro.d.ts.map +1 -0
- package/dist/runtime/browser-worker-assets.metro.js +52 -0
- package/dist/runtime/browser-worker-assets.metro.js.map +1 -0
- package/dist/runtime/browser-worker-assets.native.d.ts +2 -0
- package/dist/runtime/browser-worker-assets.native.d.ts.map +1 -1
- package/dist/runtime/browser-worker-assets.native.js +2 -0
- package/dist/runtime/browser-worker-assets.native.js.map +1 -1
- package/dist/runtime/browser-worker-config.d.ts +23 -0
- package/dist/runtime/browser-worker-config.d.ts.map +1 -1
- package/dist/runtime/browser-worker-config.js +72 -4
- package/dist/runtime/browser-worker-config.js.map +1 -1
- package/dist/runtime/client-migrations.d.ts +6 -4
- package/dist/runtime/client-migrations.d.ts.map +1 -1
- package/dist/runtime/client-migrations.js +20 -2
- package/dist/runtime/client-migrations.js.map +1 -1
- package/dist/runtime/client.d.ts +46 -6
- package/dist/runtime/client.d.ts.map +1 -1
- package/dist/runtime/client.js +65 -13
- package/dist/runtime/client.js.map +1 -1
- package/dist/runtime/connection-manager/browser-connection-manager.d.ts +5 -1
- package/dist/runtime/connection-manager/browser-connection-manager.d.ts.map +1 -1
- package/dist/runtime/connection-manager/browser-connection-manager.js +38 -2
- package/dist/runtime/connection-manager/browser-connection-manager.js.map +1 -1
- package/dist/runtime/connection-manager/direct-connection-manager.d.ts +3 -1
- package/dist/runtime/connection-manager/direct-connection-manager.d.ts.map +1 -1
- package/dist/runtime/connection-manager/direct-connection-manager.js +7 -3
- package/dist/runtime/connection-manager/direct-connection-manager.js.map +1 -1
- package/dist/runtime/connection-manager/types.d.ts +23 -2
- package/dist/runtime/connection-manager/types.d.ts.map +1 -1
- package/dist/runtime/connection-manager/types.js +49 -6
- package/dist/runtime/connection-manager/types.js.map +1 -1
- package/dist/runtime/context.d.ts +5 -1
- package/dist/runtime/context.d.ts.map +1 -1
- package/dist/runtime/context.js.map +1 -1
- package/dist/runtime/core-tick-failed-error.d.ts +31 -0
- package/dist/runtime/core-tick-failed-error.d.ts.map +1 -0
- package/dist/runtime/core-tick-failed-error.js +45 -0
- package/dist/runtime/core-tick-failed-error.js.map +1 -0
- package/dist/runtime/credentialed-transport.d.ts +18 -3
- package/dist/runtime/credentialed-transport.d.ts.map +1 -1
- package/dist/runtime/credentialed-transport.js +34 -11
- package/dist/runtime/credentialed-transport.js.map +1 -1
- package/dist/runtime/db-replaced-error.d.ts +3 -1
- package/dist/runtime/db-replaced-error.d.ts.map +1 -1
- package/dist/runtime/db-replaced-error.js +4 -2
- package/dist/runtime/db-replaced-error.js.map +1 -1
- package/dist/runtime/db.d.ts +40 -8
- package/dist/runtime/db.d.ts.map +1 -1
- package/dist/runtime/db.js +76 -9
- package/dist/runtime/db.js.map +1 -1
- package/dist/runtime/default-runtime-source.d.ts.map +1 -1
- package/dist/runtime/default-runtime-source.js +6 -1
- package/dist/runtime/default-runtime-source.js.map +1 -1
- package/dist/runtime/delete-local-first-store.d.ts +12 -0
- package/dist/runtime/delete-local-first-store.d.ts.map +1 -0
- package/dist/runtime/delete-local-first-store.js +12 -0
- package/dist/runtime/delete-local-first-store.js.map +1 -0
- package/dist/runtime/index.d.ts +4 -4
- package/dist/runtime/index.d.ts.map +1 -1
- package/dist/runtime/index.js +2 -2
- package/dist/runtime/index.js.map +1 -1
- package/dist/runtime/local-first-upgrade.d.ts +9 -0
- package/dist/runtime/local-first-upgrade.d.ts.map +1 -1
- package/dist/runtime/local-first-upgrade.js.map +1 -1
- package/dist/runtime/metro-setup-error.d.ts +20 -0
- package/dist/runtime/metro-setup-error.d.ts.map +1 -0
- package/dist/runtime/metro-setup-error.js +22 -0
- package/dist/runtime/metro-setup-error.js.map +1 -0
- package/dist/runtime/native-artifact-fingerprint-napi.d.ts +1 -1
- package/dist/runtime/native-artifact-fingerprint-napi.js +1 -1
- package/dist/runtime/native-artifact-fingerprint-napi.js.map +1 -1
- package/dist/runtime/native-artifact-fingerprint-wasm.d.ts +1 -1
- package/dist/runtime/native-artifact-fingerprint-wasm.js +1 -1
- package/dist/runtime/native-artifact-fingerprint-wasm.js.map +1 -1
- package/dist/runtime/native-artifact-fingerprints.d.ts +2 -2
- package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts +4 -1
- package/dist/runtime/native-runtime/attached-browser-worker-connection.d.ts.map +1 -1
- package/dist/runtime/native-runtime/attached-browser-worker-connection.js +3 -0
- package/dist/runtime/native-runtime/attached-browser-worker-connection.js.map +1 -1
- package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts +34 -0
- package/dist/runtime/native-runtime/broker-worker-load-failure.d.ts.map +1 -0
- package/dist/runtime/native-runtime/broker-worker-load-failure.js +61 -0
- package/dist/runtime/native-runtime/broker-worker-load-failure.js.map +1 -0
- package/dist/runtime/native-runtime/browser-follower-connection.d.ts +6 -1
- package/dist/runtime/native-runtime/browser-follower-connection.d.ts.map +1 -1
- package/dist/runtime/native-runtime/browser-follower-connection.js +9 -3
- package/dist/runtime/native-runtime/browser-follower-connection.js.map +1 -1
- package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts +12 -1
- package/dist/runtime/native-runtime/browser-shared-worker-connection.d.ts.map +1 -1
- package/dist/runtime/native-runtime/browser-shared-worker-connection.js +140 -7
- package/dist/runtime/native-runtime/browser-shared-worker-connection.js.map +1 -1
- package/dist/runtime/native-runtime/browser-worker-protocol.d.ts +29 -1
- package/dist/runtime/native-runtime/browser-worker-protocol.d.ts.map +1 -1
- package/dist/runtime/native-runtime/browser-worker-protocol.js.map +1 -1
- package/dist/runtime/native-runtime/http-stream-socket.d.ts +25 -7
- package/dist/runtime/native-runtime/http-stream-socket.d.ts.map +1 -1
- package/dist/runtime/native-runtime/http-stream-socket.js +148 -44
- package/dist/runtime/native-runtime/http-stream-socket.js.map +1 -1
- package/dist/runtime/native-runtime/native-error-code.d.ts +1 -1
- package/dist/runtime/native-runtime/native-error-code.d.ts.map +1 -1
- package/dist/runtime/native-runtime/native-error-code.js +1 -0
- package/dist/runtime/native-runtime/native-error-code.js.map +1 -1
- package/dist/runtime/native-runtime/native-runtime-adapter.d.ts +105 -7
- package/dist/runtime/native-runtime/native-runtime-adapter.d.ts.map +1 -1
- package/dist/runtime/native-runtime/native-runtime-adapter.js +306 -27
- package/dist/runtime/native-runtime/native-runtime-adapter.js.map +1 -1
- package/dist/runtime/native-runtime/session-renewal-wire.d.ts +48 -0
- package/dist/runtime/native-runtime/session-renewal-wire.d.ts.map +1 -0
- package/dist/runtime/native-runtime/session-renewal-wire.js +107 -0
- package/dist/runtime/native-runtime/session-renewal-wire.js.map +1 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.d.ts +22 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.d.ts.map +1 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.js +69 -0
- package/dist/runtime/native-runtime/stream-endpoint-memory.js.map +1 -0
- package/dist/runtime/native-runtime/websocket.d.ts +51 -1
- package/dist/runtime/native-runtime/websocket.d.ts.map +1 -1
- package/dist/runtime/native-runtime/websocket.js +187 -7
- package/dist/runtime/native-runtime/websocket.js.map +1 -1
- package/dist/runtime/page-handle.d.ts +83 -0
- package/dist/runtime/page-handle.d.ts.map +1 -0
- package/dist/runtime/page-handle.js +151 -0
- package/dist/runtime/page-handle.js.map +1 -0
- package/dist/runtime/removed-provider-props.d.ts +17 -0
- package/dist/runtime/removed-provider-props.d.ts.map +1 -0
- package/dist/runtime/removed-provider-props.js +16 -0
- package/dist/runtime/removed-provider-props.js.map +1 -0
- package/dist/runtime/row-transformer.d.ts.map +1 -1
- package/dist/runtime/row-transformer.js +20 -0
- package/dist/runtime/row-transformer.js.map +1 -1
- package/dist/runtime/runtime-config.d.ts +5 -1
- package/dist/runtime/runtime-config.d.ts.map +1 -1
- package/dist/runtime/runtime-config.js +5 -1
- package/dist/runtime/runtime-config.js.map +1 -1
- package/dist/runtime/runtime-source.d.ts +6 -1
- package/dist/runtime/runtime-source.d.ts.map +1 -1
- package/dist/runtime/runtime-source.js.map +1 -1
- package/dist/runtime/schema-metadata.d.ts +17 -0
- package/dist/runtime/schema-metadata.d.ts.map +1 -1
- package/dist/runtime/schema-metadata.js +28 -0
- package/dist/runtime/schema-metadata.js.map +1 -1
- package/dist/runtime/store-held-by-another-tab-error.d.ts +11 -0
- package/dist/runtime/store-held-by-another-tab-error.d.ts.map +1 -1
- package/dist/runtime/store-held-by-another-tab-error.js +11 -0
- package/dist/runtime/store-held-by-another-tab-error.js.map +1 -1
- package/dist/runtime/sync-status.d.ts +60 -1
- package/dist/runtime/sync-status.d.ts.map +1 -1
- package/dist/runtime/sync-status.js +64 -4
- package/dist/runtime/sync-status.js.map +1 -1
- package/dist/runtime/wasm-loader.d.ts.map +1 -1
- package/dist/runtime/wasm-loader.js +8 -1
- package/dist/runtime/wasm-loader.js.map +1 -1
- package/dist/schema-loader.d.ts +2 -0
- package/dist/schema-loader.d.ts.map +1 -1
- package/dist/schema-loader.js +7 -2
- package/dist/schema-loader.js.map +1 -1
- package/dist/schema-permissions.d.ts.map +1 -1
- package/dist/schema-permissions.js +19 -0
- package/dist/schema-permissions.js.map +1 -1
- package/dist/schema-source.d.ts.map +1 -1
- package/dist/schema-source.js +14 -0
- package/dist/schema-source.js.map +1 -1
- package/dist/session/backend-watch.d.ts +56 -15
- package/dist/session/backend-watch.d.ts.map +1 -1
- package/dist/session/backend-watch.js +127 -31
- package/dist/session/backend-watch.js.map +1 -1
- package/dist/session/config-options.d.ts +15 -0
- package/dist/session/config-options.d.ts.map +1 -0
- package/dist/session/config-options.js +55 -0
- package/dist/session/config-options.js.map +1 -0
- package/dist/session/consumer.d.ts +1 -1
- package/dist/session/consumer.js +1 -1
- package/dist/session/consumer.js.map +1 -1
- package/dist/session/create-jazz-session.d.ts +55 -21
- package/dist/session/create-jazz-session.d.ts.map +1 -1
- package/dist/session/create-jazz-session.js +215 -166
- package/dist/session/create-jazz-session.js.map +1 -1
- package/dist/session/follow-user.d.ts +30 -11
- package/dist/session/follow-user.d.ts.map +1 -1
- package/dist/session/follow-user.js +49 -9
- package/dist/session/follow-user.js.map +1 -1
- package/dist/session/jazz-session.d.ts +182 -0
- package/dist/session/jazz-session.d.ts.map +1 -0
- package/dist/session/jazz-session.js +459 -0
- package/dist/session/jazz-session.js.map +1 -0
- package/dist/session/no-kept-device-account-error.d.ts +6 -0
- package/dist/session/no-kept-device-account-error.d.ts.map +1 -0
- package/dist/session/no-kept-device-account-error.js +8 -0
- package/dist/session/no-kept-device-account-error.js.map +1 -0
- package/dist/session/replica-ledger.d.ts +164 -0
- package/dist/session/replica-ledger.d.ts.map +1 -0
- package/dist/session/replica-ledger.js +450 -0
- package/dist/session/replica-ledger.js.map +1 -0
- package/dist/session/state.d.ts +50 -13
- package/dist/session/state.d.ts.map +1 -1
- package/dist/session/state.js +158 -29
- package/dist/session/state.js.map +1 -1
- package/dist/solid/index.d.ts +3 -9
- package/dist/solid/index.d.ts.map +1 -1
- package/dist/solid/index.js +8 -11
- package/dist/solid/index.ssr.js +3 -6
- package/dist/solid/provider.d.ts +3 -3
- package/dist/solid/provider.d.ts.map +1 -1
- package/dist/solid/provider.js +23 -39
- package/dist/solid/provider.js.map +1 -1
- package/dist/solid/provider.ssr.js +6 -23
- package/dist/solid/provider.ssr.js.map +1 -1
- package/dist/solid/session.d.ts +42 -12
- package/dist/solid/session.d.ts.map +1 -1
- package/dist/solid/session.js +82 -35
- package/dist/solid/session.js.map +1 -1
- package/dist/solid/session.ssr.js +86 -23
- package/dist/solid/session.ssr.js.map +1 -1
- package/dist/svelte/JazzProvider.svelte +54 -20
- package/dist/svelte/JazzProvider.svelte.d.ts +14 -4
- package/dist/svelte/JazzProvider.svelte.d.ts.map +1 -1
- package/dist/svelte/JazzSvelteClientProvider.svelte +1 -7
- package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts +0 -1
- package/dist/svelte/JazzSvelteClientProvider.svelte.d.ts.map +1 -1
- package/dist/svelte/JazzSvelteProvider.svelte +5 -4
- package/dist/svelte/JazzSvelteProvider.svelte.d.ts +2 -2
- package/dist/svelte/JazzSvelteProvider.svelte.d.ts.map +1 -1
- package/dist/svelte/index.d.ts +4 -12
- package/dist/svelte/index.d.ts.map +1 -1
- package/dist/svelte/index.js +4 -8
- package/dist/svelte/session-state.d.ts +14 -4
- package/dist/svelte/session-state.d.ts.map +1 -1
- package/dist/svelte/session-state.js +10 -4
- package/dist/testing/client-migrations.d.ts +8 -1
- package/dist/testing/client-migrations.d.ts.map +1 -1
- package/dist/testing/client-migrations.js +11 -0
- package/dist/testing/client-migrations.js.map +1 -1
- package/dist/testing/policy-test-app.d.ts.map +1 -1
- package/dist/testing/policy-test-app.js +5 -4
- package/dist/testing/policy-test-app.js.map +1 -1
- package/dist/testing/test-jazz.d.ts +2 -2
- package/dist/testing/test-jazz.d.ts.map +1 -1
- package/dist/testing/test-jazz.js +6 -3
- package/dist/testing/test-jazz.js.map +1 -1
- package/dist/thin/index.d.ts +7 -10
- package/dist/thin/index.d.ts.map +1 -1
- package/dist/thin/index.js +28 -11
- package/dist/thin/index.js.map +1 -1
- package/dist/thin/thin-runtime.d.ts +53 -3
- package/dist/thin/thin-runtime.d.ts.map +1 -1
- package/dist/thin/thin-runtime.js +256 -33
- package/dist/thin/thin-runtime.js.map +1 -1
- package/dist/typed-app.d.ts +10 -4
- package/dist/typed-app.d.ts.map +1 -1
- package/dist/typed-app.js +44 -18
- package/dist/typed-app.js.map +1 -1
- package/dist/vue/index.d.ts +3 -8
- package/dist/vue/index.d.ts.map +1 -1
- package/dist/vue/index.js +3 -5
- package/dist/vue/index.js.map +1 -1
- package/dist/vue/provider.d.ts +6 -27
- package/dist/vue/provider.d.ts.map +1 -1
- package/dist/vue/provider.js +10 -19
- package/dist/vue/provider.js.map +1 -1
- package/dist/vue/session.d.ts +29 -28
- package/dist/vue/session.d.ts.map +1 -1
- package/dist/vue/session.js +80 -23
- package/dist/vue/session.js.map +1 -1
- package/dist/web/create-jazz-client.d.ts +5 -1
- package/dist/web/create-jazz-client.d.ts.map +1 -1
- package/dist/web/create-jazz-client.js +30 -3
- package/dist/web/create-jazz-client.js.map +1 -1
- package/dist/window-client-storage.d.ts +4 -30
- package/dist/window-client-storage.d.ts.map +1 -1
- package/dist/window-client-storage.js +2 -63
- package/dist/window-client-storage.js.map +1 -1
- package/dist/worker/jazz-broker-worker-core.d.ts.map +1 -1
- package/dist/worker/jazz-broker-worker-core.js +118 -20
- package/dist/worker/jazz-broker-worker-core.js.map +1 -1
- package/dist/worker/jazz-broker-worker.js +787 -608
- package/dist/worker/jazz_wasm_bg.wasm +0 -0
- package/dist/worker/runtime-admission.d.ts +19 -0
- package/dist/worker/runtime-admission.d.ts.map +1 -0
- package/dist/worker/runtime-admission.js +34 -0
- package/dist/worker/runtime-admission.js.map +1 -0
- package/dist/worker/vite-dev-broker.d.ts +2 -0
- package/dist/worker/vite-dev-broker.d.ts.map +1 -0
- package/dist/worker/vite-dev-broker.js +8 -0
- package/dist/worker/vite-dev-broker.js.map +1 -0
- package/package.json +30 -10
- package/dist/backend/session-recheck.d.ts +0 -18
- package/dist/backend/session-recheck.d.ts.map +0 -1
- package/dist/backend/session-recheck.js +0 -57
- package/dist/backend/session-recheck.js.map +0 -1
- package/dist/dev/inspector-overlay/embedded/assets/esm-k3rsq4Gn.js +0 -1
- package/dist/dev/inspector-overlay/embedded/assets/index-C-btvLcw.js +0 -20
- package/dist/dev/inspector-overlay/embedded/assets/jazz-broker-worker-CAMcDeUa.js +0 -3
- package/dist/dev/inspector-overlay/embedded/assets/jazz_wasm-Cc71x_6y.js +0 -1
- package/dist/dev/inspector-overlay/serve.d.ts +0 -46
- package/dist/dev/inspector-overlay/serve.d.ts.map +0 -1
- package/dist/dev/inspector-overlay/serve.js +0 -131
- package/dist/dev/inspector-overlay/serve.js.map +0 -1
- package/dist/dev-tools/auto-attach.d.ts +0 -11
- package/dist/dev-tools/auto-attach.d.ts.map +0 -1
- package/dist/dev-tools/auto-attach.js +0 -26
- package/dist/dev-tools/auto-attach.js.map +0 -1
- package/dist/expo/auth-secret-store.d.ts +0 -37
- package/dist/expo/auth-secret-store.d.ts.map +0 -1
- package/dist/expo/auth-secret-store.js +0 -139
- package/dist/expo/auth-secret-store.js.map +0 -1
- package/dist/expo/session.d.ts +0 -10
- package/dist/expo/session.d.ts.map +0 -1
- package/dist/expo/session.js +0 -5
- package/dist/expo/session.js.map +0 -1
- package/dist/expo/use-local-first-auth.d.ts +0 -12
- package/dist/expo/use-local-first-auth.d.ts.map +0 -1
- package/dist/expo/use-local-first-auth.js +0 -13
- package/dist/expo/use-local-first-auth.js.map +0 -1
- package/dist/react/devtools-auto-attach.d.ts +0 -2
- package/dist/react/devtools-auto-attach.d.ts.map +0 -1
- package/dist/react/devtools-auto-attach.js +0 -11
- package/dist/react/devtools-auto-attach.js.map +0 -1
- package/dist/react/session.d.ts +0 -18
- package/dist/react/session.d.ts.map +0 -1
- package/dist/react/session.js +0 -28
- package/dist/react/session.js.map +0 -1
- package/dist/react/use-local-first-auth.d.ts +0 -11
- package/dist/react/use-local-first-auth.d.ts.map +0 -1
- package/dist/react/use-local-first-auth.js +0 -13
- package/dist/react/use-local-first-auth.js.map +0 -1
- package/dist/react-core/app.d.ts +0 -31
- package/dist/react-core/app.d.ts.map +0 -1
- package/dist/react-core/app.js +0 -65
- package/dist/react-core/app.js.map +0 -1
- package/dist/react-core/use-account-state.d.ts +0 -4
- package/dist/react-core/use-account-state.d.ts.map +0 -1
- package/dist/react-core/use-account-state.js +0 -6
- package/dist/react-core/use-account-state.js.map +0 -1
- package/dist/react-core/use-local-first-auth.d.ts +0 -12
- package/dist/react-core/use-local-first-auth.d.ts.map +0 -1
- package/dist/react-core/use-local-first-auth.js +0 -14
- package/dist/react-core/use-local-first-auth.js.map +0 -1
- package/dist/react-native/session.d.ts +0 -10
- package/dist/react-native/session.d.ts.map +0 -1
- package/dist/react-native/session.js +0 -5
- package/dist/react-native/session.js.map +0 -1
- package/dist/react-native/use-local-first-auth.d.ts +0 -15
- package/dist/react-native/use-local-first-auth.d.ts.map +0 -1
- package/dist/react-native/use-local-first-auth.js +0 -14
- package/dist/react-native/use-local-first-auth.js.map +0 -1
- package/dist/runtime/local-first-auth-controller.d.ts +0 -29
- package/dist/runtime/local-first-auth-controller.d.ts.map +0 -1
- package/dist/runtime/local-first-auth-controller.js +0 -101
- package/dist/runtime/local-first-auth-controller.js.map +0 -1
- package/dist/session/app.d.ts +0 -58
- package/dist/session/app.d.ts.map +0 -1
- package/dist/session/app.js +0 -325
- package/dist/session/app.js.map +0 -1
- package/dist/session/create-jazz-app.d.ts +0 -11
- package/dist/session/create-jazz-app.d.ts.map +0 -1
- package/dist/session/create-jazz-app.js +0 -11
- package/dist/session/create-jazz-app.js.map +0 -1
- package/dist/session/left-behind-replicas.d.ts +0 -62
- package/dist/session/left-behind-replicas.d.ts.map +0 -1
- package/dist/session/left-behind-replicas.js +0 -146
- package/dist/session/left-behind-replicas.js.map +0 -1
- package/dist/solid/app.d.ts +0 -30
- package/dist/solid/app.d.ts.map +0 -1
- package/dist/solid/app.js +0 -95
- package/dist/solid/app.js.map +0 -1
- package/dist/solid/app.ssr.js +0 -109
- package/dist/solid/app.ssr.js.map +0 -1
- package/dist/solid/create-account-state.d.ts +0 -4
- package/dist/solid/create-account-state.d.ts.map +0 -1
- package/dist/solid/create-account-state.js +0 -10
- package/dist/solid/create-account-state.js.map +0 -1
- package/dist/solid/create-account-state.ssr.js +0 -12
- package/dist/solid/create-account-state.ssr.js.map +0 -1
- package/dist/solid/use-local-first-auth.d.ts +0 -11
- package/dist/solid/use-local-first-auth.d.ts.map +0 -1
- package/dist/solid/use-local-first-auth.js +0 -30
- package/dist/solid/use-local-first-auth.js.map +0 -1
- package/dist/solid/use-local-first-auth.ssr.js +0 -31
- package/dist/solid/use-local-first-auth.ssr.js.map +0 -1
- package/dist/svelte/JazzSessionClientProvider.svelte +0 -42
- package/dist/svelte/JazzSessionClientProvider.svelte.d.ts +0 -13
- package/dist/svelte/JazzSessionClientProvider.svelte.d.ts.map +0 -1
- package/dist/svelte/JazzSessionProvider.svelte +0 -68
- package/dist/svelte/JazzSessionProvider.svelte.d.ts +0 -19
- package/dist/svelte/JazzSessionProvider.svelte.d.ts.map +0 -1
- package/dist/svelte/account-state.d.ts +0 -5
- package/dist/svelte/account-state.d.ts.map +0 -1
- package/dist/svelte/account-state.js +0 -9
- package/dist/svelte/auth-state.d.ts +0 -23
- package/dist/svelte/auth-state.d.ts.map +0 -1
- package/dist/svelte/auth-state.js +0 -16
- package/dist/svelte/local-first-auth.svelte.d.ts +0 -50
- package/dist/svelte/local-first-auth.svelte.d.ts.map +0 -1
- package/dist/svelte/local-first-auth.svelte.js +0 -58
- package/dist/vue/app.d.ts +0 -76
- package/dist/vue/app.d.ts.map +0 -1
- package/dist/vue/app.js +0 -100
- package/dist/vue/app.js.map +0 -1
- package/dist/vue/use-account-state.d.ts +0 -5
- package/dist/vue/use-account-state.d.ts.map +0 -1
- package/dist/vue/use-account-state.js +0 -10
- package/dist/vue/use-account-state.js.map +0 -1
- package/dist/vue/use-local-first-auth.d.ts +0 -53
- package/dist/vue/use-local-first-auth.d.ts.map +0 -1
- package/dist/vue/use-local-first-auth.js +0 -67
- package/dist/vue/use-local-first-auth.js.map +0 -1
- /package/dist/dev/inspector-overlay/embedded/assets/{esm-CH5eVyQQ.js → esm-xNe3wI_B.js} +0 -0
- /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
|