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
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import type { SignedOutDecision } from "./backend-watch.js";
|
|
1
2
|
import type { AccountManagerConfig } from "../accounts/create-account-manager.js";
|
|
2
3
|
import { type JazzClient } from "../web/registered-jazz-client.js";
|
|
3
4
|
import type { OpenJazzClientConfig } from "../web/create-jazz-client.js";
|
|
4
5
|
import { type LocalFirstLoader } from "../runtime/local-first-upgrade.js";
|
|
6
|
+
import { type JazzSession } from "./jazz-session.js";
|
|
5
7
|
import { type UserFollowingSession } from "./follow-user.js";
|
|
6
8
|
export type { LocalFirstLoader };
|
|
7
9
|
export type JazzClientConfig = Omit<OpenJazzClientConfig, "account" | "serverUrl" | "appId"> & Omit<AccountManagerConfig, "appId"> & {
|
|
@@ -15,31 +17,42 @@ export type JazzClientConfig = Omit<OpenJazzClientConfig, "account" | "serverUrl
|
|
|
15
17
|
/**
|
|
16
18
|
* Your app's Jazz endpoint: by default `"/jazz"`, where `createJazz` is
|
|
17
19
|
* mounted in your own backend. `null` keeps Jazz on this device only: no
|
|
18
|
-
* server, no sign-in, one
|
|
19
|
-
*
|
|
20
|
+
* server, no sign-in, one device account per browser profile. That needs
|
|
21
|
+
* the local-first client (`client`).
|
|
20
22
|
*/
|
|
21
23
|
serverUrl?: string | null;
|
|
22
24
|
/**
|
|
23
25
|
* Who the app starts as before your backend names a user: signed out
|
|
24
|
-
* (the default, also `"signed-out"`), or a `"
|
|
25
|
-
* account on this device
|
|
26
|
-
*
|
|
27
|
-
* (`
|
|
28
|
-
*
|
|
26
|
+
* (the default, also `"signed-out"`), or a `"device"` account: an
|
|
27
|
+
* account whose key lives on this device, which is how you let people
|
|
28
|
+
* start as guests, and which can later link to your backend's user
|
|
29
|
+
* (`linkDeviceAccount()`). Your backend must accept device accounts
|
|
30
|
+
* (`acceptDeviceAccounts`). A device account works offline once its
|
|
31
|
+
* client is the local-first one (`client`).
|
|
29
32
|
*/
|
|
30
|
-
initial?: "
|
|
33
|
+
initial?: "device" | "signed-out";
|
|
31
34
|
/**
|
|
32
|
-
* When a
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
* the account and everything
|
|
36
|
-
* default. Turn it off on shared devices, where the
|
|
37
|
-
* else's: the session then leaves
|
|
38
|
-
* decides after its own sign-in, with `
|
|
39
|
-
*
|
|
40
|
-
*
|
|
35
|
+
* When a device account is on this device and the user who signs in has
|
|
36
|
+
* no Jazz account yet (they just signed up, or they are an existing user
|
|
37
|
+
* signing in to Jazz for the first time), link the device account to
|
|
38
|
+
* them: the account and everything it wrote become theirs. On by
|
|
39
|
+
* default. Turn it off on shared devices, where the device account may be
|
|
40
|
+
* someone else's guest: the session then leaves it as it is, and your
|
|
41
|
+
* app decides after its own sign-in, with `linkDeviceAccount()` (its data
|
|
42
|
+
* becomes the user's) or `refresh()` (an account of the user's own; the
|
|
43
|
+
* device account stays on this device).
|
|
41
44
|
*/
|
|
42
|
-
|
|
45
|
+
linkDeviceAccountOnSignUp?: boolean;
|
|
46
|
+
/**
|
|
47
|
+
* Called when your backend says no one is signed in any more (confirmed
|
|
48
|
+
* by a second answer a moment later), before the session signs the
|
|
49
|
+
* user out. Return `"keep"` to stay signed in for now (your app refreshed
|
|
50
|
+
* its session itself, or redirects to sign-in first): the session asks
|
|
51
|
+
* your backend again on the next focus, refusal or `refresh()`.
|
|
52
|
+
* Return `"sign-out"` (or nothing) to sign out. A hook that throws signs
|
|
53
|
+
* out.
|
|
54
|
+
*/
|
|
55
|
+
onSignedOut?: () => SignedOutDecision | void | Promise<SignedOutDecision | void>;
|
|
43
56
|
/**
|
|
44
57
|
* On sign-out (or a switch to another user), wipe the account's local
|
|
45
58
|
* storage instead of keeping it for that user's next sign-in. For shared
|
|
@@ -60,9 +73,30 @@ export type JazzClientConfig = Omit<OpenJazzClientConfig, "account" | "serverUrl
|
|
|
60
73
|
* away, so it works offline.
|
|
61
74
|
*/
|
|
62
75
|
client?: LocalFirstLoader;
|
|
76
|
+
/**
|
|
77
|
+
* When the local-first client (`client`) opens:
|
|
78
|
+
* - `"background"` (the default): start thin and upgrade once the page
|
|
79
|
+
* has loaded, unless this account upgraded in this browser before.
|
|
80
|
+
* The first paint needs no WASM.
|
|
81
|
+
* - `"now"`: open the local-first client straight away, for every
|
|
82
|
+
* account. For apps that must work offline from the first render, or
|
|
83
|
+
* that use `db.transaction`, which only the local-first client has.
|
|
84
|
+
* If the local-first client can't load, the session fails (`retry()`
|
|
85
|
+
* tries again) rather than running thin.
|
|
86
|
+
*
|
|
87
|
+
* Needs `client`: `"now"` without it is refused.
|
|
88
|
+
*/
|
|
89
|
+
localFirst?: "now" | "background";
|
|
63
90
|
};
|
|
64
|
-
/** A browser's
|
|
91
|
+
/** @internal A browser session's core, which follows your auth's signed-in user. */
|
|
65
92
|
export type BrowserJazzSession = UserFollowingSession<JazzClient>;
|
|
66
|
-
/**
|
|
67
|
-
|
|
93
|
+
/**
|
|
94
|
+
* Open a Jazz session in this browser: who is signed in, and the client that
|
|
95
|
+
* reads and writes as them. Resolves once it started; rejects if it can't.
|
|
96
|
+
* Your backend decides who is signed in; call `session.refresh()` after your
|
|
97
|
+
* own sign-in or sign-out.
|
|
98
|
+
*/
|
|
99
|
+
export declare function createJazzClient(config: JazzClientConfig): Promise<JazzSession<JazzClient>>;
|
|
100
|
+
/** @internal The session core `createJazzClient` and `<JazzProvider>` own. */
|
|
101
|
+
export declare function openBrowserSessionCore(config: JazzClientConfig): Promise<BrowserJazzSession>;
|
|
68
102
|
//# sourceMappingURL=create-jazz-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-jazz-session.d.ts","sourceRoot":"","sources":["../../src/session/create-jazz-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;
|
|
1
|
+
{"version":3,"file":"create-jazz-session.d.ts","sourceRoot":"","sources":["../../src/session/create-jazz-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAWlF,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAOzE,OAAO,EAEL,KAAK,gBAAgB,EAEtB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,EAAyC,KAAK,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAG5F,OAAO,EAKL,KAAK,oBAAoB,EAC1B,MAAM,kBAAkB,CAAC;AAY1B,YAAY,EAAE,gBAAgB,EAAE,CAAC;AAEjC,MAAM,MAAM,gBAAgB,GAAG,IAAI,CAAC,oBAAoB,EAAE,SAAS,GAAG,WAAW,GAAG,OAAO,CAAC,GAC1F,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,GAAG;IACpC;;;;;OAKG;IACH,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;;;OAKG;IACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B;;;;;;;;OAQG;IACH,OAAO,CAAC,EAAE,QAAQ,GAAG,YAAY,CAAC;IAClC;;;;;;;;;;OAUG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;IACpC;;;;;;;;OAQG;IACH,WAAW,CAAC,EAAE,MAAM,iBAAiB,GAAG,IAAI,GAAG,OAAO,CAAC,iBAAiB,GAAG,IAAI,CAAC,CAAC;IACjF;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B;;;;;;;;;;;;OAYG;IACH,UAAU,CAAC,EAAE,KAAK,GAAG,YAAY,CAAC;CACnC,CAAC;AA8BJ,oFAAoF;AACpF,MAAM,MAAM,kBAAkB,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC;AAgClE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC,CAE3F;AAED,8EAA8E;AAC9E,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,kBAAkB,CAAC,CAsO7B"}
|
|
@@ -1,15 +1,47 @@
|
|
|
1
|
-
import { clientRegistryUrl, createAccountManagerWithMinter, } from "../accounts/account-manager-core.js";
|
|
1
|
+
import { clientRegistryUrl, createAccountManagerWithMinter, watchStoredSelection, } from "../accounts/account-manager-core.js";
|
|
2
2
|
import { attachSubscriptionStore, getSubscriptionStore } from "../subscription-store-internal.js";
|
|
3
3
|
import { bearerFetch } from "../runtime/credentialed-transport.js";
|
|
4
|
+
import { sessionRefreshLockName } from "../runtime/native-runtime/session-renewal-wire.js";
|
|
4
5
|
import { createRegisteredJazzClient, } from "../web/registered-jazz-client.js";
|
|
5
6
|
import { createClient as createThinDb, mintLocalFirstTokenInJs, prefetchThinQueries, handOffThinWrites, } from "../thin/index.js";
|
|
6
7
|
import { setLocalFirstUpgrader, } from "../runtime/local-first-upgrade.js";
|
|
7
8
|
import { createJazzSessionOwner, replaceJazzSessionClient } from "./state.js";
|
|
9
|
+
import { coreInitial, createStartedJazzSession } from "./jazz-session.js";
|
|
8
10
|
import { DEFAULT_SERVER_URL, refuseClientAppId } from "../runtime/client-scope.js";
|
|
9
11
|
import { browserBackendWatchEvents } from "./backend-watch.js";
|
|
10
12
|
import { backendAnswered, firstBackendAnswer, followUser, signedInIdentity, } from "./follow-user.js";
|
|
11
|
-
import {
|
|
13
|
+
import { holdReplicaStore, replicaLedger, replicaLifecycle, } from "./replica-ledger.js";
|
|
14
|
+
import { refuseInvalidSessionConfig } from "./config-options.js";
|
|
15
|
+
import { warnWindowJazzConflict } from "../runtime/page-handle.js";
|
|
16
|
+
import { accountForgotten, storedKeepsDeviceAccount } from "../accounts/persistence.js";
|
|
12
17
|
import { rememberBackendUser } from "../accounts/enrollment.js";
|
|
18
|
+
/**
|
|
19
|
+
* Every option `createJazzClient` takes in a browser, checked against the
|
|
20
|
+
* config type both ways (`appId` and `backendSecret` are refused by type, and
|
|
21
|
+
* `appId` by name too).
|
|
22
|
+
*/
|
|
23
|
+
const BROWSER_SESSION_OPTIONS = {
|
|
24
|
+
serverUrl: true,
|
|
25
|
+
initial: true,
|
|
26
|
+
linkDeviceAccountOnSignUp: true,
|
|
27
|
+
onSignedOut: true,
|
|
28
|
+
clearOnSignOut: true,
|
|
29
|
+
client: true,
|
|
30
|
+
localFirst: true,
|
|
31
|
+
scope: true,
|
|
32
|
+
driver: true,
|
|
33
|
+
env: true,
|
|
34
|
+
runtimeSources: true,
|
|
35
|
+
dbName: true,
|
|
36
|
+
initialSyncFlushEvery: true,
|
|
37
|
+
logLevel: true,
|
|
38
|
+
telemetryCollectorUrl: true,
|
|
39
|
+
devMode: true,
|
|
40
|
+
slowQueryThresholdMs: true,
|
|
41
|
+
store: true,
|
|
42
|
+
fetch: true,
|
|
43
|
+
bearer: true,
|
|
44
|
+
};
|
|
13
45
|
/**
|
|
14
46
|
* A client keeps its options as configuration (`db.getConfig()` clones them),
|
|
15
47
|
* so one that holds a function or class could only fail later, in whatever
|
|
@@ -34,17 +66,35 @@ function refuseUnkeptOptions(clientConfig) {
|
|
|
34
66
|
}
|
|
35
67
|
}
|
|
36
68
|
}
|
|
37
|
-
/**
|
|
38
|
-
|
|
39
|
-
|
|
69
|
+
/**
|
|
70
|
+
* Open a Jazz session in this browser: who is signed in, and the client that
|
|
71
|
+
* reads and writes as them. Resolves once it started; rejects if it can't.
|
|
72
|
+
* Your backend decides who is signed in; call `session.refresh()` after your
|
|
73
|
+
* own sign-in or sign-out.
|
|
74
|
+
*/
|
|
75
|
+
export function createJazzClient(config) {
|
|
76
|
+
return createStartedJazzSession(config, openBrowserSessionCore);
|
|
77
|
+
}
|
|
78
|
+
/** @internal The session core `createJazzClient` and `<JazzProvider>` own. */
|
|
79
|
+
export async function openBrowserSessionCore(config) {
|
|
80
|
+
if (config && typeof config === "object")
|
|
81
|
+
refuseClientAppId(config);
|
|
82
|
+
refuseInvalidSessionConfig(config, BROWSER_SESSION_OPTIONS);
|
|
83
|
+
// `window.__jazz` is Jazz's page handle: an app's own global there is left
|
|
84
|
+
// alone (Jazz goes without the handle), and said so now rather than at the
|
|
85
|
+
// upgrade to local-first.
|
|
86
|
+
const page = globalThis.window;
|
|
87
|
+
if (page && typeof page.document !== "undefined")
|
|
88
|
+
warnWindowJazzConflict(page);
|
|
40
89
|
if (config.serverUrl === null)
|
|
41
90
|
return createDeviceOnlySession(config);
|
|
42
91
|
const serverUrl = config.serverUrl ?? DEFAULT_SERVER_URL;
|
|
43
|
-
const { initial, clearOnSignOut,
|
|
92
|
+
const { initial, clearOnSignOut, linkDeviceAccountOnSignUp, onSignedOut, client: loadLocalFirst, localFirst,
|
|
44
93
|
// The account manager's own: neither is client configuration, and a Db
|
|
45
94
|
// keeps only cloneable data (db.getConfig()).
|
|
46
95
|
store: _store, fetch: _fetch, bearer, ...clientConfig } = { ...config, serverUrl };
|
|
47
96
|
refuseUnkeptOptions(clientConfig);
|
|
97
|
+
refuseLocalFirstTiming(localFirst, loadLocalFirst);
|
|
48
98
|
const accounts = await createAccountManagerWithMinter({ ...config, serverUrl }, mintLocalFirstTokenInJs,
|
|
49
99
|
// A shared device: never reopen the last user before the backend answers.
|
|
50
100
|
{ rememberBackendUser: !clearOnSignOut });
|
|
@@ -52,46 +102,65 @@ export async function createJazzClient(config) {
|
|
|
52
102
|
const upgrades = localFirstMemory(registry);
|
|
53
103
|
// A memory-only client has no storage to wipe.
|
|
54
104
|
const wipesOnSignOut = !!clearOnSignOut && (config.driver?.type ?? "persistent") === "persistent";
|
|
55
|
-
//
|
|
56
|
-
const leftBehind = wipesOnSignOut && loadLocalFirst ? leftBehindReplicas(registry) : undefined;
|
|
57
|
-
// Accounts whose local-first client is (or was) the session's own in this
|
|
58
|
-
// page: signing them out here wiped their replica.
|
|
59
|
-
const inSession = new Set();
|
|
60
|
-
// Accounts this page is opening a local-first client for, and replicas
|
|
61
|
-
// being wiped: an account's open waits for its wipe to finish.
|
|
105
|
+
// Accounts this page is opening a local-first client for.
|
|
62
106
|
const opening = new Set();
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
}).catch(() => { });
|
|
107
|
+
/** Delete `account`'s store through its worker, without opening it. */
|
|
108
|
+
const deleteStore = async (account) => {
|
|
109
|
+
// `jazz-tools/local-first` brings it in the app's own chunk; a loader
|
|
110
|
+
// that gives only `createClient` gets it loaded here.
|
|
111
|
+
const deleteLocalFirstStore = (await loadLocalFirst()).deleteLocalFirstStore ??
|
|
112
|
+
(await import("../runtime/delete-local-first-store.js")).deleteLocalFirstStore;
|
|
113
|
+
return deleteLocalFirstStore({
|
|
114
|
+
...clientConfig,
|
|
115
|
+
accountId: account,
|
|
116
|
+
accountRegistryAuthority: registry,
|
|
117
|
+
});
|
|
75
118
|
};
|
|
76
|
-
|
|
119
|
+
// The lifecycle of this device's per-account stores (see `replicaLifecycle`).
|
|
120
|
+
const replicas = wipesOnSignOut && loadLocalFirst ? openReplicaLifecycle() : undefined;
|
|
121
|
+
function openReplicaLifecycle() {
|
|
122
|
+
const fetcher = bearer ? bearerFetch(bearer, config.fetch) : config.fetch;
|
|
123
|
+
return replicaLifecycle({
|
|
124
|
+
registry,
|
|
125
|
+
ledger: replicaLedger(registry),
|
|
126
|
+
stopped: () => session?.getSnapshot().status === "closed",
|
|
127
|
+
heldHere: (account) => {
|
|
128
|
+
if (opening.has(account))
|
|
129
|
+
return true;
|
|
130
|
+
const snapshot = session?.getSnapshot();
|
|
131
|
+
return snapshot?.status !== "closed" && snapshot?.account?.id === account;
|
|
132
|
+
},
|
|
133
|
+
deleteStore,
|
|
134
|
+
backendUser: async () => {
|
|
135
|
+
const user = await signedInIdentity(registry, fetcher);
|
|
136
|
+
return user ? { issuer: user.issuer, subject: user.subject } : null;
|
|
137
|
+
},
|
|
138
|
+
deviceKeyKept: (account) => storedKeepsDeviceAccount(accounts, account),
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Open `account`'s local-first client, held open against every tab's
|
|
143
|
+
* wipe, and (with clearOnSignOut) recorded in the ledger so a later page
|
|
144
|
+
* wipes what a sign-out this page doesn't see leaves behind.
|
|
145
|
+
*/
|
|
77
146
|
const openReplica = async (createDb, account) => {
|
|
78
|
-
// Only a user the backend signed in: a guest's replica is the device's own.
|
|
79
|
-
if (!leftBehind || !rememberBackendUser(account))
|
|
80
|
-
return openLocalFirst(createDb, account);
|
|
81
147
|
opening.add(account.id);
|
|
82
|
-
signedOutHere.delete(account.id);
|
|
83
148
|
try {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
const release =
|
|
87
|
-
|
|
88
|
-
|
|
149
|
+
// Without clearOnSignOut nothing is recorded, but the store is held
|
|
150
|
+
// all the same: a wipe from a tab that has clearOnSignOut must wait.
|
|
151
|
+
const release = replicas
|
|
152
|
+
? await replicas.hold({
|
|
153
|
+
account: account.id,
|
|
154
|
+
kind: rememberBackendUser(account) ? "backend" : "device",
|
|
155
|
+
identity: account.identity,
|
|
156
|
+
})
|
|
157
|
+
: await holdReplicaStore(registry, account.id, () => deleteStore(account.id));
|
|
89
158
|
let client;
|
|
90
159
|
try {
|
|
91
160
|
client = await openLocalFirst(createDb, account);
|
|
92
161
|
}
|
|
93
162
|
catch (error) {
|
|
94
|
-
release();
|
|
163
|
+
await release();
|
|
95
164
|
throw error;
|
|
96
165
|
}
|
|
97
166
|
const shutdown = client.shutdown.bind(client);
|
|
@@ -100,8 +169,7 @@ export async function createJazzClient(config) {
|
|
|
100
169
|
await shutdown(options);
|
|
101
170
|
}
|
|
102
171
|
finally {
|
|
103
|
-
release();
|
|
104
|
-
forgetSignedOut(account.id);
|
|
172
|
+
await release();
|
|
105
173
|
}
|
|
106
174
|
};
|
|
107
175
|
return client;
|
|
@@ -110,6 +178,24 @@ export async function createJazzClient(config) {
|
|
|
110
178
|
opening.delete(account.id);
|
|
111
179
|
}
|
|
112
180
|
};
|
|
181
|
+
/**
|
|
182
|
+
* How this page signs a local-first account out under `clearOnSignOut`:
|
|
183
|
+
* upload what the server still accepts, count what it still holds (every
|
|
184
|
+
* tab's writes), close this tab's client (letting go of its hold), then
|
|
185
|
+
* wipe as the last tab out. While another tab holds the store it doesn't:
|
|
186
|
+
* that tab decides. Resolves whether the store is gone.
|
|
187
|
+
*/
|
|
188
|
+
const wipeSignedOut = async (client, account) => {
|
|
189
|
+
// Loaded first: a chunk that won't load fails the sign-out while the
|
|
190
|
+
// client still works, rather than after it closed.
|
|
191
|
+
await loadLocalFirst();
|
|
192
|
+
await client.db.waitForSync({ timeoutMs: 5_000 }).catch(() => { });
|
|
193
|
+
const pendingUploads = await client.db
|
|
194
|
+
.storePendingUploads()
|
|
195
|
+
.catch(() => client.db.getSyncStatus().pendingUploads);
|
|
196
|
+
await client.shutdown();
|
|
197
|
+
return (await replicas.signedOut(account.id, pendingUploads)) !== "held";
|
|
198
|
+
};
|
|
113
199
|
let session;
|
|
114
200
|
const openLocalFirst = (createDb, account) => createRegisteredJazzClient("web", { ...clientConfig, account }, createDb);
|
|
115
201
|
const upgrade = async (loader) => {
|
|
@@ -130,10 +216,8 @@ export async function createJazzClient(config) {
|
|
|
130
216
|
}, (current, next) => upgradesInPlace.get(current)(next));
|
|
131
217
|
// Only once the session took the new client: a superseded upgrade
|
|
132
218
|
// (a logout or account switch meanwhile) is not remembered.
|
|
133
|
-
if (upgraded)
|
|
219
|
+
if (upgraded)
|
|
134
220
|
upgrades.remember(upgraded);
|
|
135
|
-
inSession.add(upgraded.id);
|
|
136
|
-
}
|
|
137
221
|
};
|
|
138
222
|
const openThin = async (account) => {
|
|
139
223
|
const thin = await createRegisteredJazzClient("web-thin", { ...clientConfig, account }, createThinDb);
|
|
@@ -147,139 +231,112 @@ export async function createJazzClient(config) {
|
|
|
147
231
|
return upgradableClient(thin);
|
|
148
232
|
};
|
|
149
233
|
const openClient = async (account) => {
|
|
150
|
-
if (loadLocalFirst && upgrades.has(account)) {
|
|
234
|
+
if (loadLocalFirst && (localFirst === "now" || upgrades.has(account))) {
|
|
151
235
|
let module;
|
|
152
236
|
try {
|
|
153
237
|
module = await loadLocalFirst();
|
|
154
238
|
}
|
|
155
239
|
catch (error) {
|
|
240
|
+
// Asked for local-first now: running thin would quietly break what
|
|
241
|
+
// the app needs it for (offline, db.transaction).
|
|
242
|
+
if (localFirst === "now")
|
|
243
|
+
throw error;
|
|
156
244
|
// A chunk that no longer loads (renamed by a deploy, or the network)
|
|
157
245
|
// costs the app its offline start, not the session: it runs thin,
|
|
158
246
|
// and the background upgrade tries the loader again.
|
|
159
247
|
console.warn("Jazz could not load the local-first client; starting thin.", error);
|
|
160
248
|
return openThin(account);
|
|
161
249
|
}
|
|
162
|
-
|
|
163
|
-
inSession.add(account.id);
|
|
164
|
-
return client;
|
|
250
|
+
return openReplica(module.createClient, account);
|
|
165
251
|
}
|
|
166
252
|
return openThin(account);
|
|
167
253
|
};
|
|
168
254
|
session = await createJazzSessionOwner({
|
|
169
255
|
accounts,
|
|
170
|
-
initial,
|
|
256
|
+
initial: coreInitial(initial),
|
|
171
257
|
// A memory-only client has no storage to wipe.
|
|
172
258
|
clearOnSignOut: wipesOnSignOut,
|
|
259
|
+
...(replicas
|
|
260
|
+
? {
|
|
261
|
+
wipeSignedOut,
|
|
262
|
+
// A thin tab holds no store: any hold is another tab's.
|
|
263
|
+
storeHeldElsewhere: (account) => replicas.heldByATab(account.id),
|
|
264
|
+
}
|
|
265
|
+
: {}),
|
|
173
266
|
openClient,
|
|
174
267
|
decorate: followUser({
|
|
175
268
|
registry,
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
269
|
+
// Checks and the sync connection's renewals may both refresh the
|
|
270
|
+
// app's session: one lock for both, so its cookie rotates once.
|
|
271
|
+
events: browserBackendWatchEvents(`jazz-account:${registry}`, sessionRefreshLockName(registry)),
|
|
272
|
+
linkGuest: linkDeviceAccountOnSignUp,
|
|
273
|
+
forgotten: (account) => accountForgotten(accounts, account.id),
|
|
274
|
+
watchAccounts: (changed) => watchStoredSelection(accounts, changed),
|
|
275
|
+
// Ask "who is signed in" the way sign-in asks: through the app's own
|
|
276
|
+
// `fetch` when it gives one, and with its bearer when it has no cookies.
|
|
277
|
+
...(bearer
|
|
278
|
+
? { fetch: bearerFetch(bearer, config.fetch) }
|
|
279
|
+
: config.fetch
|
|
280
|
+
? { fetch: config.fetch }
|
|
281
|
+
: {}),
|
|
282
|
+
onSignedOut,
|
|
180
283
|
}),
|
|
181
284
|
});
|
|
182
285
|
if (loadLocalFirst)
|
|
183
286
|
upgradeInBackground(session, loadLocalFirst);
|
|
184
|
-
if (
|
|
185
|
-
|
|
186
|
-
const following = session;
|
|
187
|
-
// Signed out in this page: the session wiped the replica as it did.
|
|
188
|
-
following.subscribe(() => {
|
|
189
|
-
const { status, account } = following.getSnapshot();
|
|
190
|
-
if (status !== "ready" && status !== "signed-out")
|
|
191
|
-
return;
|
|
192
|
-
for (const id of inSession) {
|
|
193
|
-
if (id === account?.id)
|
|
194
|
-
continue;
|
|
195
|
-
inSession.delete(id);
|
|
196
|
-
signedOutHere.add(id);
|
|
197
|
-
forgetSignedOut(id);
|
|
198
|
-
}
|
|
199
|
-
});
|
|
200
|
-
const stillLeftBehind = (account) => following.getSnapshot().status !== "closed" &&
|
|
201
|
-
!opening.has(account) &&
|
|
202
|
-
following.getSnapshot().account?.id !== account;
|
|
203
|
-
const wipe = async (owner, signal) => {
|
|
204
|
-
const remembered = await createAccountManagerWithMinter({ ...config, serverUrl, store: rememberedUserStore(owner) }, mintLocalFirstTokenInJs);
|
|
205
|
-
const account = remembered.getLoggedIn();
|
|
206
|
-
if (!account)
|
|
207
|
-
throw new Error("Jazz could not reopen the signed-out user to wipe");
|
|
208
|
-
const { createClient } = await loadLocalFirst();
|
|
209
|
-
return whileNoTabHolds(registry, owner.account, async () => {
|
|
210
|
-
// Checked and claimed in one step: an open of this account from now
|
|
211
|
-
// on waits for the wipe.
|
|
212
|
-
if (!stillLeftBehind(owner.account))
|
|
213
|
-
throw new Error("signed in again");
|
|
214
|
-
let deleting = false;
|
|
215
|
-
const run = (async () => {
|
|
216
|
-
// Its socket carries another user's cookie (or none), so the
|
|
217
|
-
// backend refuses it: nothing of this replica uploads.
|
|
218
|
-
const client = await openLocalFirst(createClient, account);
|
|
219
|
-
try {
|
|
220
|
-
// Given up on while it opened: leave the replica for a later load.
|
|
221
|
-
if (signal.aborted)
|
|
222
|
-
return;
|
|
223
|
-
deleting = true;
|
|
224
|
-
await client.db.deleteClientStorage();
|
|
225
|
-
}
|
|
226
|
-
finally {
|
|
227
|
-
await client.shutdown();
|
|
228
|
-
}
|
|
229
|
-
record.forget(owner.account);
|
|
230
|
-
})();
|
|
231
|
-
wiping.set(owner.account, run);
|
|
232
|
-
// Given up on before its delete began: let go of the lock and the
|
|
233
|
-
// account at once, so an open of it doesn't wait on an open that
|
|
234
|
-
// hangs. A delete that began is waited for, however long it takes:
|
|
235
|
-
// an open of the account meanwhile would get half-wiped storage.
|
|
236
|
-
const givenUp = new Promise((resolve) => {
|
|
237
|
-
const giveUp = () => {
|
|
238
|
-
if (!deleting)
|
|
239
|
-
resolve();
|
|
240
|
-
};
|
|
241
|
-
if (signal.aborted)
|
|
242
|
-
giveUp();
|
|
243
|
-
signal.addEventListener("abort", giveUp, { once: true });
|
|
244
|
-
});
|
|
245
|
-
try {
|
|
246
|
-
await Promise.race([run, givenUp]);
|
|
247
|
-
}
|
|
248
|
-
finally {
|
|
249
|
-
wiping.delete(owner.account);
|
|
250
|
-
}
|
|
251
|
-
}).catch((error) => {
|
|
252
|
-
if (error instanceof Error && error.message === "signed in again")
|
|
253
|
-
return false;
|
|
254
|
-
throw error;
|
|
255
|
-
});
|
|
256
|
-
};
|
|
257
|
-
// Signed out where an earlier page didn't see it (on the server, or
|
|
258
|
-
// another user signed in through the app): wipe what it left, once the
|
|
259
|
-
// session has followed the backend.
|
|
260
|
-
void backendAnswered(following)
|
|
261
|
-
.then(() => settledSession(following))
|
|
262
|
-
.then(() => wipeLeftBehindReplicas({
|
|
263
|
-
record,
|
|
264
|
-
current: () => following.getSnapshot().account?.id,
|
|
265
|
-
signedIn: () => {
|
|
266
|
-
const identity = following.getSnapshot().account?.identity;
|
|
267
|
-
return identity !== undefined && identity.issuer !== LOCAL_FIRST_ISSUER;
|
|
268
|
-
},
|
|
269
|
-
confirmSignedOut: async () => {
|
|
270
|
-
await new Promise((resolve) => setTimeout(resolve, CONFIRM_SIGNED_OUT_MS));
|
|
271
|
-
return (await signedInIdentity(registry, config.fetch)) === null;
|
|
272
|
-
},
|
|
273
|
-
stillLeftBehind,
|
|
274
|
-
wipe,
|
|
275
|
-
}));
|
|
276
|
-
}
|
|
287
|
+
if (replicas)
|
|
288
|
+
watchReplicas(session, replicas);
|
|
277
289
|
await firstBackendAnswer(session);
|
|
278
290
|
return session;
|
|
279
291
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
292
|
+
/**
|
|
293
|
+
* Run `replicas.reconcile()` (wipe what signed-out users left on this
|
|
294
|
+
* device) once the session has followed the backend's first answer, and
|
|
295
|
+
* again whenever something may have changed: the session settles after a
|
|
296
|
+
* transition, another tab changes the ledger, or the page becomes visible.
|
|
297
|
+
* Nothing polls.
|
|
298
|
+
*/
|
|
299
|
+
function watchReplicas(session, replicas) {
|
|
300
|
+
let started = false;
|
|
301
|
+
let lastStatus;
|
|
302
|
+
const reconcile = () => {
|
|
303
|
+
if (!started || session.getSnapshot().status === "closed")
|
|
304
|
+
return;
|
|
305
|
+
void replicas.reconcile();
|
|
306
|
+
};
|
|
307
|
+
const onStorage = (event) => {
|
|
308
|
+
if (event.key === null ||
|
|
309
|
+
event.key.startsWith(replicas.ledger.prefix) ||
|
|
310
|
+
event.key === replicas.ledger.legacyKey)
|
|
311
|
+
reconcile();
|
|
312
|
+
};
|
|
313
|
+
const onVisibility = () => {
|
|
314
|
+
if (globalThis.document?.visibilityState === "visible")
|
|
315
|
+
reconcile();
|
|
316
|
+
};
|
|
317
|
+
globalThis.addEventListener?.("storage", onStorage);
|
|
318
|
+
globalThis.document?.addEventListener?.("visibilitychange", onVisibility);
|
|
319
|
+
const unsubscribe = session.subscribe(() => {
|
|
320
|
+
const { status } = session.getSnapshot();
|
|
321
|
+
if (status === "closed") {
|
|
322
|
+
unsubscribe();
|
|
323
|
+
globalThis.removeEventListener?.("storage", onStorage);
|
|
324
|
+
globalThis.document?.removeEventListener?.("visibilitychange", onVisibility);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const settled = status === "ready" || status === "signed-out";
|
|
328
|
+
if (settled && status !== lastStatus)
|
|
329
|
+
reconcile();
|
|
330
|
+
lastStatus = status;
|
|
331
|
+
});
|
|
332
|
+
void backendAnswered(session)
|
|
333
|
+
.then(() => settledSession(session))
|
|
334
|
+
.then(() => {
|
|
335
|
+
started = true;
|
|
336
|
+
lastStatus = session.getSnapshot().status;
|
|
337
|
+
reconcile();
|
|
338
|
+
});
|
|
339
|
+
}
|
|
283
340
|
/** Resolves once `session` is ready or signed out. */
|
|
284
341
|
function settledSession(session) {
|
|
285
342
|
return new Promise((resolve) => {
|
|
@@ -296,23 +353,6 @@ function settledSession(session) {
|
|
|
296
353
|
stop = session.subscribe(() => void check());
|
|
297
354
|
});
|
|
298
355
|
}
|
|
299
|
-
/** An account store holding `owner` as the remembered backend user, and nothing else. */
|
|
300
|
-
function rememberedUserStore(owner) {
|
|
301
|
-
let stored = JSON.stringify({
|
|
302
|
-
format: "jazz-account-selection-v1",
|
|
303
|
-
roots: [],
|
|
304
|
-
selected: null,
|
|
305
|
-
backendUser: { format: "jazz-backend-user-v1", ...owner, claims: {} },
|
|
306
|
-
});
|
|
307
|
-
return {
|
|
308
|
-
async read() {
|
|
309
|
-
return stored;
|
|
310
|
-
},
|
|
311
|
-
async update(transform) {
|
|
312
|
-
stored = transform(stored);
|
|
313
|
-
},
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
356
|
const upgradesInPlace = new WeakMap();
|
|
317
357
|
/**
|
|
318
358
|
* The session's client while it is thin, and after it upgrades: the upgrade
|
|
@@ -352,12 +392,12 @@ function upgradableClient(thin) {
|
|
|
352
392
|
* client straight away, on this browser's local-first account.
|
|
353
393
|
*/
|
|
354
394
|
async function createDeviceOnlySession(config) {
|
|
355
|
-
const { initial, clearOnSignOut,
|
|
395
|
+
const { initial, clearOnSignOut, linkDeviceAccountOnSignUp: _linkDeviceAccountOnSignUp, localFirst: _localFirst, onSignedOut: _onSignedOut, client: loadLocalFirst, store: _store, fetch: _fetch, ...rest } = config;
|
|
356
396
|
if (!loadLocalFirst) {
|
|
357
397
|
throw new Error('serverUrl: null keeps Jazz on this device, which needs the local-first client: pass client: () => import("jazz-tools/local-first")');
|
|
358
398
|
}
|
|
359
|
-
if (initial
|
|
360
|
-
throw new Error('serverUrl: null has no backend to sign in through, so it always opens this device\'s
|
|
399
|
+
if (coreInitial(initial) === "signed-out") {
|
|
400
|
+
throw new Error('serverUrl: null has no backend to sign in through, so it always opens this device\'s device account: leave out initial or set it to "device"');
|
|
361
401
|
}
|
|
362
402
|
const { serverUrl: _serverUrl, ...clientConfig } = rest;
|
|
363
403
|
refuseUnkeptOptions(clientConfig);
|
|
@@ -445,4 +485,13 @@ function localFirstMemory(registry) {
|
|
|
445
485
|
},
|
|
446
486
|
};
|
|
447
487
|
}
|
|
488
|
+
/** `localFirst`, checked: a timing the session can't honour fails by name. */
|
|
489
|
+
function refuseLocalFirstTiming(localFirst, loader) {
|
|
490
|
+
if (localFirst === undefined || localFirst === "background")
|
|
491
|
+
return;
|
|
492
|
+
if (localFirst !== "now")
|
|
493
|
+
throw new Error(`Unknown localFirst ${JSON.stringify(localFirst)}; expected "now" or "background"`);
|
|
494
|
+
if (!loader)
|
|
495
|
+
throw new Error('localFirst: "now" opens the local-first client, which needs the `client` loader: pass client: () => import("jazz-tools/local-first")');
|
|
496
|
+
}
|
|
448
497
|
//# sourceMappingURL=create-jazz-session.js.map
|