everything-dev 1.53.2 → 2.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -11
- package/dist/_virtual/_rolldown/runtime.cjs +17 -2
- package/dist/_virtual/_rolldown/runtime.mjs +36 -0
- package/dist/api/auth-middleware.cjs +161 -0
- package/dist/api/auth-middleware.cjs.map +1 -0
- package/dist/api/auth-middleware.d.cts +69 -0
- package/dist/api/auth-middleware.d.mts +69 -0
- package/dist/api/auth-middleware.mjs +160 -0
- package/dist/api/auth-middleware.mjs.map +1 -0
- package/dist/api-contract.cjs +250 -62
- package/dist/api-contract.cjs.map +1 -1
- package/dist/api-contract.mjs +246 -65
- package/dist/api-contract.mjs.map +1 -1
- package/dist/app.cjs +99 -26
- package/dist/app.cjs.map +1 -1
- package/dist/app.d.cts +3 -0
- package/dist/app.d.mts +3 -0
- package/dist/app.mjs +100 -27
- package/dist/app.mjs.map +1 -1
- package/dist/auth-login.cjs +163 -0
- package/dist/auth-login.cjs.map +1 -0
- package/dist/auth-login.mjs +162 -0
- package/dist/auth-login.mjs.map +1 -0
- package/dist/auth-session.cjs +64 -0
- package/dist/auth-session.cjs.map +1 -0
- package/dist/auth-session.mjs +58 -0
- package/dist/auth-session.mjs.map +1 -0
- package/dist/auth-types-gen.cjs +0 -1
- package/dist/auth-types-gen.cjs.map +1 -1
- package/dist/build.cjs +37 -173
- package/dist/build.cjs.map +1 -1
- package/dist/build.mjs +37 -171
- package/dist/build.mjs.map +1 -1
- package/dist/bundle-cache.cjs +74 -0
- package/dist/bundle-cache.cjs.map +1 -0
- package/dist/bundle-cache.d.cts +27 -0
- package/dist/bundle-cache.d.mts +27 -0
- package/dist/bundle-cache.mjs +68 -0
- package/dist/bundle-cache.mjs.map +1 -0
- package/dist/bundle-fs-resolve.cjs +209 -0
- package/dist/bundle-fs-resolve.cjs.map +1 -0
- package/dist/bundle-fs-resolve.d.cts +76 -0
- package/dist/bundle-fs-resolve.d.mts +76 -0
- package/dist/bundle-fs-resolve.mjs +202 -0
- package/dist/bundle-fs-resolve.mjs.map +1 -0
- package/dist/cdn-deploy.cjs +126 -0
- package/dist/cdn-deploy.cjs.map +1 -0
- package/dist/cdn-deploy.mjs +124 -0
- package/dist/cdn-deploy.mjs.map +1 -0
- package/dist/cli/db-doctor.cjs +19 -19
- package/dist/cli/db-doctor.cjs.map +1 -1
- package/dist/cli/db-doctor.mjs +18 -18
- package/dist/cli/db-doctor.mjs.map +1 -1
- package/dist/cli/db-repair.cjs +9 -32
- package/dist/cli/db-repair.cjs.map +1 -1
- package/dist/cli/db-repair.mjs +9 -32
- package/dist/cli/db-repair.mjs.map +1 -1
- package/dist/cli/framework-version.cjs +7 -3
- package/dist/cli/framework-version.cjs.map +1 -1
- package/dist/cli/framework-version.mjs +7 -3
- package/dist/cli/framework-version.mjs.map +1 -1
- package/dist/cli/infra.cjs +159 -251
- package/dist/cli/infra.cjs.map +1 -1
- package/dist/cli/infra.mjs +154 -242
- package/dist/cli/infra.mjs.map +1 -1
- package/dist/cli/init.cjs +627 -199
- package/dist/cli/init.cjs.map +1 -1
- package/dist/cli/init.d.cts +61 -8
- package/dist/cli/init.d.mts +61 -8
- package/dist/cli/init.mjs +616 -197
- package/dist/cli/init.mjs.map +1 -1
- package/dist/cli/parse.cjs +8 -7
- package/dist/cli/parse.cjs.map +1 -1
- package/dist/cli/parse.mjs +9 -7
- package/dist/cli/parse.mjs.map +1 -1
- package/dist/cli/prompts.cjs +14 -1
- package/dist/cli/prompts.cjs.map +1 -1
- package/dist/cli/prompts.mjs +14 -1
- package/dist/cli/prompts.mjs.map +1 -1
- package/dist/cli/prune.cjs +220 -0
- package/dist/cli/prune.cjs.map +1 -0
- package/dist/cli/prune.mjs +220 -0
- package/dist/cli/prune.mjs.map +1 -0
- package/dist/cli/snapshot.cjs +2 -1
- package/dist/cli/snapshot.cjs.map +1 -1
- package/dist/cli/snapshot.mjs +2 -1
- package/dist/cli/snapshot.mjs.map +1 -1
- package/dist/cli/status.cjs +5 -4
- package/dist/cli/status.cjs.map +1 -1
- package/dist/cli/status.mjs +6 -5
- package/dist/cli/status.mjs.map +1 -1
- package/dist/cli/sync.cjs +156 -58
- package/dist/cli/sync.cjs.map +1 -1
- package/dist/cli/sync.mjs +158 -63
- package/dist/cli/sync.mjs.map +1 -1
- package/dist/cli/timing.cjs +0 -1
- package/dist/cli/timing.cjs.map +1 -1
- package/dist/cli/upgrade.cjs +95 -69
- package/dist/cli/upgrade.cjs.map +1 -1
- package/dist/cli/upgrade.mjs +97 -72
- package/dist/cli/upgrade.mjs.map +1 -1
- package/dist/cli/utils/helpers.cjs.map +1 -1
- package/dist/cli.cjs +320 -72
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.mjs +316 -68
- package/dist/cli.mjs.map +1 -1
- package/dist/code-artifacts.cjs +76 -8
- package/dist/code-artifacts.cjs.map +1 -1
- package/dist/code-artifacts.mjs +76 -10
- package/dist/code-artifacts.mjs.map +1 -1
- package/dist/commands/build.cjs +65 -0
- package/dist/commands/build.cjs.map +1 -0
- package/dist/commands/build.mjs +65 -0
- package/dist/commands/build.mjs.map +1 -0
- package/dist/commands/config.cjs +77 -0
- package/dist/commands/config.cjs.map +1 -0
- package/dist/commands/config.d.cts +8 -0
- package/dist/commands/config.d.mts +8 -0
- package/dist/commands/config.mjs +74 -0
- package/dist/commands/config.mjs.map +1 -0
- package/dist/commands/db.cjs +107 -0
- package/dist/commands/db.cjs.map +1 -0
- package/dist/commands/db.mjs +107 -0
- package/dist/commands/db.mjs.map +1 -0
- package/dist/commands/deploy.cjs +336 -0
- package/dist/commands/deploy.cjs.map +1 -0
- package/dist/commands/deploy.mjs +334 -0
- package/dist/commands/deploy.mjs.map +1 -0
- package/dist/commands/dev.cjs +75 -0
- package/dist/commands/dev.cjs.map +1 -0
- package/dist/commands/dev.mjs +73 -0
- package/dist/commands/dev.mjs.map +1 -0
- package/dist/commands/init.cjs +234 -0
- package/dist/commands/init.cjs.map +1 -0
- package/dist/commands/init.mjs +231 -0
- package/dist/commands/init.mjs.map +1 -0
- package/dist/commands/keys.cjs +255 -0
- package/dist/commands/keys.cjs.map +1 -0
- package/dist/commands/keys.mjs +253 -0
- package/dist/commands/keys.mjs.map +1 -0
- package/dist/commands/ops.cjs +199 -0
- package/dist/commands/ops.cjs.map +1 -0
- package/dist/commands/ops.mjs +197 -0
- package/dist/commands/ops.mjs.map +1 -0
- package/dist/commands/plugins.cjs +211 -0
- package/dist/commands/plugins.cjs.map +1 -0
- package/dist/commands/plugins.mjs +211 -0
- package/dist/commands/plugins.mjs.map +1 -0
- package/dist/commands/shared.cjs +8 -0
- package/dist/commands/shared.cjs.map +1 -0
- package/dist/commands/shared.d.cts +6 -0
- package/dist/commands/shared.d.mts +6 -0
- package/dist/commands/shared.mjs +8 -0
- package/dist/commands/shared.mjs.map +1 -0
- package/dist/commands/upgrade.cjs +325 -0
- package/dist/commands/upgrade.cjs.map +1 -0
- package/dist/commands/upgrade.mjs +323 -0
- package/dist/commands/upgrade.mjs.map +1 -0
- package/dist/components/dev-render.cjs +340 -0
- package/dist/components/dev-render.cjs.map +1 -0
- package/dist/components/dev-render.mjs +332 -0
- package/dist/components/dev-render.mjs.map +1 -0
- package/dist/config.cjs +460 -221
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +491 -48
- package/dist/config.d.mts +491 -48
- package/dist/config.mjs +439 -212
- package/dist/config.mjs.map +1 -1
- package/dist/contract.cjs +327 -50
- package/dist/contract.cjs.map +1 -1
- package/dist/contract.d.cts +1951 -1062
- package/dist/contract.d.mts +1951 -1062
- package/dist/contract.meta.cjs +107 -12
- package/dist/contract.meta.cjs.map +1 -1
- package/dist/contract.meta.d.cts +166 -8
- package/dist/contract.meta.d.mts +166 -8
- package/dist/contract.meta.mjs +107 -11
- package/dist/contract.meta.mjs.map +1 -1
- package/dist/contract.mjs +580 -327
- package/dist/contract.mjs.map +1 -1
- package/dist/dag.cjs +5 -3
- package/dist/dag.cjs.map +1 -1
- package/dist/dag.mjs +6 -3
- package/dist/dag.mjs.map +1 -1
- package/dist/db/binding.cjs +80 -0
- package/dist/db/binding.cjs.map +1 -0
- package/dist/db/binding.d.cts +39 -0
- package/dist/db/binding.d.mts +39 -0
- package/dist/db/binding.mjs +78 -0
- package/dist/db/binding.mjs.map +1 -0
- package/dist/db/bindings.cjs +78 -0
- package/dist/db/bindings.cjs.map +1 -0
- package/dist/db/bindings.d.cts +34 -0
- package/dist/db/bindings.d.mts +34 -0
- package/dist/db/bindings.mjs +76 -0
- package/dist/db/bindings.mjs.map +1 -0
- package/dist/db/core.cjs +204 -0
- package/dist/db/core.cjs.map +1 -0
- package/dist/db/core.d.cts +69 -0
- package/dist/db/core.d.mts +69 -0
- package/dist/db/core.mjs +192 -0
- package/dist/db/core.mjs.map +1 -0
- package/dist/db/driver.cjs +167 -0
- package/dist/db/driver.cjs.map +1 -0
- package/dist/db/driver.d.cts +50 -0
- package/dist/db/driver.d.mts +50 -0
- package/dist/db/driver.mjs +165 -0
- package/dist/db/driver.mjs.map +1 -0
- package/dist/db/drizzle-kit.cjs +177 -0
- package/dist/db/drizzle-kit.cjs.map +1 -0
- package/dist/db/drizzle-kit.d.cts +25 -0
- package/dist/db/drizzle-kit.d.mts +25 -0
- package/dist/db/drizzle-kit.mjs +175 -0
- package/dist/db/drizzle-kit.mjs.map +1 -0
- package/dist/db/errors.cjs +27 -0
- package/dist/db/errors.cjs.map +1 -0
- package/dist/db/errors.d.cts +16 -0
- package/dist/db/errors.d.mts +16 -0
- package/dist/db/errors.mjs +26 -0
- package/dist/db/errors.mjs.map +1 -0
- package/dist/db/identity.cjs +55 -0
- package/dist/db/identity.cjs.map +1 -0
- package/dist/db/identity.d.cts +40 -0
- package/dist/db/identity.d.mts +40 -0
- package/dist/db/identity.mjs +53 -0
- package/dist/db/identity.mjs.map +1 -0
- package/dist/db/index.cjs +43 -0
- package/dist/db/index.d.cts +9 -0
- package/dist/db/index.d.mts +9 -0
- package/dist/db/index.mjs +10 -0
- package/dist/db/run-migrations.cjs +343 -0
- package/dist/db/run-migrations.cjs.map +1 -0
- package/dist/db/run-migrations.d.cts +87 -0
- package/dist/db/run-migrations.d.mts +87 -0
- package/dist/db/run-migrations.mjs +341 -0
- package/dist/db/run-migrations.mjs.map +1 -0
- package/dist/delegate-signer.cjs +85 -0
- package/dist/delegate-signer.cjs.map +1 -0
- package/dist/delegate-signer.mjs +84 -0
- package/dist/delegate-signer.mjs.map +1 -0
- package/dist/deploy-diff.cjs +119 -0
- package/dist/deploy-diff.cjs.map +1 -0
- package/dist/deploy-diff.mjs +109 -0
- package/dist/deploy-diff.mjs.map +1 -0
- package/dist/descriptor/constructors.cjs +49 -0
- package/dist/descriptor/constructors.cjs.map +1 -0
- package/dist/descriptor/constructors.d.cts +27 -0
- package/dist/descriptor/constructors.d.mts +27 -0
- package/dist/descriptor/constructors.mjs +45 -0
- package/dist/descriptor/constructors.mjs.map +1 -0
- package/dist/descriptor/index.cjs +24 -0
- package/dist/descriptor/index.d.cts +5 -0
- package/dist/descriptor/index.d.mts +5 -0
- package/dist/descriptor/index.mjs +6 -0
- package/dist/descriptor/resolve.cjs +258 -0
- package/dist/descriptor/resolve.cjs.map +1 -0
- package/dist/descriptor/resolve.d.cts +50 -0
- package/dist/descriptor/resolve.d.mts +50 -0
- package/dist/descriptor/resolve.mjs +252 -0
- package/dist/descriptor/resolve.mjs.map +1 -0
- package/dist/descriptor/schema.cjs +109 -0
- package/dist/descriptor/schema.cjs.map +1 -0
- package/dist/descriptor/schema.d.cts +217 -0
- package/dist/descriptor/schema.d.mts +217 -0
- package/dist/descriptor/schema.mjs +102 -0
- package/dist/descriptor/schema.mjs.map +1 -0
- package/dist/descriptor/serialize.cjs +45 -0
- package/dist/descriptor/serialize.cjs.map +1 -0
- package/dist/descriptor/serialize.d.cts +7 -0
- package/dist/descriptor/serialize.d.mts +7 -0
- package/dist/descriptor/serialize.mjs +45 -0
- package/dist/descriptor/serialize.mjs.map +1 -0
- package/dist/dev-log-pipeline.cjs +273 -0
- package/dist/dev-log-pipeline.cjs.map +1 -0
- package/dist/dev-log-pipeline.mjs +267 -0
- package/dist/dev-log-pipeline.mjs.map +1 -0
- package/dist/dev-logs.cjs +39 -8
- package/dist/dev-logs.cjs.map +1 -1
- package/dist/dev-logs.mjs +37 -9
- package/dist/dev-logs.mjs.map +1 -1
- package/dist/dev-program.cjs +405 -0
- package/dist/dev-program.cjs.map +1 -0
- package/dist/dev-program.d.cts +10 -0
- package/dist/dev-program.d.mts +10 -0
- package/dist/dev-program.mjs +395 -0
- package/dist/dev-program.mjs.map +1 -0
- package/dist/dev-session-data.d.cts +27 -0
- package/dist/dev-session-data.d.mts +27 -0
- package/dist/dev-session.cjs +178 -105
- package/dist/dev-session.cjs.map +1 -1
- package/dist/dev-session.mjs +180 -105
- package/dist/dev-session.mjs.map +1 -1
- package/dist/env/process-env.cjs +16 -0
- package/dist/env/process-env.cjs.map +1 -0
- package/dist/env/process-env.mjs +13 -0
- package/dist/env/process-env.mjs.map +1 -0
- package/dist/env/project-env.cjs +144 -0
- package/dist/env/project-env.cjs.map +1 -0
- package/dist/env/project-env.d.cts +1 -0
- package/dist/env/project-env.d.mts +1 -0
- package/dist/env/project-env.mjs +132 -0
- package/dist/env/project-env.mjs.map +1 -0
- package/dist/fastkv.cjs +59 -12
- package/dist/fastkv.cjs.map +1 -1
- package/dist/fastkv.d.cts +42 -6
- package/dist/fastkv.d.mts +42 -6
- package/dist/fastkv.mjs +58 -13
- package/dist/fastkv.mjs.map +1 -1
- package/dist/fingerprint.cjs +57 -0
- package/dist/fingerprint.cjs.map +1 -0
- package/dist/fingerprint.d.cts +14 -0
- package/dist/fingerprint.d.mts +14 -0
- package/dist/fingerprint.mjs +55 -0
- package/dist/fingerprint.mjs.map +1 -0
- package/dist/http-client.cjs +17 -17
- package/dist/http-client.cjs.map +1 -1
- package/dist/http-client.mjs +17 -17
- package/dist/http-client.mjs.map +1 -1
- package/dist/image-deploy.cjs +186 -0
- package/dist/image-deploy.cjs.map +1 -0
- package/dist/image-deploy.mjs +182 -0
- package/dist/image-deploy.mjs.map +1 -0
- package/dist/index.cjs +66 -18
- package/dist/index.d.cts +8 -7
- package/dist/index.d.mts +8 -7
- package/dist/index.mjs +6 -5
- package/dist/infra/docker.cjs +77 -0
- package/dist/infra/docker.cjs.map +1 -0
- package/dist/infra/docker.d.cts +10 -0
- package/dist/infra/docker.d.mts +10 -0
- package/dist/infra/docker.mjs +69 -0
- package/dist/infra/docker.mjs.map +1 -0
- package/dist/infra/materializer.cjs +74 -0
- package/dist/infra/materializer.cjs.map +1 -0
- package/dist/infra/materializer.mjs +70 -0
- package/dist/infra/materializer.mjs.map +1 -0
- package/dist/infra/planner.cjs +135 -103
- package/dist/infra/planner.cjs.map +1 -1
- package/dist/infra/planner.mjs +137 -104
- package/dist/infra/planner.mjs.map +1 -1
- package/dist/infra/port-ownership.cjs +57 -0
- package/dist/infra/port-ownership.cjs.map +1 -0
- package/dist/infra/port-ownership.mjs +57 -0
- package/dist/infra/port-ownership.mjs.map +1 -0
- package/dist/infra/preflight.cjs +45 -33
- package/dist/infra/preflight.cjs.map +1 -1
- package/dist/infra/preflight.d.cts +1 -0
- package/dist/infra/preflight.d.mts +1 -0
- package/dist/infra/preflight.mjs +46 -34
- package/dist/infra/preflight.mjs.map +1 -1
- package/dist/infra/types.cjs.map +1 -1
- package/dist/infra/types.d.cts +2 -0
- package/dist/infra/types.d.mts +2 -0
- package/dist/infra/types.mjs.map +1 -1
- package/dist/integrity.cjs +50 -61
- package/dist/integrity.cjs.map +1 -1
- package/dist/integrity.d.cts +16 -10
- package/dist/integrity.d.mts +16 -10
- package/dist/integrity.mjs +50 -59
- package/dist/integrity.mjs.map +1 -1
- package/dist/internal/manifest-normalizer.cjs +8 -2
- package/dist/internal/manifest-normalizer.cjs.map +1 -1
- package/dist/internal/manifest-normalizer.mjs +9 -3
- package/dist/internal/manifest-normalizer.mjs.map +1 -1
- package/dist/merge.cjs +19 -1
- package/dist/merge.cjs.map +1 -1
- package/dist/merge.d.cts +1 -1
- package/dist/merge.d.mts +1 -1
- package/dist/merge.mjs +19 -2
- package/dist/merge.mjs.map +1 -1
- package/dist/mf.cjs +190 -3
- package/dist/mf.cjs.map +1 -1
- package/dist/mf.d.cts +24 -2
- package/dist/mf.d.mts +24 -2
- package/dist/mf.mjs +189 -4
- package/dist/mf.mjs.map +1 -1
- package/dist/near-cli.cjs +59 -91
- package/dist/near-cli.cjs.map +1 -1
- package/dist/near-cli.mjs +58 -90
- package/dist/near-cli.mjs.map +1 -1
- package/dist/near-signer.cjs +73 -0
- package/dist/near-signer.cjs.map +1 -0
- package/dist/near-signer.mjs +70 -0
- package/dist/near-signer.mjs.map +1 -0
- package/dist/network.cjs +0 -1
- package/dist/network.cjs.map +1 -1
- package/dist/orchestrator.cjs +256 -87
- package/dist/orchestrator.cjs.map +1 -1
- package/dist/orchestrator.mjs +248 -87
- package/dist/orchestrator.mjs.map +1 -1
- package/dist/platform-deploy.cjs +81 -0
- package/dist/platform-deploy.cjs.map +1 -0
- package/dist/platform-deploy.mjs +80 -0
- package/dist/platform-deploy.mjs.map +1 -0
- package/dist/plugin.cjs +54 -1389
- package/dist/plugin.cjs.map +1 -1
- package/dist/plugin.d.cts +6 -896
- package/dist/plugin.d.mts +6 -896
- package/dist/plugin.mjs +53 -1387
- package/dist/plugin.mjs.map +1 -1
- package/dist/process-kill.cjs +44 -0
- package/dist/process-kill.cjs.map +1 -0
- package/dist/process-kill.mjs +43 -0
- package/dist/process-kill.mjs.map +1 -0
- package/dist/process-registry.cjs +64 -9
- package/dist/process-registry.cjs.map +1 -1
- package/dist/process-registry.mjs +61 -10
- package/dist/process-registry.mjs.map +1 -1
- package/dist/progress.cjs +45 -0
- package/dist/progress.cjs.map +1 -0
- package/dist/progress.d.cts +13 -0
- package/dist/progress.d.mts +13 -0
- package/dist/progress.mjs +42 -0
- package/dist/progress.mjs.map +1 -0
- package/dist/publish.cjs +513 -79
- package/dist/publish.cjs.map +1 -1
- package/dist/publish.mjs +515 -82
- package/dist/publish.mjs.map +1 -1
- package/dist/registry-use.cjs +41 -0
- package/dist/registry-use.cjs.map +1 -0
- package/dist/registry-use.mjs +40 -0
- package/dist/registry-use.mjs.map +1 -0
- package/dist/resolution/session.cjs +335 -0
- package/dist/resolution/session.cjs.map +1 -0
- package/dist/resolution/session.d.cts +105 -0
- package/dist/resolution/session.d.mts +105 -0
- package/dist/resolution/session.mjs +331 -0
- package/dist/resolution/session.mjs.map +1 -0
- package/dist/rollback.cjs +131 -0
- package/dist/rollback.cjs.map +1 -0
- package/dist/rollback.mjs +128 -0
- package/dist/rollback.mjs.map +1 -0
- package/dist/sdk.cjs +7 -7
- package/dist/sdk.d.cts +3 -3
- package/dist/sdk.d.mts +3 -3
- package/dist/sdk.mjs +2 -2
- package/dist/service-descriptor.cjs +67 -34
- package/dist/service-descriptor.cjs.map +1 -1
- package/dist/service-descriptor.d.cts +4 -1
- package/dist/service-descriptor.d.mts +3 -0
- package/dist/service-descriptor.mjs +63 -35
- package/dist/service-descriptor.mjs.map +1 -1
- package/dist/shared-deps.cjs +17 -16
- package/dist/shared-deps.cjs.map +1 -1
- package/dist/shared-deps.mjs +17 -16
- package/dist/shared-deps.mjs.map +1 -1
- package/dist/start-config-source.cjs +24 -0
- package/dist/start-config-source.cjs.map +1 -0
- package/dist/start-config-source.d.cts +29 -0
- package/dist/start-config-source.d.mts +29 -0
- package/dist/start-config-source.mjs +22 -0
- package/dist/start-config-source.mjs.map +1 -0
- package/dist/storage-upload.cjs +145 -0
- package/dist/storage-upload.cjs.map +1 -0
- package/dist/storage-upload.mjs +143 -0
- package/dist/storage-upload.mjs.map +1 -0
- package/dist/types.cjs +126 -20
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +867 -585
- package/dist/types.d.mts +867 -585
- package/dist/types.mjs +307 -208
- package/dist/types.mjs.map +1 -1
- package/dist/ui/api.cjs +105 -0
- package/dist/ui/api.cjs.map +1 -0
- package/dist/ui/api.d.cts +31 -0
- package/dist/ui/api.d.mts +31 -0
- package/dist/ui/api.mjs +99 -0
- package/dist/ui/api.mjs.map +1 -0
- package/dist/ui/auth-guards.cjs +50 -0
- package/dist/ui/auth-guards.cjs.map +1 -0
- package/dist/ui/auth-guards.d.cts +39 -0
- package/dist/ui/auth-guards.d.mts +39 -0
- package/dist/ui/auth-guards.mjs +48 -0
- package/dist/ui/auth-guards.mjs.map +1 -0
- package/dist/ui/auth.cjs +197 -0
- package/dist/ui/auth.cjs.map +1 -0
- package/dist/ui/auth.d.cts +56 -0
- package/dist/ui/auth.d.mts +56 -0
- package/dist/ui/auth.mjs +179 -0
- package/dist/ui/auth.mjs.map +1 -0
- package/dist/ui/entry.cjs +16 -0
- package/dist/ui/entry.cjs.map +1 -0
- package/dist/ui/entry.d.cts +12 -0
- package/dist/ui/entry.d.mts +12 -0
- package/dist/ui/entry.mjs +15 -0
- package/dist/ui/entry.mjs.map +1 -0
- package/dist/ui/head.cjs +14 -7
- package/dist/ui/head.cjs.map +1 -1
- package/dist/ui/head.mjs +15 -7
- package/dist/ui/head.mjs.map +1 -1
- package/dist/ui/hydrate.cjs +265 -0
- package/dist/ui/hydrate.cjs.map +1 -0
- package/dist/ui/hydrate.d.cts +48 -0
- package/dist/ui/hydrate.d.mts +48 -0
- package/dist/ui/hydrate.mjs +263 -0
- package/dist/ui/hydrate.mjs.map +1 -0
- package/dist/ui/i18n.cjs +153 -0
- package/dist/ui/i18n.cjs.map +1 -0
- package/dist/ui/i18n.d.cts +29 -0
- package/dist/ui/i18n.d.mts +29 -0
- package/dist/ui/i18n.mjs +140 -0
- package/dist/ui/i18n.mjs.map +1 -0
- package/dist/ui/index.cjs +19 -1
- package/dist/ui/index.d.cts +6 -3
- package/dist/ui/index.d.mts +6 -3
- package/dist/ui/index.mjs +5 -2
- package/dist/ui/locale.cjs +53 -0
- package/dist/ui/locale.cjs.map +1 -0
- package/dist/ui/locale.d.cts +18 -0
- package/dist/ui/locale.d.mts +18 -0
- package/dist/ui/locale.mjs +49 -0
- package/dist/ui/locale.mjs.map +1 -0
- package/dist/ui/manifest/index.cjs +25 -0
- package/dist/ui/manifest/index.cjs.map +1 -0
- package/dist/ui/manifest/index.d.cts +9 -0
- package/dist/ui/manifest/index.d.mts +9 -0
- package/dist/ui/manifest/index.mjs +13 -0
- package/dist/ui/manifest/index.mjs.map +1 -0
- package/dist/ui/manifest-generator.cjs +8 -0
- package/dist/ui/manifest-generator.d.cts +1 -0
- package/dist/ui/manifest-generator.d.mts +1 -0
- package/dist/ui/manifest-generator.mjs +3 -0
- package/dist/ui/message-catalogs.cjs +8 -0
- package/dist/ui/message-catalogs.cjs.map +1 -0
- package/dist/ui/message-catalogs.d.cts +5 -0
- package/dist/ui/message-catalogs.d.mts +5 -0
- package/dist/ui/message-catalogs.mjs +8 -0
- package/dist/ui/message-catalogs.mjs.map +1 -0
- package/dist/ui/metadata.cjs +0 -1
- package/dist/ui/metadata.cjs.map +1 -1
- package/dist/ui/metadata.d.cts +1 -1
- package/dist/ui/metadata.d.mts +1 -1
- package/dist/ui/plugin-path.cjs +37 -0
- package/dist/ui/plugin-path.cjs.map +1 -0
- package/dist/ui/plugin-path.d.cts +25 -0
- package/dist/ui/plugin-path.d.mts +25 -0
- package/dist/ui/plugin-path.mjs +35 -0
- package/dist/ui/plugin-path.mjs.map +1 -0
- package/dist/ui/router-client.cjs +61 -0
- package/dist/ui/router-client.cjs.map +1 -0
- package/dist/ui/router-client.d.cts +20 -0
- package/dist/ui/router-client.d.mts +20 -0
- package/dist/ui/router-client.mjs +60 -0
- package/dist/ui/router-client.mjs.map +1 -0
- package/dist/ui/router-defaults.cjs +48 -0
- package/dist/ui/router-defaults.cjs.map +1 -0
- package/dist/ui/router-defaults.d.cts +8 -0
- package/dist/ui/router-defaults.d.mts +8 -0
- package/dist/ui/router-defaults.mjs +45 -0
- package/dist/ui/router-defaults.mjs.map +1 -0
- package/dist/ui/router-error.cjs +70 -0
- package/dist/ui/router-error.cjs.map +1 -0
- package/dist/ui/router-error.d.cts +19 -0
- package/dist/ui/router-error.d.mts +19 -0
- package/dist/ui/router-error.mjs +69 -0
- package/dist/ui/router-error.mjs.map +1 -0
- package/dist/ui/router-server.cjs +153 -0
- package/dist/ui/router-server.cjs.map +1 -0
- package/dist/ui/router-server.d.cts +38 -0
- package/dist/ui/router-server.d.mts +38 -0
- package/dist/ui/router-server.mjs +152 -0
- package/dist/ui/router-server.mjs.map +1 -0
- package/dist/ui/router.cjs +4 -16
- package/dist/ui/router.cjs.map +1 -1
- package/dist/ui/router.mjs +4 -15
- package/dist/ui/router.mjs.map +1 -1
- package/dist/ui/runtime.cjs +5 -1
- package/dist/ui/runtime.cjs.map +1 -1
- package/dist/ui/runtime.d.cts +2 -1
- package/dist/ui/runtime.d.mts +2 -1
- package/dist/ui/runtime.mjs +5 -1
- package/dist/ui/runtime.mjs.map +1 -1
- package/dist/ui/slot.cjs +34 -0
- package/dist/ui/slot.cjs.map +1 -0
- package/dist/ui/slot.d.cts +43 -0
- package/dist/ui/slot.d.mts +43 -0
- package/dist/ui/slot.mjs +34 -0
- package/dist/ui/slot.mjs.map +1 -0
- package/dist/ui/tenant.cjs +300 -0
- package/dist/ui/tenant.cjs.map +1 -0
- package/dist/ui/tenant.d.cts +122 -0
- package/dist/ui/tenant.d.mts +122 -0
- package/dist/ui/tenant.mjs +279 -0
- package/dist/ui/tenant.mjs.map +1 -0
- package/dist/ui/types.d.cts +32 -2
- package/dist/ui/types.d.mts +32 -2
- package/dist/ui/version-check.cjs +47 -0
- package/dist/ui/version-check.cjs.map +1 -0
- package/dist/ui/version-check.d.cts +23 -0
- package/dist/ui/version-check.d.mts +23 -0
- package/dist/ui/version-check.mjs +46 -0
- package/dist/ui/version-check.mjs.map +1 -0
- package/dist/utils/banner.cjs +2 -2
- package/dist/utils/banner.cjs.map +1 -1
- package/dist/utils/banner.mjs +2 -2
- package/dist/utils/banner.mjs.map +1 -1
- package/dist/utils/linkify.cjs +1 -1
- package/dist/utils/linkify.cjs.map +1 -1
- package/dist/utils/linkify.mjs +1 -0
- package/dist/utils/linkify.mjs.map +1 -1
- package/dist/utils/run.cjs +6 -6
- package/dist/utils/run.cjs.map +1 -1
- package/dist/utils/run.mjs +6 -6
- package/dist/utils/run.mjs.map +1 -1
- package/dist/utils/save-config.cjs +12 -0
- package/dist/utils/save-config.cjs.map +1 -1
- package/dist/utils/save-config.mjs +12 -0
- package/dist/utils/save-config.mjs.map +1 -1
- package/dist/utils/snapshot-hash.cjs +10 -0
- package/dist/utils/snapshot-hash.cjs.map +1 -0
- package/dist/utils/snapshot-hash.mjs +10 -0
- package/dist/utils/snapshot-hash.mjs.map +1 -0
- package/dist/utils/string.cjs +0 -1
- package/dist/utils/string.cjs.map +1 -1
- package/dist/utils/theme.cjs +30 -12
- package/dist/utils/theme.cjs.map +1 -1
- package/dist/utils/theme.mjs +30 -11
- package/dist/utils/theme.mjs.map +1 -1
- package/dist/version-manifest-deploy.cjs +50 -0
- package/dist/version-manifest-deploy.cjs.map +1 -0
- package/dist/version-manifest-deploy.mjs +49 -0
- package/dist/version-manifest-deploy.mjs.map +1 -0
- package/dist/version-manifest-resolve.cjs +42 -0
- package/dist/version-manifest-resolve.cjs.map +1 -0
- package/dist/version-manifest-resolve.d.cts +38 -0
- package/dist/version-manifest-resolve.d.mts +38 -0
- package/dist/version-manifest-resolve.mjs +40 -0
- package/dist/version-manifest-resolve.mjs.map +1 -0
- package/dist/version-status.cjs +18 -0
- package/dist/version-status.cjs.map +1 -0
- package/dist/version-status.d.cts +22 -0
- package/dist/version-status.d.mts +22 -0
- package/dist/version-status.mjs +17 -0
- package/dist/version-status.mjs.map +1 -0
- package/dist/workspace-catalog.cjs +53 -0
- package/dist/workspace-catalog.cjs.map +1 -0
- package/dist/workspace-catalog.mjs +51 -0
- package/dist/workspace-catalog.mjs.map +1 -0
- package/dist/workspace.cjs +237 -0
- package/dist/workspace.cjs.map +1 -0
- package/dist/workspace.mjs +233 -0
- package/dist/workspace.mjs.map +1 -0
- package/package.json +179 -27
- package/skills/add-a-route/SKILL.md +132 -0
- package/skills/api-and-auth/SKILL.md +87 -21
- package/skills/api-and-auth/references/middleware.md +1 -1
- package/skills/cli-reference/SKILL.md +48 -21
- package/skills/code-style/SKILL.md +8 -0
- package/skills/dev-workflow/SKILL.md +50 -26
- package/skills/extends-config/SKILL.md +31 -19
- package/skills/init-upgrade/SKILL.md +29 -16
- package/skills/plugin-development/SKILL.md +46 -112
- package/skills/plugin-development/references/database.md +82 -0
- package/skills/plugin-development/references/request-context.md +67 -0
- package/skills/publish-sync/SKILL.md +99 -22
- package/skills/registry/SKILL.md +82 -0
- package/skills/super-app/SKILL.md +25 -15
- package/skills/talk-to-the-app/SKILL.md +138 -0
- package/skills/ui-integration/SKILL.md +93 -11
- package/dist/cli/db-studio.cjs +0 -131
- package/dist/cli/db-studio.cjs.map +0 -1
- package/dist/cli/db-studio.mjs +0 -127
- package/dist/cli/db-studio.mjs.map +0 -1
- package/dist/cli/init.d.cts.map +0 -1
- package/dist/cli/init.d.mts.map +0 -1
- package/dist/components/dev-view.cjs +0 -309
- package/dist/components/dev-view.cjs.map +0 -1
- package/dist/components/dev-view.mjs +0 -309
- package/dist/components/dev-view.mjs.map +0 -1
- package/dist/components/streaming-view.cjs +0 -134
- package/dist/components/streaming-view.cjs.map +0 -1
- package/dist/components/streaming-view.mjs +0 -132
- package/dist/components/streaming-view.mjs.map +0 -1
- package/dist/config.d.cts.map +0 -1
- package/dist/config.d.mts.map +0 -1
- package/dist/contract.d.cts.map +0 -1
- package/dist/contract.d.mts.map +0 -1
- package/dist/contract.meta.d.cts.map +0 -1
- package/dist/contract.meta.d.mts.map +0 -1
- package/dist/dag.d.cts.map +0 -1
- package/dist/dag.d.mts.map +0 -1
- package/dist/db.cjs +0 -81
- package/dist/db.cjs.map +0 -1
- package/dist/db.d.cts +0 -30
- package/dist/db.d.cts.map +0 -1
- package/dist/db.d.mts +0 -30
- package/dist/db.d.mts.map +0 -1
- package/dist/db.mjs +0 -75
- package/dist/db.mjs.map +0 -1
- package/dist/fastkv.d.cts.map +0 -1
- package/dist/fastkv.d.mts.map +0 -1
- package/dist/integrity.d.cts.map +0 -1
- package/dist/integrity.d.mts.map +0 -1
- package/dist/merge.d.cts.map +0 -1
- package/dist/merge.d.mts.map +0 -1
- package/dist/mf.d.cts.map +0 -1
- package/dist/mf.d.mts.map +0 -1
- package/dist/plugin.d.cts.map +0 -1
- package/dist/plugin.d.mts.map +0 -1
- package/dist/service-descriptor.d.cts.map +0 -1
- package/dist/service-descriptor.d.mts.map +0 -1
- package/dist/types.d.cts.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/dist/ui/head.d.cts.map +0 -1
- package/dist/ui/head.d.mts.map +0 -1
- package/dist/ui/metadata.d.cts.map +0 -1
- package/dist/ui/metadata.d.mts.map +0 -1
- package/dist/ui/router.d.cts.map +0 -1
- package/dist/ui/router.d.mts.map +0 -1
- package/dist/ui/runtime.d.cts.map +0 -1
- package/dist/ui/runtime.d.mts.map +0 -1
- package/dist/ui/types.d.cts.map +0 -1
- package/dist/ui/types.d.mts.map +0 -1
package/dist/ui/auth.cjs
ADDED
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
const require_ui_runtime = require('./runtime.cjs');
|
|
3
|
+
const require_plugin_path = require('./plugin-path.cjs');
|
|
4
|
+
const require_auth_guards = require('./auth-guards.cjs');
|
|
5
|
+
let _tanstack_react_router = require("@tanstack/react-router");
|
|
6
|
+
let _better_auth_api_key_client = require("@better-auth/api-key/client");
|
|
7
|
+
let _better_auth_passkey_client = require("@better-auth/passkey/client");
|
|
8
|
+
let _tanstack_react_query = require("@tanstack/react-query");
|
|
9
|
+
let better_auth_client_plugins = require("better-auth/client/plugins");
|
|
10
|
+
let better_auth_react = require("better-auth/react");
|
|
11
|
+
let better_near_auth_client = require("better-near-auth/client");
|
|
12
|
+
|
|
13
|
+
//#region src/ui/auth.ts
|
|
14
|
+
function hasAuthVariables(auth) {
|
|
15
|
+
return !!auth && typeof auth === "object" && typeof auth.variables === "object";
|
|
16
|
+
}
|
|
17
|
+
function readRuntimeConfig(config) {
|
|
18
|
+
if (config) return config;
|
|
19
|
+
if (typeof window === "undefined") return void 0;
|
|
20
|
+
try {
|
|
21
|
+
return require_ui_runtime.getRuntimeConfig();
|
|
22
|
+
} catch {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function getAuthVariables(config) {
|
|
27
|
+
const runtimeConfig = readRuntimeConfig(config);
|
|
28
|
+
if (!runtimeConfig || !hasAuthVariables(runtimeConfig.auth)) throw new Error("Missing auth runtime configuration");
|
|
29
|
+
return runtimeConfig.auth.variables;
|
|
30
|
+
}
|
|
31
|
+
function getSiwnClientConfig(options) {
|
|
32
|
+
const runtimeConfig = readRuntimeConfig(options.runtimeConfig);
|
|
33
|
+
const siwn = getAuthVariables(options.runtimeConfig).siwn;
|
|
34
|
+
const mainnetRecipient = siwn.recipients?.mainnet ?? siwn.recipient;
|
|
35
|
+
if (!mainnetRecipient) throw new Error("Missing auth SIWN recipient");
|
|
36
|
+
const networkId = runtimeConfig?.networkId ?? (mainnetRecipient.endsWith(".testnet") ? "testnet" : "mainnet");
|
|
37
|
+
const testnetRecipient = siwn.recipients?.testnet;
|
|
38
|
+
if (testnetRecipient) return {
|
|
39
|
+
recipients: {
|
|
40
|
+
mainnet: mainnetRecipient,
|
|
41
|
+
testnet: testnetRecipient
|
|
42
|
+
},
|
|
43
|
+
networkId,
|
|
44
|
+
cspNonce: options.cspNonce
|
|
45
|
+
};
|
|
46
|
+
return {
|
|
47
|
+
recipient: mainnetRecipient,
|
|
48
|
+
networkId,
|
|
49
|
+
cspNonce: options.cspNonce
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function getHostUrl(config) {
|
|
53
|
+
const runtimeConfig = readRuntimeConfig(config);
|
|
54
|
+
if (runtimeConfig?.hostUrl) return runtimeConfig.hostUrl;
|
|
55
|
+
if (typeof window !== "undefined") return window.location.origin;
|
|
56
|
+
return "";
|
|
57
|
+
}
|
|
58
|
+
function getDeviceLinkClientId(config) {
|
|
59
|
+
return (readRuntimeConfig(config)?.auth?.variables)?.deviceLink?.clientId ?? better_near_auth_client.DEFAULT_DEVICE_LINK_CLIENT_ID;
|
|
60
|
+
}
|
|
61
|
+
function createAuthClient(options = {}) {
|
|
62
|
+
const nearAuthConfig = getSiwnClientConfig(options);
|
|
63
|
+
return (0, better_auth_react.createAuthClient)({
|
|
64
|
+
baseURL: getHostUrl(options.runtimeConfig),
|
|
65
|
+
fetchOptions: {
|
|
66
|
+
credentials: "include",
|
|
67
|
+
...options.headers ? { headers: options.headers } : {}
|
|
68
|
+
},
|
|
69
|
+
plugins: [
|
|
70
|
+
(0, better_auth_client_plugins.inferAdditionalFields)({ user: { locale: {
|
|
71
|
+
type: "string",
|
|
72
|
+
required: false,
|
|
73
|
+
input: true
|
|
74
|
+
} } }),
|
|
75
|
+
(0, better_near_auth_client.siwnClient)(nearAuthConfig),
|
|
76
|
+
(0, better_auth_client_plugins.adminClient)(),
|
|
77
|
+
(0, better_auth_client_plugins.anonymousClient)(),
|
|
78
|
+
(0, better_auth_client_plugins.phoneNumberClient)(),
|
|
79
|
+
(0, _better_auth_passkey_client.passkeyClient)(),
|
|
80
|
+
(0, better_auth_client_plugins.organizationClient)({ teams: { enabled: true } }),
|
|
81
|
+
(0, _better_auth_api_key_client.apiKeyClient)(),
|
|
82
|
+
(0, better_auth_client_plugins.deviceAuthorizationClient)()
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
function useAuthClient() {
|
|
87
|
+
return (0, _tanstack_react_router.useRouter)().options.context.authClient;
|
|
88
|
+
}
|
|
89
|
+
const sessionQueryKey = ["session"];
|
|
90
|
+
function sessionQueryOptions(authClient) {
|
|
91
|
+
return {
|
|
92
|
+
queryKey: sessionQueryKey,
|
|
93
|
+
queryFn: async () => {
|
|
94
|
+
const { data: session, error } = await authClient.getSession({ query: { disableCookieCache: true } });
|
|
95
|
+
if (error) throw new Error(error.message || "Unable to load your session");
|
|
96
|
+
return session ?? null;
|
|
97
|
+
},
|
|
98
|
+
staleTime: 6e4,
|
|
99
|
+
gcTime: 6e5
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
async function refreshSessionCache(authClient, queryClient) {
|
|
103
|
+
return queryClient.fetchQuery({
|
|
104
|
+
...sessionQueryOptions(authClient),
|
|
105
|
+
staleTime: 0
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Resolves the session for the root route: the query cache wins (it is kept
|
|
110
|
+
* authoritative by the single sessionQueryOptions read path), and a populated
|
|
111
|
+
* router-context session — the host's SSR resolution — seeds an empty cache so
|
|
112
|
+
* the dehydrated state carries it to the client.
|
|
113
|
+
*/
|
|
114
|
+
function resolveSessionFromCache(queryClient, contextSession) {
|
|
115
|
+
if (!queryClient) return contextSession;
|
|
116
|
+
const cachedSession = queryClient.getQueryData(sessionQueryKey);
|
|
117
|
+
if (cachedSession !== void 0) return cachedSession;
|
|
118
|
+
if (contextSession !== void 0) queryClient.setQueryData(sessionQueryKey, contextSession);
|
|
119
|
+
return contextSession;
|
|
120
|
+
}
|
|
121
|
+
function useRelayHistory(session, authClient) {
|
|
122
|
+
return (0, _tanstack_react_query.useQuery)({
|
|
123
|
+
queryKey: ["relay-history"],
|
|
124
|
+
queryFn: async () => {
|
|
125
|
+
return (await authClient.near.relayHistory())?.data?.transactions ?? [];
|
|
126
|
+
},
|
|
127
|
+
enabled: !!session,
|
|
128
|
+
refetchInterval: 2e3
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
const UNSUPPORTED_AUTHENTICATOR_CODES = /* @__PURE__ */ new Set([
|
|
132
|
+
"PASSKEY_UNSUPPORTED_AUTHENTICATOR",
|
|
133
|
+
"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",
|
|
134
|
+
"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
135
|
+
"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT"
|
|
136
|
+
]);
|
|
137
|
+
function isUnsupportedAuthenticatorError(error) {
|
|
138
|
+
if (!(error instanceof Error) || !("code" in error)) return false;
|
|
139
|
+
return typeof error.code === "string" && UNSUPPORTED_AUTHENTICATOR_CODES.has(error.code);
|
|
140
|
+
}
|
|
141
|
+
function toPasskeyError(error, fallback) {
|
|
142
|
+
return Object.assign(new Error(error?.message || fallback), { code: error?.code });
|
|
143
|
+
}
|
|
144
|
+
async function isPasskeyAutofillAvailable() {
|
|
145
|
+
if (typeof window === "undefined" || !window.PublicKeyCredential) return false;
|
|
146
|
+
try {
|
|
147
|
+
return await window.PublicKeyCredential.isConditionalMediationAvailable?.() === true;
|
|
148
|
+
} catch {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
async function createAccountWithPasskey(authClient, options) {
|
|
153
|
+
try {
|
|
154
|
+
const { data, error } = await authClient.passkey.addPasskey();
|
|
155
|
+
if (error || !data) {
|
|
156
|
+
options?.onError?.(toPasskeyError(error, "Could not create your account"));
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
const { passkeyWallet } = data;
|
|
160
|
+
options?.onSuccess?.({ passkeyWallet });
|
|
161
|
+
} catch (error) {
|
|
162
|
+
options?.onError?.(toPasskeyError(error instanceof Error ? error : null, "Could not create your account"));
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async function signInWithPasskey(authClient, options) {
|
|
166
|
+
try {
|
|
167
|
+
const { data, error } = await authClient.signIn.passkey({ autoFill: options?.autoFill });
|
|
168
|
+
if (error || !data) {
|
|
169
|
+
options?.onError?.(toPasskeyError(error, "Passkey sign-in failed"));
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
options?.onSuccess?.();
|
|
173
|
+
} catch (error) {
|
|
174
|
+
options?.onError?.(toPasskeyError(error instanceof Error ? error : null, "Passkey sign-in failed"));
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
//#endregion
|
|
179
|
+
exports.clearAuthenticatedQueries = require_auth_guards.clearAuthenticatedQueries;
|
|
180
|
+
exports.createAccountWithPasskey = createAccountWithPasskey;
|
|
181
|
+
exports.createAuthClient = createAuthClient;
|
|
182
|
+
exports.getDeviceLinkClientId = getDeviceLinkClientId;
|
|
183
|
+
exports.isPasskeyAutofillAvailable = isPasskeyAutofillAvailable;
|
|
184
|
+
exports.isUnsupportedAuthenticatorError = isUnsupportedAuthenticatorError;
|
|
185
|
+
exports.pluginHref = require_plugin_path.pluginHref;
|
|
186
|
+
exports.pluginPath = require_plugin_path.pluginPath;
|
|
187
|
+
exports.pluginSearch = require_plugin_path.pluginSearch;
|
|
188
|
+
exports.refreshSessionCache = refreshSessionCache;
|
|
189
|
+
exports.requireAdmin = require_auth_guards.requireAdmin;
|
|
190
|
+
exports.requireSession = require_auth_guards.requireSession;
|
|
191
|
+
exports.resolveSessionFromCache = resolveSessionFromCache;
|
|
192
|
+
exports.sessionQueryKey = sessionQueryKey;
|
|
193
|
+
exports.sessionQueryOptions = sessionQueryOptions;
|
|
194
|
+
exports.signInWithPasskey = signInWithPasskey;
|
|
195
|
+
exports.useAuthClient = useAuthClient;
|
|
196
|
+
exports.useRelayHistory = useRelayHistory;
|
|
197
|
+
//# sourceMappingURL=auth.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.cjs","names":["getRuntimeConfig","DEFAULT_DEVICE_LINK_CLIENT_ID","createBetterAuthClient","inferAdditionalFields","siwnClient","adminClient","anonymousClient","phoneNumberClient","passkeyClient","organizationClient","apiKeyClient","deviceAuthorizationClient","useRouter","useQuery"],"sources":["../../src/ui/auth.ts"],"sourcesContent":["import { apiKeyClient } from \"@better-auth/api-key/client\";\nimport { passkeyClient } from \"@better-auth/passkey/client\";\nimport { type QueryClient, useQuery } from \"@tanstack/react-query\";\nimport { useRouter } from \"@tanstack/react-router\";\nimport {\n adminClient,\n anonymousClient,\n deviceAuthorizationClient,\n inferAdditionalFields,\n organizationClient,\n phoneNumberClient,\n} from \"better-auth/client/plugins\";\nimport { createAuthClient as createBetterAuthClient } from \"better-auth/react\";\nimport type { PasskeyWalletLink, RelayedTransactionT } from \"better-near-auth\";\nimport { DEFAULT_DEVICE_LINK_CLIENT_ID, siwnClient } from \"better-near-auth/client\";\nimport type { ClientRuntimeConfig } from \"../types\";\nimport { getRuntimeConfig } from \"./runtime\";\n\ntype RuntimeAuthVariables = {\n siwn: {\n recipient?: string;\n recipients?: {\n mainnet?: string;\n testnet?: string;\n };\n };\n deviceLink?: {\n clientId?: string;\n };\n};\n\nexport type CreateAuthClientOptions = {\n runtimeConfig?: Partial<ClientRuntimeConfig>;\n headers?: HeadersInit;\n cspNonce?: string;\n};\n\ntype SiwnClientConfig = Parameters<typeof siwnClient>[0] & {\n cspNonce?: string;\n};\n\nfunction hasAuthVariables(auth: ClientRuntimeConfig[\"auth\"] | undefined): auth is NonNullable<\n ClientRuntimeConfig[\"auth\"]\n> & {\n variables: RuntimeAuthVariables;\n} {\n return !!auth && typeof auth === \"object\" && typeof auth.variables === \"object\";\n}\n\nfunction readRuntimeConfig(config?: Partial<ClientRuntimeConfig>) {\n if (config) return config;\n if (typeof window === \"undefined\") return undefined;\n try {\n return getRuntimeConfig();\n } catch {\n return undefined;\n }\n}\n\nfunction getAuthVariables(config?: Partial<ClientRuntimeConfig>): RuntimeAuthVariables {\n const runtimeConfig = readRuntimeConfig(config);\n if (!runtimeConfig || !hasAuthVariables(runtimeConfig.auth)) {\n throw new Error(\"Missing auth runtime configuration\");\n }\n return runtimeConfig.auth.variables;\n}\n\nfunction getSiwnClientConfig(options: CreateAuthClientOptions): SiwnClientConfig {\n const runtimeConfig = readRuntimeConfig(options.runtimeConfig);\n const variables = getAuthVariables(options.runtimeConfig);\n const siwn = variables.siwn;\n\n const mainnetRecipient = siwn.recipients?.mainnet ?? siwn.recipient;\n if (!mainnetRecipient) {\n throw new Error(\"Missing auth SIWN recipient\");\n }\n\n const networkId =\n runtimeConfig?.networkId ?? (mainnetRecipient.endsWith(\".testnet\") ? \"testnet\" : \"mainnet\");\n const testnetRecipient = siwn.recipients?.testnet;\n\n if (testnetRecipient) {\n return {\n recipients: { mainnet: mainnetRecipient, testnet: testnetRecipient },\n networkId,\n cspNonce: options.cspNonce,\n };\n }\n\n return { recipient: mainnetRecipient, networkId, cspNonce: options.cspNonce };\n}\n\nfunction getHostUrl(config?: Partial<ClientRuntimeConfig>) {\n const runtimeConfig = readRuntimeConfig(config);\n if (runtimeConfig?.hostUrl) return runtimeConfig.hostUrl;\n if (typeof window !== \"undefined\") return window.location.origin;\n return \"\";\n}\n\nexport function getDeviceLinkClientId(config?: Partial<ClientRuntimeConfig>): string {\n const runtimeConfig = readRuntimeConfig(config);\n const variables = runtimeConfig?.auth?.variables as RuntimeAuthVariables | undefined;\n return variables?.deviceLink?.clientId ?? DEFAULT_DEVICE_LINK_CLIENT_ID;\n}\n\nexport function createAuthClient(options: CreateAuthClientOptions = {}) {\n const nearAuthConfig = getSiwnClientConfig(options);\n\n return createBetterAuthClient({\n baseURL: getHostUrl(options.runtimeConfig),\n fetchOptions: {\n credentials: \"include\",\n ...(options.headers ? { headers: options.headers } : {}),\n },\n plugins: [\n inferAdditionalFields({\n user: {\n locale: { type: \"string\", required: false, input: true },\n },\n }),\n siwnClient(nearAuthConfig),\n adminClient(),\n anonymousClient(),\n phoneNumberClient(),\n passkeyClient(),\n organizationClient({ teams: { enabled: true } }),\n apiKeyClient(),\n deviceAuthorizationClient(),\n ],\n });\n}\n\nexport type { AuthContext } from \"./auth-guards\";\nexport {\n clearAuthenticatedQueries,\n requireAdmin,\n requireSession,\n} from \"./auth-guards\";\nexport { pluginHref, pluginPath, pluginSearch } from \"./plugin-path\";\n\nexport type AuthClient = ReturnType<typeof createAuthClient>;\ntype OrganizationListResult = Awaited<ReturnType<AuthClient[\"organization\"][\"list\"]>>;\ntype PasskeyListResult = Awaited<ReturnType<AuthClient[\"passkey\"][\"listUserPasskeys\"]>>;\n\nexport type SessionData = AuthClient[\"$Infer\"][\"Session\"];\nexport type Organization = NonNullable<OrganizationListResult[\"data\"]>[number];\nexport type Passkey = NonNullable<PasskeyListResult[\"data\"]>[number];\n\nexport function useAuthClient(): AuthClient {\n return useRouter().options.context.authClient as AuthClient;\n}\n\nexport const sessionQueryKey = [\"session\"] as const;\n\nexport function sessionQueryOptions(authClient: AuthClient) {\n return {\n queryKey: sessionQueryKey,\n queryFn: async () => {\n const { data: session, error } = await authClient.getSession({\n query: { disableCookieCache: true },\n });\n if (error) throw new Error(error.message || \"Unable to load your session\");\n return session ?? null;\n },\n staleTime: 60 * 1000,\n gcTime: 10 * 60 * 1000,\n };\n}\n\nexport async function refreshSessionCache(\n authClient: AuthClient,\n queryClient: QueryClient,\n): Promise<SessionData | null> {\n return queryClient.fetchQuery({ ...sessionQueryOptions(authClient), staleTime: 0 });\n}\n\n/**\n * Resolves the session for the root route: the query cache wins (it is kept\n * authoritative by the single sessionQueryOptions read path), and a populated\n * router-context session — the host's SSR resolution — seeds an empty cache so\n * the dehydrated state carries it to the client.\n */\nexport function resolveSessionFromCache<T>(\n queryClient: QueryClient | undefined,\n contextSession: T | null | undefined,\n): T | null | undefined {\n if (!queryClient) return contextSession;\n\n const cachedSession = queryClient.getQueryData<T | null>(sessionQueryKey);\n if (cachedSession !== undefined) return cachedSession;\n\n if (contextSession !== undefined) {\n queryClient.setQueryData(sessionQueryKey, contextSession);\n }\n return contextSession;\n}\n\nexport function useRelayHistory(session: SessionData | null | undefined, authClient: AuthClient) {\n return useQuery({\n queryKey: [\"relay-history\"],\n queryFn: async (): Promise<RelayedTransactionT[]> => {\n const res = await authClient.near.relayHistory();\n return res?.data?.transactions ?? [];\n },\n enabled: !!session,\n refetchInterval: 2000,\n });\n}\n\nexport type PasskeyWalletStatus = PasskeyWalletLink;\n\nexport type PasskeyCeremonyError = Error & { code?: string };\n\nconst UNSUPPORTED_AUTHENTICATOR_CODES = new Set([\n \"PASSKEY_UNSUPPORTED_AUTHENTICATOR\",\n \"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG\",\n \"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT\",\n \"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT\",\n]);\n\nexport function isUnsupportedAuthenticatorError(error: unknown): boolean {\n if (!(error instanceof Error) || !(\"code\" in error)) return false;\n return typeof error.code === \"string\" && UNSUPPORTED_AUTHENTICATOR_CODES.has(error.code);\n}\n\nfunction toPasskeyError(\n error: { code?: string; message?: string } | null | undefined,\n fallback: string,\n): PasskeyCeremonyError {\n return Object.assign(new Error(error?.message || fallback), { code: error?.code });\n}\n\nexport async function isPasskeyAutofillAvailable(): Promise<boolean> {\n if (typeof window === \"undefined\" || !window.PublicKeyCredential) return false;\n try {\n return (await window.PublicKeyCredential.isConditionalMediationAvailable?.()) === true;\n } catch {\n return false;\n }\n}\n\nexport async function createAccountWithPasskey(\n authClient: AuthClient,\n options?: {\n onSuccess?: (result: { passkeyWallet?: PasskeyWalletStatus }) => void;\n onError?: (error: PasskeyCeremonyError) => void;\n },\n): Promise<void> {\n try {\n const { data, error } = await authClient.passkey.addPasskey();\n if (error || !data) {\n options?.onError?.(toPasskeyError(error, \"Could not create your account\"));\n return;\n }\n const { passkeyWallet } = data as { passkeyWallet?: PasskeyWalletStatus };\n options?.onSuccess?.({ passkeyWallet });\n } catch (error) {\n options?.onError?.(\n toPasskeyError(error instanceof Error ? error : null, \"Could not create your account\"),\n );\n }\n}\n\nexport async function signInWithPasskey(\n authClient: AuthClient,\n options?: {\n autoFill?: boolean;\n onSuccess?: () => void;\n onError?: (error: PasskeyCeremonyError) => void;\n },\n): Promise<void> {\n try {\n const { data, error } = await authClient.signIn.passkey({ autoFill: options?.autoFill });\n if (error || !data) {\n options?.onError?.(toPasskeyError(error, \"Passkey sign-in failed\"));\n return;\n }\n options?.onSuccess?.();\n } catch (error) {\n options?.onError?.(\n toPasskeyError(error instanceof Error ? error : null, \"Passkey sign-in failed\"),\n );\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ClientRuntimeConfig } from "../types.cjs";
|
|
2
|
+
import { AuthContext, clearAuthenticatedQueries, requireAdmin, requireSession } from "./auth-guards.cjs";
|
|
3
|
+
import { pluginHref, pluginPath, pluginSearch } from "./plugin-path.cjs";
|
|
4
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { PasskeyWalletLink } from "better-near-auth";
|
|
6
|
+
//#region src/ui/auth.d.ts
|
|
7
|
+
type CreateAuthClientOptions = {
|
|
8
|
+
runtimeConfig?: Partial<ClientRuntimeConfig>;
|
|
9
|
+
headers?: HeadersInit;
|
|
10
|
+
cspNonce?: string;
|
|
11
|
+
};
|
|
12
|
+
declare function getDeviceLinkClientId(config?: Partial<ClientRuntimeConfig>): string;
|
|
13
|
+
declare function createAuthClient(options?: CreateAuthClientOptions): any;
|
|
14
|
+
type AuthClient = ReturnType<typeof createAuthClient>;
|
|
15
|
+
type OrganizationListResult = Awaited<ReturnType<AuthClient["organization"]["list"]>>;
|
|
16
|
+
type PasskeyListResult = Awaited<ReturnType<AuthClient["passkey"]["listUserPasskeys"]>>;
|
|
17
|
+
type SessionData = AuthClient["$Infer"]["Session"];
|
|
18
|
+
type Organization = NonNullable<OrganizationListResult["data"]>[number];
|
|
19
|
+
type Passkey = NonNullable<PasskeyListResult["data"]>[number];
|
|
20
|
+
declare function useAuthClient(): AuthClient;
|
|
21
|
+
declare const sessionQueryKey: readonly ["session"];
|
|
22
|
+
declare function sessionQueryOptions(authClient: AuthClient): {
|
|
23
|
+
queryKey: readonly ["session"];
|
|
24
|
+
queryFn: () => Promise<any>;
|
|
25
|
+
staleTime: number;
|
|
26
|
+
gcTime: number;
|
|
27
|
+
};
|
|
28
|
+
declare function refreshSessionCache(authClient: AuthClient, queryClient: QueryClient): Promise<SessionData | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the session for the root route: the query cache wins (it is kept
|
|
31
|
+
* authoritative by the single sessionQueryOptions read path), and a populated
|
|
32
|
+
* router-context session — the host's SSR resolution — seeds an empty cache so
|
|
33
|
+
* the dehydrated state carries it to the client.
|
|
34
|
+
*/
|
|
35
|
+
declare function resolveSessionFromCache<T>(queryClient: QueryClient | undefined, contextSession: T | null | undefined): T | null | undefined;
|
|
36
|
+
declare function useRelayHistory(session: SessionData | null | undefined, authClient: AuthClient): import("@tanstack/react-query").UseQueryResult<RelayedTransactionT[], Error>;
|
|
37
|
+
type PasskeyWalletStatus = PasskeyWalletLink;
|
|
38
|
+
type PasskeyCeremonyError = Error & {
|
|
39
|
+
code?: string;
|
|
40
|
+
};
|
|
41
|
+
declare function isUnsupportedAuthenticatorError(error: unknown): boolean;
|
|
42
|
+
declare function isPasskeyAutofillAvailable(): Promise<boolean>;
|
|
43
|
+
declare function createAccountWithPasskey(authClient: AuthClient, options?: {
|
|
44
|
+
onSuccess?: (result: {
|
|
45
|
+
passkeyWallet?: PasskeyWalletStatus;
|
|
46
|
+
}) => void;
|
|
47
|
+
onError?: (error: PasskeyCeremonyError) => void;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
declare function signInWithPasskey(authClient: AuthClient, options?: {
|
|
50
|
+
autoFill?: boolean;
|
|
51
|
+
onSuccess?: () => void;
|
|
52
|
+
onError?: (error: PasskeyCeremonyError) => void;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { AuthClient, type AuthContext, CreateAuthClientOptions, Organization, Passkey, PasskeyCeremonyError, PasskeyWalletStatus, SessionData, clearAuthenticatedQueries, createAccountWithPasskey, createAuthClient, getDeviceLinkClientId, isPasskeyAutofillAvailable, isUnsupportedAuthenticatorError, pluginHref, pluginPath, pluginSearch, refreshSessionCache, requireAdmin, requireSession, resolveSessionFromCache, sessionQueryKey, sessionQueryOptions, signInWithPasskey, useAuthClient, useRelayHistory };
|
|
56
|
+
//# sourceMappingURL=auth.d.cts.map
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { ClientRuntimeConfig } from "../types.mjs";
|
|
2
|
+
import { AuthContext, clearAuthenticatedQueries, requireAdmin, requireSession } from "./auth-guards.mjs";
|
|
3
|
+
import { pluginHref, pluginPath, pluginSearch } from "./plugin-path.mjs";
|
|
4
|
+
import { QueryClient } from "@tanstack/react-query";
|
|
5
|
+
import { PasskeyWalletLink } from "better-near-auth";
|
|
6
|
+
//#region src/ui/auth.d.ts
|
|
7
|
+
type CreateAuthClientOptions = {
|
|
8
|
+
runtimeConfig?: Partial<ClientRuntimeConfig>;
|
|
9
|
+
headers?: HeadersInit;
|
|
10
|
+
cspNonce?: string;
|
|
11
|
+
};
|
|
12
|
+
declare function getDeviceLinkClientId(config?: Partial<ClientRuntimeConfig>): string;
|
|
13
|
+
declare function createAuthClient(options?: CreateAuthClientOptions): any;
|
|
14
|
+
type AuthClient = ReturnType<typeof createAuthClient>;
|
|
15
|
+
type OrganizationListResult = Awaited<ReturnType<AuthClient["organization"]["list"]>>;
|
|
16
|
+
type PasskeyListResult = Awaited<ReturnType<AuthClient["passkey"]["listUserPasskeys"]>>;
|
|
17
|
+
type SessionData = AuthClient["$Infer"]["Session"];
|
|
18
|
+
type Organization = NonNullable<OrganizationListResult["data"]>[number];
|
|
19
|
+
type Passkey = NonNullable<PasskeyListResult["data"]>[number];
|
|
20
|
+
declare function useAuthClient(): AuthClient;
|
|
21
|
+
declare const sessionQueryKey: readonly ["session"];
|
|
22
|
+
declare function sessionQueryOptions(authClient: AuthClient): {
|
|
23
|
+
queryKey: readonly ["session"];
|
|
24
|
+
queryFn: () => Promise<any>;
|
|
25
|
+
staleTime: number;
|
|
26
|
+
gcTime: number;
|
|
27
|
+
};
|
|
28
|
+
declare function refreshSessionCache(authClient: AuthClient, queryClient: QueryClient): Promise<SessionData | null>;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the session for the root route: the query cache wins (it is kept
|
|
31
|
+
* authoritative by the single sessionQueryOptions read path), and a populated
|
|
32
|
+
* router-context session — the host's SSR resolution — seeds an empty cache so
|
|
33
|
+
* the dehydrated state carries it to the client.
|
|
34
|
+
*/
|
|
35
|
+
declare function resolveSessionFromCache<T>(queryClient: QueryClient | undefined, contextSession: T | null | undefined): T | null | undefined;
|
|
36
|
+
declare function useRelayHistory(session: SessionData | null | undefined, authClient: AuthClient): import("@tanstack/react-query").UseQueryResult<RelayedTransactionT[], Error>;
|
|
37
|
+
type PasskeyWalletStatus = PasskeyWalletLink;
|
|
38
|
+
type PasskeyCeremonyError = Error & {
|
|
39
|
+
code?: string;
|
|
40
|
+
};
|
|
41
|
+
declare function isUnsupportedAuthenticatorError(error: unknown): boolean;
|
|
42
|
+
declare function isPasskeyAutofillAvailable(): Promise<boolean>;
|
|
43
|
+
declare function createAccountWithPasskey(authClient: AuthClient, options?: {
|
|
44
|
+
onSuccess?: (result: {
|
|
45
|
+
passkeyWallet?: PasskeyWalletStatus;
|
|
46
|
+
}) => void;
|
|
47
|
+
onError?: (error: PasskeyCeremonyError) => void;
|
|
48
|
+
}): Promise<void>;
|
|
49
|
+
declare function signInWithPasskey(authClient: AuthClient, options?: {
|
|
50
|
+
autoFill?: boolean;
|
|
51
|
+
onSuccess?: () => void;
|
|
52
|
+
onError?: (error: PasskeyCeremonyError) => void;
|
|
53
|
+
}): Promise<void>;
|
|
54
|
+
//#endregion
|
|
55
|
+
export { AuthClient, type AuthContext, CreateAuthClientOptions, Organization, Passkey, PasskeyCeremonyError, PasskeyWalletStatus, SessionData, clearAuthenticatedQueries, createAccountWithPasskey, createAuthClient, getDeviceLinkClientId, isPasskeyAutofillAvailable, isUnsupportedAuthenticatorError, pluginHref, pluginPath, pluginSearch, refreshSessionCache, requireAdmin, requireSession, resolveSessionFromCache, sessionQueryKey, sessionQueryOptions, signInWithPasskey, useAuthClient, useRelayHistory };
|
|
56
|
+
//# sourceMappingURL=auth.d.mts.map
|
package/dist/ui/auth.mjs
ADDED
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { getRuntimeConfig } from "./runtime.mjs";
|
|
2
|
+
import { pluginHref, pluginPath, pluginSearch } from "./plugin-path.mjs";
|
|
3
|
+
import { clearAuthenticatedQueries, requireAdmin, requireSession } from "./auth-guards.mjs";
|
|
4
|
+
import { useRouter } from "@tanstack/react-router";
|
|
5
|
+
import { apiKeyClient } from "@better-auth/api-key/client";
|
|
6
|
+
import { passkeyClient } from "@better-auth/passkey/client";
|
|
7
|
+
import { useQuery } from "@tanstack/react-query";
|
|
8
|
+
import { adminClient, anonymousClient, deviceAuthorizationClient, inferAdditionalFields, organizationClient, phoneNumberClient } from "better-auth/client/plugins";
|
|
9
|
+
import { createAuthClient as createAuthClient$1 } from "better-auth/react";
|
|
10
|
+
import { DEFAULT_DEVICE_LINK_CLIENT_ID, siwnClient } from "better-near-auth/client";
|
|
11
|
+
|
|
12
|
+
//#region src/ui/auth.ts
|
|
13
|
+
function hasAuthVariables(auth) {
|
|
14
|
+
return !!auth && typeof auth === "object" && typeof auth.variables === "object";
|
|
15
|
+
}
|
|
16
|
+
function readRuntimeConfig(config) {
|
|
17
|
+
if (config) return config;
|
|
18
|
+
if (typeof window === "undefined") return void 0;
|
|
19
|
+
try {
|
|
20
|
+
return getRuntimeConfig();
|
|
21
|
+
} catch {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function getAuthVariables(config) {
|
|
26
|
+
const runtimeConfig = readRuntimeConfig(config);
|
|
27
|
+
if (!runtimeConfig || !hasAuthVariables(runtimeConfig.auth)) throw new Error("Missing auth runtime configuration");
|
|
28
|
+
return runtimeConfig.auth.variables;
|
|
29
|
+
}
|
|
30
|
+
function getSiwnClientConfig(options) {
|
|
31
|
+
const runtimeConfig = readRuntimeConfig(options.runtimeConfig);
|
|
32
|
+
const siwn = getAuthVariables(options.runtimeConfig).siwn;
|
|
33
|
+
const mainnetRecipient = siwn.recipients?.mainnet ?? siwn.recipient;
|
|
34
|
+
if (!mainnetRecipient) throw new Error("Missing auth SIWN recipient");
|
|
35
|
+
const networkId = runtimeConfig?.networkId ?? (mainnetRecipient.endsWith(".testnet") ? "testnet" : "mainnet");
|
|
36
|
+
const testnetRecipient = siwn.recipients?.testnet;
|
|
37
|
+
if (testnetRecipient) return {
|
|
38
|
+
recipients: {
|
|
39
|
+
mainnet: mainnetRecipient,
|
|
40
|
+
testnet: testnetRecipient
|
|
41
|
+
},
|
|
42
|
+
networkId,
|
|
43
|
+
cspNonce: options.cspNonce
|
|
44
|
+
};
|
|
45
|
+
return {
|
|
46
|
+
recipient: mainnetRecipient,
|
|
47
|
+
networkId,
|
|
48
|
+
cspNonce: options.cspNonce
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function getHostUrl(config) {
|
|
52
|
+
const runtimeConfig = readRuntimeConfig(config);
|
|
53
|
+
if (runtimeConfig?.hostUrl) return runtimeConfig.hostUrl;
|
|
54
|
+
if (typeof window !== "undefined") return window.location.origin;
|
|
55
|
+
return "";
|
|
56
|
+
}
|
|
57
|
+
function getDeviceLinkClientId(config) {
|
|
58
|
+
return (readRuntimeConfig(config)?.auth?.variables)?.deviceLink?.clientId ?? DEFAULT_DEVICE_LINK_CLIENT_ID;
|
|
59
|
+
}
|
|
60
|
+
function createAuthClient(options = {}) {
|
|
61
|
+
const nearAuthConfig = getSiwnClientConfig(options);
|
|
62
|
+
return createAuthClient$1({
|
|
63
|
+
baseURL: getHostUrl(options.runtimeConfig),
|
|
64
|
+
fetchOptions: {
|
|
65
|
+
credentials: "include",
|
|
66
|
+
...options.headers ? { headers: options.headers } : {}
|
|
67
|
+
},
|
|
68
|
+
plugins: [
|
|
69
|
+
inferAdditionalFields({ user: { locale: {
|
|
70
|
+
type: "string",
|
|
71
|
+
required: false,
|
|
72
|
+
input: true
|
|
73
|
+
} } }),
|
|
74
|
+
siwnClient(nearAuthConfig),
|
|
75
|
+
adminClient(),
|
|
76
|
+
anonymousClient(),
|
|
77
|
+
phoneNumberClient(),
|
|
78
|
+
passkeyClient(),
|
|
79
|
+
organizationClient({ teams: { enabled: true } }),
|
|
80
|
+
apiKeyClient(),
|
|
81
|
+
deviceAuthorizationClient()
|
|
82
|
+
]
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
function useAuthClient() {
|
|
86
|
+
return useRouter().options.context.authClient;
|
|
87
|
+
}
|
|
88
|
+
const sessionQueryKey = ["session"];
|
|
89
|
+
function sessionQueryOptions(authClient) {
|
|
90
|
+
return {
|
|
91
|
+
queryKey: sessionQueryKey,
|
|
92
|
+
queryFn: async () => {
|
|
93
|
+
const { data: session, error } = await authClient.getSession({ query: { disableCookieCache: true } });
|
|
94
|
+
if (error) throw new Error(error.message || "Unable to load your session");
|
|
95
|
+
return session ?? null;
|
|
96
|
+
},
|
|
97
|
+
staleTime: 6e4,
|
|
98
|
+
gcTime: 6e5
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async function refreshSessionCache(authClient, queryClient) {
|
|
102
|
+
return queryClient.fetchQuery({
|
|
103
|
+
...sessionQueryOptions(authClient),
|
|
104
|
+
staleTime: 0
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Resolves the session for the root route: the query cache wins (it is kept
|
|
109
|
+
* authoritative by the single sessionQueryOptions read path), and a populated
|
|
110
|
+
* router-context session — the host's SSR resolution — seeds an empty cache so
|
|
111
|
+
* the dehydrated state carries it to the client.
|
|
112
|
+
*/
|
|
113
|
+
function resolveSessionFromCache(queryClient, contextSession) {
|
|
114
|
+
if (!queryClient) return contextSession;
|
|
115
|
+
const cachedSession = queryClient.getQueryData(sessionQueryKey);
|
|
116
|
+
if (cachedSession !== void 0) return cachedSession;
|
|
117
|
+
if (contextSession !== void 0) queryClient.setQueryData(sessionQueryKey, contextSession);
|
|
118
|
+
return contextSession;
|
|
119
|
+
}
|
|
120
|
+
function useRelayHistory(session, authClient) {
|
|
121
|
+
return useQuery({
|
|
122
|
+
queryKey: ["relay-history"],
|
|
123
|
+
queryFn: async () => {
|
|
124
|
+
return (await authClient.near.relayHistory())?.data?.transactions ?? [];
|
|
125
|
+
},
|
|
126
|
+
enabled: !!session,
|
|
127
|
+
refetchInterval: 2e3
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
const UNSUPPORTED_AUTHENTICATOR_CODES = /* @__PURE__ */ new Set([
|
|
131
|
+
"PASSKEY_UNSUPPORTED_AUTHENTICATOR",
|
|
132
|
+
"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG",
|
|
133
|
+
"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT",
|
|
134
|
+
"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT"
|
|
135
|
+
]);
|
|
136
|
+
function isUnsupportedAuthenticatorError(error) {
|
|
137
|
+
if (!(error instanceof Error) || !("code" in error)) return false;
|
|
138
|
+
return typeof error.code === "string" && UNSUPPORTED_AUTHENTICATOR_CODES.has(error.code);
|
|
139
|
+
}
|
|
140
|
+
function toPasskeyError(error, fallback) {
|
|
141
|
+
return Object.assign(new Error(error?.message || fallback), { code: error?.code });
|
|
142
|
+
}
|
|
143
|
+
async function isPasskeyAutofillAvailable() {
|
|
144
|
+
if (typeof window === "undefined" || !window.PublicKeyCredential) return false;
|
|
145
|
+
try {
|
|
146
|
+
return await window.PublicKeyCredential.isConditionalMediationAvailable?.() === true;
|
|
147
|
+
} catch {
|
|
148
|
+
return false;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
async function createAccountWithPasskey(authClient, options) {
|
|
152
|
+
try {
|
|
153
|
+
const { data, error } = await authClient.passkey.addPasskey();
|
|
154
|
+
if (error || !data) {
|
|
155
|
+
options?.onError?.(toPasskeyError(error, "Could not create your account"));
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
const { passkeyWallet } = data;
|
|
159
|
+
options?.onSuccess?.({ passkeyWallet });
|
|
160
|
+
} catch (error) {
|
|
161
|
+
options?.onError?.(toPasskeyError(error instanceof Error ? error : null, "Could not create your account"));
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
async function signInWithPasskey(authClient, options) {
|
|
165
|
+
try {
|
|
166
|
+
const { data, error } = await authClient.signIn.passkey({ autoFill: options?.autoFill });
|
|
167
|
+
if (error || !data) {
|
|
168
|
+
options?.onError?.(toPasskeyError(error, "Passkey sign-in failed"));
|
|
169
|
+
return;
|
|
170
|
+
}
|
|
171
|
+
options?.onSuccess?.();
|
|
172
|
+
} catch (error) {
|
|
173
|
+
options?.onError?.(toPasskeyError(error instanceof Error ? error : null, "Passkey sign-in failed"));
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
//#endregion
|
|
178
|
+
export { clearAuthenticatedQueries, createAccountWithPasskey, createAuthClient, getDeviceLinkClientId, isPasskeyAutofillAvailable, isUnsupportedAuthenticatorError, pluginHref, pluginPath, pluginSearch, refreshSessionCache, requireAdmin, requireSession, resolveSessionFromCache, sessionQueryKey, sessionQueryOptions, signInWithPasskey, useAuthClient, useRelayHistory };
|
|
179
|
+
//# sourceMappingURL=auth.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.mjs","names":["createBetterAuthClient"],"sources":["../../src/ui/auth.ts"],"sourcesContent":["import { apiKeyClient } from \"@better-auth/api-key/client\";\nimport { passkeyClient } from \"@better-auth/passkey/client\";\nimport { type QueryClient, useQuery } from \"@tanstack/react-query\";\nimport { useRouter } from \"@tanstack/react-router\";\nimport {\n adminClient,\n anonymousClient,\n deviceAuthorizationClient,\n inferAdditionalFields,\n organizationClient,\n phoneNumberClient,\n} from \"better-auth/client/plugins\";\nimport { createAuthClient as createBetterAuthClient } from \"better-auth/react\";\nimport type { PasskeyWalletLink, RelayedTransactionT } from \"better-near-auth\";\nimport { DEFAULT_DEVICE_LINK_CLIENT_ID, siwnClient } from \"better-near-auth/client\";\nimport type { ClientRuntimeConfig } from \"../types\";\nimport { getRuntimeConfig } from \"./runtime\";\n\ntype RuntimeAuthVariables = {\n siwn: {\n recipient?: string;\n recipients?: {\n mainnet?: string;\n testnet?: string;\n };\n };\n deviceLink?: {\n clientId?: string;\n };\n};\n\nexport type CreateAuthClientOptions = {\n runtimeConfig?: Partial<ClientRuntimeConfig>;\n headers?: HeadersInit;\n cspNonce?: string;\n};\n\ntype SiwnClientConfig = Parameters<typeof siwnClient>[0] & {\n cspNonce?: string;\n};\n\nfunction hasAuthVariables(auth: ClientRuntimeConfig[\"auth\"] | undefined): auth is NonNullable<\n ClientRuntimeConfig[\"auth\"]\n> & {\n variables: RuntimeAuthVariables;\n} {\n return !!auth && typeof auth === \"object\" && typeof auth.variables === \"object\";\n}\n\nfunction readRuntimeConfig(config?: Partial<ClientRuntimeConfig>) {\n if (config) return config;\n if (typeof window === \"undefined\") return undefined;\n try {\n return getRuntimeConfig();\n } catch {\n return undefined;\n }\n}\n\nfunction getAuthVariables(config?: Partial<ClientRuntimeConfig>): RuntimeAuthVariables {\n const runtimeConfig = readRuntimeConfig(config);\n if (!runtimeConfig || !hasAuthVariables(runtimeConfig.auth)) {\n throw new Error(\"Missing auth runtime configuration\");\n }\n return runtimeConfig.auth.variables;\n}\n\nfunction getSiwnClientConfig(options: CreateAuthClientOptions): SiwnClientConfig {\n const runtimeConfig = readRuntimeConfig(options.runtimeConfig);\n const variables = getAuthVariables(options.runtimeConfig);\n const siwn = variables.siwn;\n\n const mainnetRecipient = siwn.recipients?.mainnet ?? siwn.recipient;\n if (!mainnetRecipient) {\n throw new Error(\"Missing auth SIWN recipient\");\n }\n\n const networkId =\n runtimeConfig?.networkId ?? (mainnetRecipient.endsWith(\".testnet\") ? \"testnet\" : \"mainnet\");\n const testnetRecipient = siwn.recipients?.testnet;\n\n if (testnetRecipient) {\n return {\n recipients: { mainnet: mainnetRecipient, testnet: testnetRecipient },\n networkId,\n cspNonce: options.cspNonce,\n };\n }\n\n return { recipient: mainnetRecipient, networkId, cspNonce: options.cspNonce };\n}\n\nfunction getHostUrl(config?: Partial<ClientRuntimeConfig>) {\n const runtimeConfig = readRuntimeConfig(config);\n if (runtimeConfig?.hostUrl) return runtimeConfig.hostUrl;\n if (typeof window !== \"undefined\") return window.location.origin;\n return \"\";\n}\n\nexport function getDeviceLinkClientId(config?: Partial<ClientRuntimeConfig>): string {\n const runtimeConfig = readRuntimeConfig(config);\n const variables = runtimeConfig?.auth?.variables as RuntimeAuthVariables | undefined;\n return variables?.deviceLink?.clientId ?? DEFAULT_DEVICE_LINK_CLIENT_ID;\n}\n\nexport function createAuthClient(options: CreateAuthClientOptions = {}) {\n const nearAuthConfig = getSiwnClientConfig(options);\n\n return createBetterAuthClient({\n baseURL: getHostUrl(options.runtimeConfig),\n fetchOptions: {\n credentials: \"include\",\n ...(options.headers ? { headers: options.headers } : {}),\n },\n plugins: [\n inferAdditionalFields({\n user: {\n locale: { type: \"string\", required: false, input: true },\n },\n }),\n siwnClient(nearAuthConfig),\n adminClient(),\n anonymousClient(),\n phoneNumberClient(),\n passkeyClient(),\n organizationClient({ teams: { enabled: true } }),\n apiKeyClient(),\n deviceAuthorizationClient(),\n ],\n });\n}\n\nexport type { AuthContext } from \"./auth-guards\";\nexport {\n clearAuthenticatedQueries,\n requireAdmin,\n requireSession,\n} from \"./auth-guards\";\nexport { pluginHref, pluginPath, pluginSearch } from \"./plugin-path\";\n\nexport type AuthClient = ReturnType<typeof createAuthClient>;\ntype OrganizationListResult = Awaited<ReturnType<AuthClient[\"organization\"][\"list\"]>>;\ntype PasskeyListResult = Awaited<ReturnType<AuthClient[\"passkey\"][\"listUserPasskeys\"]>>;\n\nexport type SessionData = AuthClient[\"$Infer\"][\"Session\"];\nexport type Organization = NonNullable<OrganizationListResult[\"data\"]>[number];\nexport type Passkey = NonNullable<PasskeyListResult[\"data\"]>[number];\n\nexport function useAuthClient(): AuthClient {\n return useRouter().options.context.authClient as AuthClient;\n}\n\nexport const sessionQueryKey = [\"session\"] as const;\n\nexport function sessionQueryOptions(authClient: AuthClient) {\n return {\n queryKey: sessionQueryKey,\n queryFn: async () => {\n const { data: session, error } = await authClient.getSession({\n query: { disableCookieCache: true },\n });\n if (error) throw new Error(error.message || \"Unable to load your session\");\n return session ?? null;\n },\n staleTime: 60 * 1000,\n gcTime: 10 * 60 * 1000,\n };\n}\n\nexport async function refreshSessionCache(\n authClient: AuthClient,\n queryClient: QueryClient,\n): Promise<SessionData | null> {\n return queryClient.fetchQuery({ ...sessionQueryOptions(authClient), staleTime: 0 });\n}\n\n/**\n * Resolves the session for the root route: the query cache wins (it is kept\n * authoritative by the single sessionQueryOptions read path), and a populated\n * router-context session — the host's SSR resolution — seeds an empty cache so\n * the dehydrated state carries it to the client.\n */\nexport function resolveSessionFromCache<T>(\n queryClient: QueryClient | undefined,\n contextSession: T | null | undefined,\n): T | null | undefined {\n if (!queryClient) return contextSession;\n\n const cachedSession = queryClient.getQueryData<T | null>(sessionQueryKey);\n if (cachedSession !== undefined) return cachedSession;\n\n if (contextSession !== undefined) {\n queryClient.setQueryData(sessionQueryKey, contextSession);\n }\n return contextSession;\n}\n\nexport function useRelayHistory(session: SessionData | null | undefined, authClient: AuthClient) {\n return useQuery({\n queryKey: [\"relay-history\"],\n queryFn: async (): Promise<RelayedTransactionT[]> => {\n const res = await authClient.near.relayHistory();\n return res?.data?.transactions ?? [];\n },\n enabled: !!session,\n refetchInterval: 2000,\n });\n}\n\nexport type PasskeyWalletStatus = PasskeyWalletLink;\n\nexport type PasskeyCeremonyError = Error & { code?: string };\n\nconst UNSUPPORTED_AUTHENTICATOR_CODES = new Set([\n \"PASSKEY_UNSUPPORTED_AUTHENTICATOR\",\n \"ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG\",\n \"ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT\",\n \"ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT\",\n]);\n\nexport function isUnsupportedAuthenticatorError(error: unknown): boolean {\n if (!(error instanceof Error) || !(\"code\" in error)) return false;\n return typeof error.code === \"string\" && UNSUPPORTED_AUTHENTICATOR_CODES.has(error.code);\n}\n\nfunction toPasskeyError(\n error: { code?: string; message?: string } | null | undefined,\n fallback: string,\n): PasskeyCeremonyError {\n return Object.assign(new Error(error?.message || fallback), { code: error?.code });\n}\n\nexport async function isPasskeyAutofillAvailable(): Promise<boolean> {\n if (typeof window === \"undefined\" || !window.PublicKeyCredential) return false;\n try {\n return (await window.PublicKeyCredential.isConditionalMediationAvailable?.()) === true;\n } catch {\n return false;\n }\n}\n\nexport async function createAccountWithPasskey(\n authClient: AuthClient,\n options?: {\n onSuccess?: (result: { passkeyWallet?: PasskeyWalletStatus }) => void;\n onError?: (error: PasskeyCeremonyError) => void;\n },\n): Promise<void> {\n try {\n const { data, error } = await authClient.passkey.addPasskey();\n if (error || !data) {\n options?.onError?.(toPasskeyError(error, \"Could not create your account\"));\n return;\n }\n const { passkeyWallet } = data as { passkeyWallet?: PasskeyWalletStatus };\n options?.onSuccess?.({ passkeyWallet });\n } catch (error) {\n options?.onError?.(\n toPasskeyError(error instanceof Error ? error : null, \"Could not create your account\"),\n );\n }\n}\n\nexport async function signInWithPasskey(\n authClient: AuthClient,\n options?: {\n autoFill?: boolean;\n onSuccess?: () => void;\n onError?: (error: PasskeyCeremonyError) => void;\n },\n): Promise<void> {\n try {\n const { data, error } = await authClient.signIn.passkey({ autoFill: options?.autoFill });\n if (error || !data) {\n options?.onError?.(toPasskeyError(error, \"Passkey sign-in failed\"));\n return;\n }\n options?.onSuccess?.();\n } catch (error) {\n options?.onError?.(\n toPasskeyError(error instanceof Error ? error : null, \"Passkey sign-in failed\"),\n );\n }\n}\n"],"mappings":"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"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
//#region src/ui/entry.ts
|
|
3
|
+
/**
|
|
4
|
+
* Web entry runner — the MF entry expose calls this with its app-specific
|
|
5
|
+
* hydrate loader. The only synchronous work allowed in a web entry is the
|
|
6
|
+
* dynamic import that loads shared-scope negotiation before any shared
|
|
7
|
+
* module executes (loadShareSync … eager:true crash class), so this module
|
|
8
|
+
* deliberately imports nothing else.
|
|
9
|
+
*/
|
|
10
|
+
function runEntry(hydrate) {
|
|
11
|
+
hydrate();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.runEntry = runEntry;
|
|
16
|
+
//# sourceMappingURL=entry.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.cjs","names":[],"sources":["../../src/ui/entry.ts"],"sourcesContent":["/**\n * Web entry runner — the MF entry expose calls this with its app-specific\n * hydrate loader. The only synchronous work allowed in a web entry is the\n * dynamic import that loads shared-scope negotiation before any shared\n * module executes (loadShareSync … eager:true crash class), so this module\n * deliberately imports nothing else.\n */\n\nexport function runEntry(hydrate: () => Promise<unknown>): void {\n void hydrate();\n}\n"],"mappings":";;;;;;;;;AAQA,SAAgB,SAAS,SAAuC;CAC9D,AAAK,QAAQ;AACf"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/ui/entry.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Web entry runner — the MF entry expose calls this with its app-specific
|
|
4
|
+
* hydrate loader. The only synchronous work allowed in a web entry is the
|
|
5
|
+
* dynamic import that loads shared-scope negotiation before any shared
|
|
6
|
+
* module executes (loadShareSync … eager:true crash class), so this module
|
|
7
|
+
* deliberately imports nothing else.
|
|
8
|
+
*/
|
|
9
|
+
declare function runEntry(hydrate: () => Promise<unknown>): void;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { runEntry };
|
|
12
|
+
//# sourceMappingURL=entry.d.cts.map
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//#region src/ui/entry.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Web entry runner — the MF entry expose calls this with its app-specific
|
|
4
|
+
* hydrate loader. The only synchronous work allowed in a web entry is the
|
|
5
|
+
* dynamic import that loads shared-scope negotiation before any shared
|
|
6
|
+
* module executes (loadShareSync … eager:true crash class), so this module
|
|
7
|
+
* deliberately imports nothing else.
|
|
8
|
+
*/
|
|
9
|
+
declare function runEntry(hydrate: () => Promise<unknown>): void;
|
|
10
|
+
//#endregion
|
|
11
|
+
export { runEntry };
|
|
12
|
+
//# sourceMappingURL=entry.d.mts.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
//#region src/ui/entry.ts
|
|
2
|
+
/**
|
|
3
|
+
* Web entry runner — the MF entry expose calls this with its app-specific
|
|
4
|
+
* hydrate loader. The only synchronous work allowed in a web entry is the
|
|
5
|
+
* dynamic import that loads shared-scope negotiation before any shared
|
|
6
|
+
* module executes (loadShareSync … eager:true crash class), so this module
|
|
7
|
+
* deliberately imports nothing else.
|
|
8
|
+
*/
|
|
9
|
+
function runEntry(hydrate) {
|
|
10
|
+
hydrate();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { runEntry };
|
|
15
|
+
//# sourceMappingURL=entry.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"entry.mjs","names":[],"sources":["../../src/ui/entry.ts"],"sourcesContent":["/**\n * Web entry runner — the MF entry expose calls this with its app-specific\n * hydrate loader. The only synchronous work allowed in a web entry is the\n * dynamic import that loads shared-scope negotiation before any shared\n * module executes (loadShareSync … eager:true crash class), so this module\n * deliberately imports nothing else.\n */\n\nexport function runEntry(hydrate: () => Promise<unknown>): void {\n void hydrate();\n}\n"],"mappings":";;;;;;;;AAQA,SAAgB,SAAS,SAAuC;CAC9D,AAAK,QAAQ;AACf"}
|