@aigne/aos 0.2.0-beta
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/CHANGELOG.md +49 -0
- package/LICENSE.md +26 -0
- package/dist/agent-dsl.cjs +116 -0
- package/dist/agent-dsl.d.cts +31 -0
- package/dist/agent-dsl.d.cts.map +1 -0
- package/dist/agent-dsl.d.mts +31 -0
- package/dist/agent-dsl.d.mts.map +1 -0
- package/dist/agent-dsl.mjs +115 -0
- package/dist/agent-dsl.mjs.map +1 -0
- package/dist/arc-compat.cjs +125 -0
- package/dist/arc-compat.d.cts +17 -0
- package/dist/arc-compat.d.cts.map +1 -0
- package/dist/arc-compat.d.mts +17 -0
- package/dist/arc-compat.d.mts.map +1 -0
- package/dist/arc-compat.mjs +123 -0
- package/dist/arc-compat.mjs.map +1 -0
- package/dist/auto-surface/compiler.cjs +36 -0
- package/dist/auto-surface/compiler.d.cts +7 -0
- package/dist/auto-surface/compiler.d.cts.map +1 -0
- package/dist/auto-surface/compiler.d.mts +7 -0
- package/dist/auto-surface/compiler.d.mts.map +1 -0
- package/dist/auto-surface/compiler.mjs +37 -0
- package/dist/auto-surface/compiler.mjs.map +1 -0
- package/dist/auto-surface/definition-dsl.cjs +333 -0
- package/dist/auto-surface/definition-dsl.d.cts +41 -0
- package/dist/auto-surface/definition-dsl.d.cts.map +1 -0
- package/dist/auto-surface/definition-dsl.d.mts +41 -0
- package/dist/auto-surface/definition-dsl.d.mts.map +1 -0
- package/dist/auto-surface/definition-dsl.mjs +332 -0
- package/dist/auto-surface/definition-dsl.mjs.map +1 -0
- package/dist/auto-surface/fragments.cjs +177 -0
- package/dist/auto-surface/fragments.d.cts +23 -0
- package/dist/auto-surface/fragments.d.cts.map +1 -0
- package/dist/auto-surface/fragments.d.mts +23 -0
- package/dist/auto-surface/fragments.d.mts.map +1 -0
- package/dist/auto-surface/fragments.mjs +175 -0
- package/dist/auto-surface/fragments.mjs.map +1 -0
- package/dist/auto-surface/index.d.mts +9 -0
- package/dist/auto-surface/layering.cjs +43 -0
- package/dist/auto-surface/layering.d.cts +7 -0
- package/dist/auto-surface/layering.d.cts.map +1 -0
- package/dist/auto-surface/layering.d.mts +7 -0
- package/dist/auto-surface/layering.d.mts.map +1 -0
- package/dist/auto-surface/layering.mjs +43 -0
- package/dist/auto-surface/layering.mjs.map +1 -0
- package/dist/auto-surface/projection.cjs +11 -0
- package/dist/auto-surface/projection.d.cts +11 -0
- package/dist/auto-surface/projection.d.cts.map +1 -0
- package/dist/auto-surface/projection.d.mts +11 -0
- package/dist/auto-surface/projection.d.mts.map +1 -0
- package/dist/auto-surface/projection.mjs +12 -0
- package/dist/auto-surface/projection.mjs.map +1 -0
- package/dist/auto-surface/projectors/settings-shell.cjs +114 -0
- package/dist/auto-surface/projectors/settings-shell.d.cts +10 -0
- package/dist/auto-surface/projectors/settings-shell.d.cts.map +1 -0
- package/dist/auto-surface/projectors/settings-shell.d.mts +10 -0
- package/dist/auto-surface/projectors/settings-shell.d.mts.map +1 -0
- package/dist/auto-surface/projectors/settings-shell.mjs +114 -0
- package/dist/auto-surface/projectors/settings-shell.mjs.map +1 -0
- package/dist/auto-surface/scenario.cjs +38 -0
- package/dist/auto-surface/scenario.d.cts +31 -0
- package/dist/auto-surface/scenario.d.cts.map +1 -0
- package/dist/auto-surface/scenario.d.mts +31 -0
- package/dist/auto-surface/scenario.d.mts.map +1 -0
- package/dist/auto-surface/scenario.mjs +37 -0
- package/dist/auto-surface/scenario.mjs.map +1 -0
- package/dist/auto-surface/types.cjs +9 -0
- package/dist/auto-surface/types.d.cts +153 -0
- package/dist/auto-surface/types.d.cts.map +1 -0
- package/dist/auto-surface/types.d.mts +153 -0
- package/dist/auto-surface/types.d.mts.map +1 -0
- package/dist/auto-surface/types.mjs +9 -0
- package/dist/auto-surface/types.mjs.map +1 -0
- package/dist/auto-surface/value-dsl.cjs +80 -0
- package/dist/auto-surface/value-dsl.d.cts +24 -0
- package/dist/auto-surface/value-dsl.d.cts.map +1 -0
- package/dist/auto-surface/value-dsl.d.mts +24 -0
- package/dist/auto-surface/value-dsl.d.mts.map +1 -0
- package/dist/auto-surface/value-dsl.mjs +79 -0
- package/dist/auto-surface/value-dsl.mjs.map +1 -0
- package/dist/blocklet/activation.cjs +94 -0
- package/dist/blocklet/activation.d.cts +30 -0
- package/dist/blocklet/activation.d.cts.map +1 -0
- package/dist/blocklet/activation.d.mts +30 -0
- package/dist/blocklet/activation.d.mts.map +1 -0
- package/dist/blocklet/activation.mjs +94 -0
- package/dist/blocklet/activation.mjs.map +1 -0
- package/dist/blocklet/did-space-registry.cjs +282 -0
- package/dist/blocklet/did-space-registry.d.cts +82 -0
- package/dist/blocklet/did-space-registry.d.cts.map +1 -0
- package/dist/blocklet/did-space-registry.d.mts +82 -0
- package/dist/blocklet/did-space-registry.d.mts.map +1 -0
- package/dist/blocklet/did-space-registry.mjs +281 -0
- package/dist/blocklet/did-space-registry.mjs.map +1 -0
- package/dist/blocklet/handlers.cjs +66 -0
- package/dist/blocklet/handlers.d.cts +16 -0
- package/dist/blocklet/handlers.d.cts.map +1 -0
- package/dist/blocklet/handlers.d.mts +16 -0
- package/dist/blocklet/handlers.d.mts.map +1 -0
- package/dist/blocklet/handlers.mjs +65 -0
- package/dist/blocklet/handlers.mjs.map +1 -0
- package/dist/blocklet/index.d.mts +7 -0
- package/dist/blocklet/manifest.d.cts +2 -0
- package/dist/blocklet/manifest.d.mts +2 -0
- package/dist/blocklet/manifest.mjs +3 -0
- package/dist/blocklet/registry.cjs +447 -0
- package/dist/blocklet/registry.d.cts +197 -0
- package/dist/blocklet/registry.d.cts.map +1 -0
- package/dist/blocklet/registry.d.mts +197 -0
- package/dist/blocklet/registry.d.mts.map +1 -0
- package/dist/blocklet/registry.mjs +441 -0
- package/dist/blocklet/registry.mjs.map +1 -0
- package/dist/blocklet/static-render.cjs +183 -0
- package/dist/blocklet/static-render.d.cts +55 -0
- package/dist/blocklet/static-render.d.cts.map +1 -0
- package/dist/blocklet/static-render.d.mts +55 -0
- package/dist/blocklet/static-render.d.mts.map +1 -0
- package/dist/blocklet/static-render.mjs +181 -0
- package/dist/blocklet/static-render.mjs.map +1 -0
- package/dist/blocklet/types.d.cts +70 -0
- package/dist/blocklet/types.d.cts.map +1 -0
- package/dist/blocklet/types.d.mts +70 -0
- package/dist/blocklet/types.d.mts.map +1 -0
- package/dist/devices/chain.cjs +127 -0
- package/dist/devices/chain.d.cts +48 -0
- package/dist/devices/chain.d.cts.map +1 -0
- package/dist/devices/chain.d.mts +48 -0
- package/dist/devices/chain.d.mts.map +1 -0
- package/dist/devices/chain.mjs +125 -0
- package/dist/devices/chain.mjs.map +1 -0
- package/dist/dsl-shared.cjs +290 -0
- package/dist/dsl-shared.d.cts +54 -0
- package/dist/dsl-shared.d.cts.map +1 -0
- package/dist/dsl-shared.d.mts +54 -0
- package/dist/dsl-shared.d.mts.map +1 -0
- package/dist/dsl-shared.mjs +287 -0
- package/dist/dsl-shared.mjs.map +1 -0
- package/dist/http/afs-mcp.cjs +85 -0
- package/dist/http/afs-mcp.d.cts +14 -0
- package/dist/http/afs-mcp.d.cts.map +1 -0
- package/dist/http/afs-mcp.d.mts +14 -0
- package/dist/http/afs-mcp.d.mts.map +1 -0
- package/dist/http/afs-mcp.mjs +86 -0
- package/dist/http/afs-mcp.mjs.map +1 -0
- package/dist/http/afs-raw.cjs +264 -0
- package/dist/http/afs-raw.d.cts +31 -0
- package/dist/http/afs-raw.d.cts.map +1 -0
- package/dist/http/afs-raw.d.mts +31 -0
- package/dist/http/afs-raw.d.mts.map +1 -0
- package/dist/http/afs-raw.mjs +264 -0
- package/dist/http/afs-raw.mjs.map +1 -0
- package/dist/http/afs-rest.cjs +30 -0
- package/dist/http/afs-rest.d.cts +21 -0
- package/dist/http/afs-rest.d.cts.map +1 -0
- package/dist/http/afs-rest.d.mts +21 -0
- package/dist/http/afs-rest.d.mts.map +1 -0
- package/dist/http/afs-rest.mjs +31 -0
- package/dist/http/afs-rest.mjs.map +1 -0
- package/dist/http/afs-rpc-wire.cjs +271 -0
- package/dist/http/afs-rpc-wire.d.cts +195 -0
- package/dist/http/afs-rpc-wire.d.cts.map +1 -0
- package/dist/http/afs-rpc-wire.d.mts +195 -0
- package/dist/http/afs-rpc-wire.d.mts.map +1 -0
- package/dist/http/afs-rpc-wire.mjs +262 -0
- package/dist/http/afs-rpc-wire.mjs.map +1 -0
- package/dist/http/afs-rpc.cjs +729 -0
- package/dist/http/afs-rpc.d.cts +103 -0
- package/dist/http/afs-rpc.d.cts.map +1 -0
- package/dist/http/afs-rpc.d.mts +103 -0
- package/dist/http/afs-rpc.d.mts.map +1 -0
- package/dist/http/afs-rpc.mjs +729 -0
- package/dist/http/afs-rpc.mjs.map +1 -0
- package/dist/http/afs-upload.cjs +116 -0
- package/dist/http/afs-upload.d.cts +40 -0
- package/dist/http/afs-upload.d.cts.map +1 -0
- package/dist/http/afs-upload.d.mts +40 -0
- package/dist/http/afs-upload.d.mts.map +1 -0
- package/dist/http/afs-upload.mjs +116 -0
- package/dist/http/afs-upload.mjs.map +1 -0
- package/dist/http/aup-client.cjs +60 -0
- package/dist/http/aup-client.d.cts +22 -0
- package/dist/http/aup-client.d.cts.map +1 -0
- package/dist/http/aup-client.d.mts +22 -0
- package/dist/http/aup-client.d.mts.map +1 -0
- package/dist/http/aup-client.mjs +59 -0
- package/dist/http/aup-client.mjs.map +1 -0
- package/dist/http/aup-event.cjs +100 -0
- package/dist/http/aup-event.d.cts +38 -0
- package/dist/http/aup-event.d.cts.map +1 -0
- package/dist/http/aup-event.d.mts +38 -0
- package/dist/http/aup-event.d.mts.map +1 -0
- package/dist/http/aup-event.mjs +101 -0
- package/dist/http/aup-event.mjs.map +1 -0
- package/dist/http/auth-context.cjs +66 -0
- package/dist/http/auth-context.d.cts +64 -0
- package/dist/http/auth-context.d.cts.map +1 -0
- package/dist/http/auth-context.d.mts +64 -0
- package/dist/http/auth-context.d.mts.map +1 -0
- package/dist/http/auth-context.mjs +66 -0
- package/dist/http/auth-context.mjs.map +1 -0
- package/dist/http/csrf.cjs +50 -0
- package/dist/http/csrf.d.cts +8 -0
- package/dist/http/csrf.d.cts.map +1 -0
- package/dist/http/csrf.d.mts +8 -0
- package/dist/http/csrf.d.mts.map +1 -0
- package/dist/http/csrf.mjs +49 -0
- package/dist/http/csrf.mjs.map +1 -0
- package/dist/http/handlers.cjs +106 -0
- package/dist/http/handlers.d.cts +39 -0
- package/dist/http/handlers.d.cts.map +1 -0
- package/dist/http/handlers.d.mts +39 -0
- package/dist/http/handlers.d.mts.map +1 -0
- package/dist/http/handlers.mjs +104 -0
- package/dist/http/handlers.mjs.map +1 -0
- package/dist/http/index.d.mts +1 -0
- package/dist/http/ingest-facade.cjs +315 -0
- package/dist/http/ingest-facade.mjs +314 -0
- package/dist/http/ingest-facade.mjs.map +1 -0
- package/dist/http/raw-url.cjs +136 -0
- package/dist/http/raw-url.d.cts +54 -0
- package/dist/http/raw-url.d.cts.map +1 -0
- package/dist/http/raw-url.d.mts +54 -0
- package/dist/http/raw-url.d.mts.map +1 -0
- package/dist/http/raw-url.mjs +136 -0
- package/dist/http/raw-url.mjs.map +1 -0
- package/dist/http/request-context.cjs +178 -0
- package/dist/http/request-context.d.cts +76 -0
- package/dist/http/request-context.d.cts.map +1 -0
- package/dist/http/request-context.d.mts +76 -0
- package/dist/http/request-context.d.mts.map +1 -0
- package/dist/http/request-context.mjs +179 -0
- package/dist/http/request-context.mjs.map +1 -0
- package/dist/index.cjs +197 -0
- package/dist/index.d.cts +63 -0
- package/dist/index.d.mts +68 -0
- package/dist/index.mjs +61 -0
- package/dist/mcp/index.cjs +9 -0
- package/dist/mcp/index.d.cts +5 -0
- package/dist/mcp/index.d.mts +5 -0
- package/dist/mcp/index.mjs +6 -0
- package/dist/mcp/prompts.cjs +17 -0
- package/dist/mcp/prompts.d.cts +8 -0
- package/dist/mcp/prompts.d.cts.map +1 -0
- package/dist/mcp/prompts.d.mts +8 -0
- package/dist/mcp/prompts.d.mts.map +1 -0
- package/dist/mcp/prompts.mjs +17 -0
- package/dist/mcp/prompts.mjs.map +1 -0
- package/dist/mcp/resources.cjs +22 -0
- package/dist/mcp/resources.d.cts +8 -0
- package/dist/mcp/resources.d.cts.map +1 -0
- package/dist/mcp/resources.d.mts +8 -0
- package/dist/mcp/resources.d.mts.map +1 -0
- package/dist/mcp/resources.mjs +22 -0
- package/dist/mcp/resources.mjs.map +1 -0
- package/dist/mcp/server.cjs +51 -0
- package/dist/mcp/server.d.cts +20 -0
- package/dist/mcp/server.d.cts.map +1 -0
- package/dist/mcp/server.d.mts +20 -0
- package/dist/mcp/server.d.mts.map +1 -0
- package/dist/mcp/server.mjs +52 -0
- package/dist/mcp/server.mjs.map +1 -0
- package/dist/mcp/tools.cjs +218 -0
- package/dist/mcp/tools.d.cts +8 -0
- package/dist/mcp/tools.d.cts.map +1 -0
- package/dist/mcp/tools.d.mts +8 -0
- package/dist/mcp/tools.d.mts.map +1 -0
- package/dist/mcp/tools.mjs +219 -0
- package/dist/mcp/tools.mjs.map +1 -0
- package/dist/mcp/utils.cjs +75 -0
- package/dist/mcp/utils.mjs +69 -0
- package/dist/mcp/utils.mjs.map +1 -0
- package/dist/mount/index.cjs +4 -0
- package/dist/mount/index.d.cts +3 -0
- package/dist/mount/index.d.mts +3 -0
- package/dist/mount/index.mjs +3 -0
- package/dist/mount/materializer.cjs +167 -0
- package/dist/mount/materializer.d.cts +97 -0
- package/dist/mount/materializer.d.cts.map +1 -0
- package/dist/mount/materializer.d.mts +97 -0
- package/dist/mount/materializer.d.mts.map +1 -0
- package/dist/mount/materializer.mjs +167 -0
- package/dist/mount/materializer.mjs.map +1 -0
- package/dist/mount/types.d.cts +90 -0
- package/dist/mount/types.d.cts.map +1 -0
- package/dist/mount/types.d.mts +90 -0
- package/dist/mount/types.d.mts.map +1 -0
- package/dist/mount-config.cjs +61 -0
- package/dist/mount-config.d.cts +19 -0
- package/dist/mount-config.d.cts.map +1 -0
- package/dist/mount-config.d.mts +19 -0
- package/dist/mount-config.d.mts.map +1 -0
- package/dist/mount-config.mjs +61 -0
- package/dist/mount-config.mjs.map +1 -0
- package/dist/projectors/aup-projector.cjs +190 -0
- package/dist/projectors/aup-projector.d.cts +59 -0
- package/dist/projectors/aup-projector.d.cts.map +1 -0
- package/dist/projectors/aup-projector.d.mts +59 -0
- package/dist/projectors/aup-projector.d.mts.map +1 -0
- package/dist/projectors/aup-projector.mjs +188 -0
- package/dist/projectors/aup-projector.mjs.map +1 -0
- package/dist/projectors/index.cjs +6 -0
- package/dist/projectors/index.d.cts +2 -0
- package/dist/projectors/index.d.mts +2 -0
- package/dist/projectors/index.mjs +3 -0
- package/dist/scaffold/afs.cjs +195 -0
- package/dist/scaffold/afs.d.cts +16 -0
- package/dist/scaffold/afs.d.cts.map +1 -0
- package/dist/scaffold/afs.d.mts +16 -0
- package/dist/scaffold/afs.d.mts.map +1 -0
- package/dist/scaffold/afs.mjs +195 -0
- package/dist/scaffold/afs.mjs.map +1 -0
- package/dist/scaffold/composition.cjs +92 -0
- package/dist/scaffold/composition.d.cts +10 -0
- package/dist/scaffold/composition.d.cts.map +1 -0
- package/dist/scaffold/composition.d.mts +10 -0
- package/dist/scaffold/composition.d.mts.map +1 -0
- package/dist/scaffold/composition.mjs +92 -0
- package/dist/scaffold/composition.mjs.map +1 -0
- package/dist/scaffold/dsl-error.cjs +21 -0
- package/dist/scaffold/dsl-error.d.cts +11 -0
- package/dist/scaffold/dsl-error.d.cts.map +1 -0
- package/dist/scaffold/dsl-error.d.mts +11 -0
- package/dist/scaffold/dsl-error.d.mts.map +1 -0
- package/dist/scaffold/dsl-error.mjs +20 -0
- package/dist/scaffold/dsl-error.mjs.map +1 -0
- package/dist/scaffold/index.d.mts +12 -0
- package/dist/scaffold/manifest-dsl.cjs +188 -0
- package/dist/scaffold/manifest-dsl.d.cts +8 -0
- package/dist/scaffold/manifest-dsl.d.cts.map +1 -0
- package/dist/scaffold/manifest-dsl.d.mts +8 -0
- package/dist/scaffold/manifest-dsl.d.mts.map +1 -0
- package/dist/scaffold/manifest-dsl.mjs +188 -0
- package/dist/scaffold/manifest-dsl.mjs.map +1 -0
- package/dist/scaffold/module-dsl.cjs +284 -0
- package/dist/scaffold/module-dsl.d.cts +8 -0
- package/dist/scaffold/module-dsl.d.cts.map +1 -0
- package/dist/scaffold/module-dsl.d.mts +8 -0
- package/dist/scaffold/module-dsl.d.mts.map +1 -0
- package/dist/scaffold/module-dsl.mjs +284 -0
- package/dist/scaffold/module-dsl.mjs.map +1 -0
- package/dist/scaffold/resolver.cjs +156 -0
- package/dist/scaffold/resolver.d.cts +7 -0
- package/dist/scaffold/resolver.d.cts.map +1 -0
- package/dist/scaffold/resolver.d.mts +7 -0
- package/dist/scaffold/resolver.d.mts.map +1 -0
- package/dist/scaffold/resolver.mjs +156 -0
- package/dist/scaffold/resolver.mjs.map +1 -0
- package/dist/scaffold/runtime.cjs +24 -0
- package/dist/scaffold/runtime.d.cts +19 -0
- package/dist/scaffold/runtime.d.cts.map +1 -0
- package/dist/scaffold/runtime.d.mts +19 -0
- package/dist/scaffold/runtime.d.mts.map +1 -0
- package/dist/scaffold/runtime.mjs +25 -0
- package/dist/scaffold/runtime.mjs.map +1 -0
- package/dist/scaffold/shell-dsl.cjs +279 -0
- package/dist/scaffold/shell-dsl.d.cts +8 -0
- package/dist/scaffold/shell-dsl.d.cts.map +1 -0
- package/dist/scaffold/shell-dsl.d.mts +8 -0
- package/dist/scaffold/shell-dsl.d.mts.map +1 -0
- package/dist/scaffold/shell-dsl.mjs +279 -0
- package/dist/scaffold/shell-dsl.mjs.map +1 -0
- package/dist/scaffold/surface-dsl.cjs +182 -0
- package/dist/scaffold/surface-dsl.d.cts +8 -0
- package/dist/scaffold/surface-dsl.d.cts.map +1 -0
- package/dist/scaffold/surface-dsl.d.mts +8 -0
- package/dist/scaffold/surface-dsl.d.mts.map +1 -0
- package/dist/scaffold/surface-dsl.mjs +182 -0
- package/dist/scaffold/surface-dsl.mjs.map +1 -0
- package/dist/scaffold/surfaces.cjs +84 -0
- package/dist/scaffold/surfaces.d.cts +23 -0
- package/dist/scaffold/surfaces.d.cts.map +1 -0
- package/dist/scaffold/surfaces.d.mts +24 -0
- package/dist/scaffold/surfaces.d.mts.map +1 -0
- package/dist/scaffold/surfaces.mjs +84 -0
- package/dist/scaffold/surfaces.mjs.map +1 -0
- package/dist/scaffold/types.d.cts +264 -0
- package/dist/scaffold/types.d.cts.map +1 -0
- package/dist/scaffold/types.d.mts +265 -0
- package/dist/scaffold/types.d.mts.map +1 -0
- package/dist/scaffold/workspace-dsl.cjs +339 -0
- package/dist/scaffold/workspace-dsl.d.cts +49 -0
- package/dist/scaffold/workspace-dsl.d.cts.map +1 -0
- package/dist/scaffold/workspace-dsl.d.mts +49 -0
- package/dist/scaffold/workspace-dsl.d.mts.map +1 -0
- package/dist/scaffold/workspace-dsl.mjs +337 -0
- package/dist/scaffold/workspace-dsl.mjs.map +1 -0
- package/dist/scope/index.d.mts +3 -0
- package/dist/scope/read-blocklet-scope.cjs +29 -0
- package/dist/scope/read-blocklet-scope.d.cts +8 -0
- package/dist/scope/read-blocklet-scope.d.cts.map +1 -0
- package/dist/scope/read-blocklet-scope.d.mts +8 -0
- package/dist/scope/read-blocklet-scope.d.mts.map +1 -0
- package/dist/scope/read-blocklet-scope.mjs +30 -0
- package/dist/scope/read-blocklet-scope.mjs.map +1 -0
- package/dist/scope/resolve-scoped-afs.cjs +87 -0
- package/dist/scope/resolve-scoped-afs.d.cts +7 -0
- package/dist/scope/resolve-scoped-afs.d.cts.map +1 -0
- package/dist/scope/resolve-scoped-afs.d.mts +7 -0
- package/dist/scope/resolve-scoped-afs.d.mts.map +1 -0
- package/dist/scope/resolve-scoped-afs.mjs +88 -0
- package/dist/scope/resolve-scoped-afs.mjs.map +1 -0
- package/dist/scope/types.d.cts +25 -0
- package/dist/scope/types.d.cts.map +1 -0
- package/dist/scope/types.d.mts +25 -0
- package/dist/scope/types.d.mts.map +1 -0
- package/dist/session/backends.cjs +90 -0
- package/dist/session/backends.d.cts +35 -0
- package/dist/session/backends.d.cts.map +1 -0
- package/dist/session/backends.d.mts +35 -0
- package/dist/session/backends.d.mts.map +1 -0
- package/dist/session/backends.mjs +89 -0
- package/dist/session/backends.mjs.map +1 -0
- package/dist/session/replication-resolver.cjs +323 -0
- package/dist/session/replication-resolver.d.cts +71 -0
- package/dist/session/replication-resolver.d.cts.map +1 -0
- package/dist/session/replication-resolver.d.mts +71 -0
- package/dist/session/replication-resolver.d.mts.map +1 -0
- package/dist/session/replication-resolver.mjs +323 -0
- package/dist/session/replication-resolver.mjs.map +1 -0
- package/dist/session/role-level.cjs +36 -0
- package/dist/session/role-level.d.cts +24 -0
- package/dist/session/role-level.d.cts.map +1 -0
- package/dist/session/role-level.d.mts +24 -0
- package/dist/session/role-level.d.mts.map +1 -0
- package/dist/session/role-level.mjs +35 -0
- package/dist/session/role-level.mjs.map +1 -0
- package/dist/session/session-dir-providers.cjs +254 -0
- package/dist/session/session-dir-providers.d.cts +32 -0
- package/dist/session/session-dir-providers.d.cts.map +1 -0
- package/dist/session/session-dir-providers.d.mts +32 -0
- package/dist/session/session-dir-providers.d.mts.map +1 -0
- package/dist/session/session-dir-providers.mjs +252 -0
- package/dist/session/session-dir-providers.mjs.map +1 -0
- package/dist/session/session-id.cjs +20 -0
- package/dist/session/session-id.d.cts +15 -0
- package/dist/session/session-id.d.cts.map +1 -0
- package/dist/session/session-id.d.mts +15 -0
- package/dist/session/session-id.d.mts.map +1 -0
- package/dist/session/session-id.mjs +20 -0
- package/dist/session/session-id.mjs.map +1 -0
- package/dist/session/session-user-afs.cjs +899 -0
- package/dist/session/session-user-afs.d.cts +296 -0
- package/dist/session/session-user-afs.d.cts.map +1 -0
- package/dist/session/session-user-afs.d.mts +296 -0
- package/dist/session/session-user-afs.d.mts.map +1 -0
- package/dist/session/session-user-afs.mjs +896 -0
- package/dist/session/session-user-afs.mjs.map +1 -0
- package/dist/session/settings-cascade.cjs +69 -0
- package/dist/session/settings-cascade.d.cts +81 -0
- package/dist/session/settings-cascade.d.cts.map +1 -0
- package/dist/session/settings-cascade.d.mts +81 -0
- package/dist/session/settings-cascade.d.mts.map +1 -0
- package/dist/session/settings-cascade.mjs +69 -0
- package/dist/session/settings-cascade.mjs.map +1 -0
- package/dist/session/settings-resolver.cjs +770 -0
- package/dist/session/settings-resolver.d.cts +177 -0
- package/dist/session/settings-resolver.d.cts.map +1 -0
- package/dist/session/settings-resolver.d.mts +177 -0
- package/dist/session/settings-resolver.d.mts.map +1 -0
- package/dist/session/settings-resolver.mjs +771 -0
- package/dist/session/settings-resolver.mjs.map +1 -0
- package/dist/session/settings-schema-store.cjs +0 -0
- package/dist/session/settings-schema-store.d.cts +72 -0
- package/dist/session/settings-schema-store.d.cts.map +1 -0
- package/dist/session/settings-schema-store.d.mts +72 -0
- package/dist/session/settings-schema-store.d.mts.map +1 -0
- package/dist/session/settings-schema-store.mjs +0 -0
- package/dist/session/settings-schema-store.mjs.map +1 -0
- package/dist/system-mounts/index.cjs +14 -0
- package/dist/system-mounts/index.d.cts +6 -0
- package/dist/system-mounts/index.d.mts +6 -0
- package/dist/system-mounts/index.mjs +6 -0
- package/dist/system-mounts/install.cjs +101 -0
- package/dist/system-mounts/install.d.cts +36 -0
- package/dist/system-mounts/install.d.cts.map +1 -0
- package/dist/system-mounts/install.d.mts +37 -0
- package/dist/system-mounts/install.d.mts.map +1 -0
- package/dist/system-mounts/install.mjs +102 -0
- package/dist/system-mounts/install.mjs.map +1 -0
- package/dist/system-mounts/installers.cjs +247 -0
- package/dist/system-mounts/installers.d.cts +13 -0
- package/dist/system-mounts/installers.d.cts.map +1 -0
- package/dist/system-mounts/installers.d.mts +14 -0
- package/dist/system-mounts/installers.d.mts.map +1 -0
- package/dist/system-mounts/installers.mjs +244 -0
- package/dist/system-mounts/installers.mjs.map +1 -0
- package/dist/system-mounts/lists.cjs +122 -0
- package/dist/system-mounts/lists.d.cts +34 -0
- package/dist/system-mounts/lists.d.cts.map +1 -0
- package/dist/system-mounts/lists.d.mts +34 -0
- package/dist/system-mounts/lists.d.mts.map +1 -0
- package/dist/system-mounts/lists.mjs +122 -0
- package/dist/system-mounts/lists.mjs.map +1 -0
- package/dist/system-mounts/types.d.cts +124 -0
- package/dist/system-mounts/types.d.cts.map +1 -0
- package/dist/system-mounts/types.d.mts +125 -0
- package/dist/system-mounts/types.d.mts.map +1 -0
- package/dist/system-mounts/validate.cjs +56 -0
- package/dist/system-mounts/validate.d.cts +34 -0
- package/dist/system-mounts/validate.d.cts.map +1 -0
- package/dist/system-mounts/validate.d.mts +34 -0
- package/dist/system-mounts/validate.d.mts.map +1 -0
- package/dist/system-mounts/validate.mjs +56 -0
- package/dist/system-mounts/validate.mjs.map +1 -0
- package/dist/terminal-llm.cjs +90 -0
- package/dist/terminal-llm.d.cts +50 -0
- package/dist/terminal-llm.d.cts.map +1 -0
- package/dist/terminal-llm.d.mts +50 -0
- package/dist/terminal-llm.d.mts.map +1 -0
- package/dist/terminal-llm.mjs +90 -0
- package/dist/terminal-llm.mjs.map +1 -0
- package/dist/terminal-repl.cjs +371 -0
- package/dist/terminal-repl.d.cts +69 -0
- package/dist/terminal-repl.d.cts.map +1 -0
- package/dist/terminal-repl.d.mts +69 -0
- package/dist/terminal-repl.d.mts.map +1 -0
- package/dist/terminal-repl.mjs +370 -0
- package/dist/terminal-repl.mjs.map +1 -0
- package/dist/transport/idle-timer.cjs +136 -0
- package/dist/transport/idle-timer.d.cts +92 -0
- package/dist/transport/idle-timer.d.cts.map +1 -0
- package/dist/transport/idle-timer.d.mts +92 -0
- package/dist/transport/idle-timer.d.mts.map +1 -0
- package/dist/transport/idle-timer.mjs +132 -0
- package/dist/transport/idle-timer.mjs.map +1 -0
- package/dist/web-component-dsl.cjs +153 -0
- package/dist/web-component-dsl.d.cts +27 -0
- package/dist/web-component-dsl.d.cts.map +1 -0
- package/dist/web-component-dsl.d.mts +27 -0
- package/dist/web-component-dsl.d.mts.map +1 -0
- package/dist/web-component-dsl.mjs +152 -0
- package/dist/web-component-dsl.mjs.map +1 -0
- package/package.json +81 -0
|
@@ -0,0 +1,271 @@
|
|
|
1
|
+
|
|
2
|
+
//#region src/http/afs-rpc-wire.ts
|
|
3
|
+
/**
|
|
4
|
+
* afs-rpc wire contract — encoding + validation helpers.
|
|
5
|
+
*
|
|
6
|
+
* Single source of truth for the binary content encoding (base64) and the
|
|
7
|
+
* write/delete body validation rules pinned in
|
|
8
|
+
* `planning/did-integration/mobile-didspace-transport/wire-contract.md`.
|
|
9
|
+
*
|
|
10
|
+
* Both runtime handlers (Node `daemon/server.ts`, Cloudflare `index.ts`) share
|
|
11
|
+
* `createAfsRpcHandler`; this module is where the write/delete dispatch (Phase
|
|
12
|
+
* 4) decodes `content` and enforces field-position rules. Defined in Phase 0
|
|
13
|
+
* so the contract is frozen before any implementation.
|
|
14
|
+
*/
|
|
15
|
+
/** Stable error codes surfaced on the wire (see wire-contract.md §7/§9). */
|
|
16
|
+
const WIRE_ERROR_CODES = {
|
|
17
|
+
conflict: "AFS_CONFLICT",
|
|
18
|
+
payloadTooLarge: "PAYLOAD_TOO_LARGE",
|
|
19
|
+
batchOverBudget: "BATCH_OVER_BUDGET",
|
|
20
|
+
batchTailSkipped: "BATCH_TAIL_SKIPPED",
|
|
21
|
+
fileTooLarge: "FILE_TOO_LARGE"
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Extract the JWT from an `Authorization: Bearer <jwt>` header, or null when
|
|
25
|
+
* absent/malformed. Shared by both runtimes' `resolveCaller` (Phase 4) so the
|
|
26
|
+
* Bearer parsing is single-sourced and case-insensitive on the scheme.
|
|
27
|
+
*/
|
|
28
|
+
function parseBearerToken(header) {
|
|
29
|
+
if (!header) return null;
|
|
30
|
+
const token = /^Bearer\s+(.+)$/i.exec(header)?.[1]?.trim();
|
|
31
|
+
return token ? token : null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Decode a base64 string into bytes. Pure; no DOM/Buffer assumptions beyond
|
|
35
|
+
* `atob` (present in workerd + Node 18+ globalThis). Throws on malformed input.
|
|
36
|
+
*/
|
|
37
|
+
function decodeContentBase64(b64) {
|
|
38
|
+
const binary = atob(b64);
|
|
39
|
+
const bytes = new Uint8Array(binary.length);
|
|
40
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
41
|
+
return bytes;
|
|
42
|
+
}
|
|
43
|
+
/** Encode bytes into a base64 string. Inverse of {@link decodeContentBase64}. */
|
|
44
|
+
function encodeContentBase64(bytes) {
|
|
45
|
+
let binary = "";
|
|
46
|
+
const CHUNK = 32768;
|
|
47
|
+
for (let i = 0; i < bytes.length; i += CHUNK) binary += String.fromCharCode(...bytes.subarray(i, i + CHUNK));
|
|
48
|
+
return btoa(binary);
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Validate + decode a `write` body per the wire contract.
|
|
52
|
+
*
|
|
53
|
+
* Enforces:
|
|
54
|
+
* - `content` present and `encoding === "base64"` (missing/other → 400).
|
|
55
|
+
* The empty string IS present — it is the canonical base64 of a 0-byte
|
|
56
|
+
* file, which must roundtrip (P6 crafted-sample finding; rejecting it
|
|
57
|
+
* made empty files unsyncable on every client).
|
|
58
|
+
* - `content` is valid base64 (bad → 400).
|
|
59
|
+
*
|
|
60
|
+
* Does NOT touch `options.ifMatch` placement: the field-position rule
|
|
61
|
+
* (ifMatch belongs at `options.ifMatch`, never `options.meta.ifMatch` for
|
|
62
|
+
* writes) is enforced by the handler reading ONLY `options.ifMatch`. A
|
|
63
|
+
* misplaced `meta.ifMatch` is simply ignored (treated as absent top-level
|
|
64
|
+
* ifMatch → LWW), per wire-contract.md §8.3.
|
|
65
|
+
*/
|
|
66
|
+
function validateAndDecodeWrite(body) {
|
|
67
|
+
if (typeof body.content !== "string") return {
|
|
68
|
+
ok: false,
|
|
69
|
+
status: 400,
|
|
70
|
+
error: "Missing 'content' for write"
|
|
71
|
+
};
|
|
72
|
+
const encoding = body.encoding ?? "base64";
|
|
73
|
+
if (encoding !== "base64") return {
|
|
74
|
+
ok: false,
|
|
75
|
+
status: 400,
|
|
76
|
+
error: `Unsupported encoding '${encoding}' (use base64)`
|
|
77
|
+
};
|
|
78
|
+
let bytes;
|
|
79
|
+
try {
|
|
80
|
+
bytes = decodeContentBase64(body.content);
|
|
81
|
+
} catch {
|
|
82
|
+
return {
|
|
83
|
+
ok: false,
|
|
84
|
+
status: 400,
|
|
85
|
+
error: "Invalid base64 in 'content'"
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return {
|
|
89
|
+
ok: true,
|
|
90
|
+
bytes
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Read the top-level write ifMatch precondition. The misplaced
|
|
95
|
+
* `options.meta.ifMatch` is intentionally NOT consulted for writes — only
|
|
96
|
+
* `delete` carries ifMatch under `meta`.
|
|
97
|
+
*/
|
|
98
|
+
function readWriteIfMatch(options) {
|
|
99
|
+
const v = options?.ifMatch;
|
|
100
|
+
return typeof v === "string" ? v : void 0;
|
|
101
|
+
}
|
|
102
|
+
const MB = 1024 * 1024;
|
|
103
|
+
/** Cloudflare-tier limits (free-tier portability baseline; P0-confirmed). */
|
|
104
|
+
const BATCH_LIMITS_CF = {
|
|
105
|
+
maxWriteEntries: 20,
|
|
106
|
+
maxDeleteEntries: 40,
|
|
107
|
+
maxReadEntries: 20,
|
|
108
|
+
maxWriteBatchBytes: 1 * MB,
|
|
109
|
+
maxEntryWriteBytes: 16 * MB,
|
|
110
|
+
readTailSkipThresholdBytes: 4 * MB,
|
|
111
|
+
maxEncodedRequestBytes: 24 * MB
|
|
112
|
+
};
|
|
113
|
+
/** Node-daemon limits (no subrequest budget; bounded by memory/UX only). */
|
|
114
|
+
const BATCH_LIMITS_NODE = {
|
|
115
|
+
maxWriteEntries: 100,
|
|
116
|
+
maxDeleteEntries: 100,
|
|
117
|
+
maxReadEntries: 100,
|
|
118
|
+
maxWriteBatchBytes: 16 * MB,
|
|
119
|
+
maxEntryWriteBytes: 16 * MB,
|
|
120
|
+
readTailSkipThresholdBytes: 4 * MB,
|
|
121
|
+
maxEncodedRequestBytes: 24 * MB
|
|
122
|
+
};
|
|
123
|
+
const BATCH_FORBIDDEN_ENTRY_FIELDS = ["blocklet", "sessionId"];
|
|
124
|
+
function maxEntriesFor(type, limits) {
|
|
125
|
+
if (type === "batchWrite") return limits.maxWriteEntries;
|
|
126
|
+
if (type === "batchDelete") return limits.maxDeleteEntries;
|
|
127
|
+
return limits.maxReadEntries;
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Envelope-level validation for the three batch ops (wire-contract §9).
|
|
131
|
+
*
|
|
132
|
+
* Envelope rejections (zero entries executed): entries shape, per-type
|
|
133
|
+
* maxEntries / Σ-decoded-bytes budget (400 BATCH_OVER_BUDGET), forbidden
|
|
134
|
+
* per-entry `blocklet`/`sessionId` fields, invalid/traversal paths, and a
|
|
135
|
+
* single entry over the per-entry decoded cap (413 PAYLOAD_TOO_LARGE — the
|
|
136
|
+
* single-op code).
|
|
137
|
+
*
|
|
138
|
+
* Content-shape problems (missing/empty content, unknown encoding, bad
|
|
139
|
+
* base64) are NOT envelope rejections: single-op parity says each such entry
|
|
140
|
+
* fails alone, so they come back as per-entry decode outcomes in
|
|
141
|
+
* `writeDecodes` for the dispatch loop to surface as `results[i]`.
|
|
142
|
+
*/
|
|
143
|
+
function validateBatchBody(body, limits, sanitizePath) {
|
|
144
|
+
const type = body.type ?? "";
|
|
145
|
+
const entries = body.entries;
|
|
146
|
+
if (!Array.isArray(entries) || entries.length === 0) return {
|
|
147
|
+
ok: false,
|
|
148
|
+
status: 400,
|
|
149
|
+
error: "'entries' must be a non-empty array"
|
|
150
|
+
};
|
|
151
|
+
const maxEntries = maxEntriesFor(type, limits);
|
|
152
|
+
if (entries.length > maxEntries) return {
|
|
153
|
+
ok: false,
|
|
154
|
+
status: 400,
|
|
155
|
+
error: `Too many entries for ${type} (${entries.length} > ${maxEntries})`,
|
|
156
|
+
code: WIRE_ERROR_CODES.batchOverBudget
|
|
157
|
+
};
|
|
158
|
+
for (let i = 0; i < entries.length; i++) {
|
|
159
|
+
const entry = entries[i];
|
|
160
|
+
if (typeof entry !== "object" || entry === null || Array.isArray(entry)) return {
|
|
161
|
+
ok: false,
|
|
162
|
+
status: 400,
|
|
163
|
+
error: `entries[${i}] must be an object`
|
|
164
|
+
};
|
|
165
|
+
for (const field of BATCH_FORBIDDEN_ENTRY_FIELDS) if (field in entry) return {
|
|
166
|
+
ok: false,
|
|
167
|
+
status: 400,
|
|
168
|
+
error: `entries[${i}] must not carry '${field}' (envelope-level field)`
|
|
169
|
+
};
|
|
170
|
+
const path = entry.path;
|
|
171
|
+
if (typeof path !== "string" || sanitizePath(path) === null) return {
|
|
172
|
+
ok: false,
|
|
173
|
+
status: 400,
|
|
174
|
+
error: `entries[${i}] has a missing or invalid 'path'`
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
if (type !== "batchWrite") return {
|
|
178
|
+
ok: true,
|
|
179
|
+
entries
|
|
180
|
+
};
|
|
181
|
+
const writeDecodes = [];
|
|
182
|
+
let totalDecoded = 0;
|
|
183
|
+
for (const raw of entries) {
|
|
184
|
+
const decoded = validateAndDecodeWrite({
|
|
185
|
+
type: "write",
|
|
186
|
+
path: raw.path,
|
|
187
|
+
content: raw.content,
|
|
188
|
+
encoding: raw.encoding,
|
|
189
|
+
options: raw.options
|
|
190
|
+
});
|
|
191
|
+
if (!decoded.ok) {
|
|
192
|
+
writeDecodes.push(decoded);
|
|
193
|
+
continue;
|
|
194
|
+
}
|
|
195
|
+
if (decoded.bytes.length > limits.maxEntryWriteBytes) return {
|
|
196
|
+
ok: false,
|
|
197
|
+
status: 413,
|
|
198
|
+
error: `Payload too large (> ${limits.maxEntryWriteBytes} bytes)`,
|
|
199
|
+
code: WIRE_ERROR_CODES.payloadTooLarge
|
|
200
|
+
};
|
|
201
|
+
totalDecoded += decoded.bytes.length;
|
|
202
|
+
writeDecodes.push(decoded);
|
|
203
|
+
}
|
|
204
|
+
if (totalDecoded > limits.maxWriteBatchBytes) return {
|
|
205
|
+
ok: false,
|
|
206
|
+
status: 400,
|
|
207
|
+
error: `Batch decoded bytes over budget (${totalDecoded} > ${limits.maxWriteBatchBytes})`,
|
|
208
|
+
code: WIRE_ERROR_CODES.batchOverBudget
|
|
209
|
+
};
|
|
210
|
+
return {
|
|
211
|
+
ok: true,
|
|
212
|
+
entries,
|
|
213
|
+
writeDecodes
|
|
214
|
+
};
|
|
215
|
+
}
|
|
216
|
+
/**
|
|
217
|
+
* Read the request body with a hard byte ceiling, BEFORE any JSON parsing.
|
|
218
|
+
*
|
|
219
|
+
* Two layers: a fast Content-Length pre-check (rejects honest oversized
|
|
220
|
+
* declarations without reading), then a bounded stream read (rejects lying
|
|
221
|
+
* Content-Length — declared small, actually large). Returns `{ tooLarge }`
|
|
222
|
+
* instead of throwing so the caller can shape the 413 response.
|
|
223
|
+
*/
|
|
224
|
+
async function readBoundedBody(request, maxBytes) {
|
|
225
|
+
const declared = Number(request.headers.get("content-length") ?? "");
|
|
226
|
+
if (Number.isFinite(declared) && declared > maxBytes) return { tooLarge: true };
|
|
227
|
+
const reader = request.body?.getReader();
|
|
228
|
+
if (!reader) {
|
|
229
|
+
const text = await request.text();
|
|
230
|
+
return text.length > maxBytes ? { tooLarge: true } : {
|
|
231
|
+
tooLarge: false,
|
|
232
|
+
text
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
const chunks = [];
|
|
236
|
+
let total = 0;
|
|
237
|
+
while (true) {
|
|
238
|
+
const { done, value } = await reader.read();
|
|
239
|
+
if (done) break;
|
|
240
|
+
total += value.byteLength;
|
|
241
|
+
if (total > maxBytes) {
|
|
242
|
+
try {
|
|
243
|
+
await reader.cancel();
|
|
244
|
+
} catch {}
|
|
245
|
+
return { tooLarge: true };
|
|
246
|
+
}
|
|
247
|
+
chunks.push(value);
|
|
248
|
+
}
|
|
249
|
+
const buf = new Uint8Array(total);
|
|
250
|
+
let offset = 0;
|
|
251
|
+
for (const chunk of chunks) {
|
|
252
|
+
buf.set(chunk, offset);
|
|
253
|
+
offset += chunk.byteLength;
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
tooLarge: false,
|
|
257
|
+
text: new TextDecoder().decode(buf)
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
//#endregion
|
|
262
|
+
exports.BATCH_LIMITS_CF = BATCH_LIMITS_CF;
|
|
263
|
+
exports.BATCH_LIMITS_NODE = BATCH_LIMITS_NODE;
|
|
264
|
+
exports.WIRE_ERROR_CODES = WIRE_ERROR_CODES;
|
|
265
|
+
exports.decodeContentBase64 = decodeContentBase64;
|
|
266
|
+
exports.encodeContentBase64 = encodeContentBase64;
|
|
267
|
+
exports.parseBearerToken = parseBearerToken;
|
|
268
|
+
exports.readBoundedBody = readBoundedBody;
|
|
269
|
+
exports.readWriteIfMatch = readWriteIfMatch;
|
|
270
|
+
exports.validateAndDecodeWrite = validateAndDecodeWrite;
|
|
271
|
+
exports.validateBatchBody = validateBatchBody;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
//#region src/http/afs-rpc-wire.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* afs-rpc wire contract — encoding + validation helpers.
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth for the binary content encoding (base64) and the
|
|
6
|
+
* write/delete body validation rules pinned in
|
|
7
|
+
* `planning/did-integration/mobile-didspace-transport/wire-contract.md`.
|
|
8
|
+
*
|
|
9
|
+
* Both runtime handlers (Node `daemon/server.ts`, Cloudflare `index.ts`) share
|
|
10
|
+
* `createAfsRpcHandler`; this module is where the write/delete dispatch (Phase
|
|
11
|
+
* 4) decodes `content` and enforces field-position rules. Defined in Phase 0
|
|
12
|
+
* so the contract is frozen before any implementation.
|
|
13
|
+
*/
|
|
14
|
+
/** Stable error codes surfaced on the wire (see wire-contract.md §7/§9). */
|
|
15
|
+
declare const WIRE_ERROR_CODES: {
|
|
16
|
+
readonly conflict: "AFS_CONFLICT";
|
|
17
|
+
readonly payloadTooLarge: "PAYLOAD_TOO_LARGE"; /** Batch envelope rejected up-front (entry count / Σ bytes) — zero entries executed. */
|
|
18
|
+
readonly batchOverBudget: "BATCH_OVER_BUDGET"; /** batchRead tail entry skipped (encoded-byte threshold reached) — retry next batch. */
|
|
19
|
+
readonly batchTailSkipped: "BATCH_TAIL_SKIPPED";
|
|
20
|
+
/**
|
|
21
|
+
* Declared-size upload rejected BEFORE any bytes move (ingest-prepare early
|
|
22
|
+
* reject — DID-Space upload-limits, design §8 / D7). Distinct from
|
|
23
|
+
* `PAYLOAD_TOO_LARGE` ("actual decoded bytes over the cap"): `FILE_TOO_LARGE`
|
|
24
|
+
* fires on the client-declared size at the planning stage, is per-entry, and
|
|
25
|
+
* is never auto-retried by the sync engine.
|
|
26
|
+
*/
|
|
27
|
+
readonly fileTooLarge: "FILE_TOO_LARGE";
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Extract the JWT from an `Authorization: Bearer <jwt>` header, or null when
|
|
31
|
+
* absent/malformed. Shared by both runtimes' `resolveCaller` (Phase 4) so the
|
|
32
|
+
* Bearer parsing is single-sourced and case-insensitive on the scheme.
|
|
33
|
+
*/
|
|
34
|
+
declare function parseBearerToken(header: string | null | undefined): string | null;
|
|
35
|
+
/** Only encoding understood today. `bypass` (D-A) is reserved for large blobs. */
|
|
36
|
+
type WireEncoding = "base64";
|
|
37
|
+
/** Shape of a `write` RpcBody after JSON parse, before decoding. */
|
|
38
|
+
interface RpcWriteBody {
|
|
39
|
+
type: "write";
|
|
40
|
+
path?: string;
|
|
41
|
+
content?: string;
|
|
42
|
+
encoding?: string;
|
|
43
|
+
contentType?: string;
|
|
44
|
+
options?: {
|
|
45
|
+
ifMatch?: unknown;
|
|
46
|
+
meta?: {
|
|
47
|
+
deviceId?: unknown;
|
|
48
|
+
mtime?: unknown;
|
|
49
|
+
ifMatch?: unknown;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
type WireValidation = {
|
|
54
|
+
ok: true;
|
|
55
|
+
bytes: Uint8Array;
|
|
56
|
+
} | {
|
|
57
|
+
ok: false;
|
|
58
|
+
status: number;
|
|
59
|
+
error: string;
|
|
60
|
+
code?: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Decode a base64 string into bytes. Pure; no DOM/Buffer assumptions beyond
|
|
64
|
+
* `atob` (present in workerd + Node 18+ globalThis). Throws on malformed input.
|
|
65
|
+
*/
|
|
66
|
+
declare function decodeContentBase64(b64: string): Uint8Array;
|
|
67
|
+
/** Encode bytes into a base64 string. Inverse of {@link decodeContentBase64}. */
|
|
68
|
+
declare function encodeContentBase64(bytes: Uint8Array): string;
|
|
69
|
+
/**
|
|
70
|
+
* Validate + decode a `write` body per the wire contract.
|
|
71
|
+
*
|
|
72
|
+
* Enforces:
|
|
73
|
+
* - `content` present and `encoding === "base64"` (missing/other → 400).
|
|
74
|
+
* The empty string IS present — it is the canonical base64 of a 0-byte
|
|
75
|
+
* file, which must roundtrip (P6 crafted-sample finding; rejecting it
|
|
76
|
+
* made empty files unsyncable on every client).
|
|
77
|
+
* - `content` is valid base64 (bad → 400).
|
|
78
|
+
*
|
|
79
|
+
* Does NOT touch `options.ifMatch` placement: the field-position rule
|
|
80
|
+
* (ifMatch belongs at `options.ifMatch`, never `options.meta.ifMatch` for
|
|
81
|
+
* writes) is enforced by the handler reading ONLY `options.ifMatch`. A
|
|
82
|
+
* misplaced `meta.ifMatch` is simply ignored (treated as absent top-level
|
|
83
|
+
* ifMatch → LWW), per wire-contract.md §8.3.
|
|
84
|
+
*/
|
|
85
|
+
declare function validateAndDecodeWrite(body: RpcWriteBody): WireValidation;
|
|
86
|
+
/**
|
|
87
|
+
* Read the top-level write ifMatch precondition. The misplaced
|
|
88
|
+
* `options.meta.ifMatch` is intentionally NOT consulted for writes — only
|
|
89
|
+
* `delete` carries ifMatch under `meta`.
|
|
90
|
+
*/
|
|
91
|
+
declare function readWriteIfMatch(options: RpcWriteBody["options"]): string | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Per-type batch limits — the wire-contract §9 constant table. These are
|
|
94
|
+
* CONTRACT constants (clients mirror the same numbers when packing batches;
|
|
95
|
+
* no negotiation endpoint), injected into `createAfsRpcHandler` per runtime.
|
|
96
|
+
* Derived from the worst-case subrequest costs measured in P0
|
|
97
|
+
* (planning/afs-rpc-batch/p0-measurements.md).
|
|
98
|
+
*/
|
|
99
|
+
interface BatchLimits {
|
|
100
|
+
/** Max entries per batchWrite envelope. */
|
|
101
|
+
maxWriteEntries: number;
|
|
102
|
+
/** Max entries per batchDelete envelope. */
|
|
103
|
+
maxDeleteEntries: number;
|
|
104
|
+
/** Max entries per batchRead envelope. */
|
|
105
|
+
maxReadEntries: number;
|
|
106
|
+
/** Σ decoded bytes cap across a batchWrite envelope (400 BATCH_OVER_BUDGET). */
|
|
107
|
+
maxWriteBatchBytes: number;
|
|
108
|
+
/** Single-entry decoded cap (413 PAYLOAD_TOO_LARGE — same code as single op). */
|
|
109
|
+
maxEntryWriteBytes: number;
|
|
110
|
+
/**
|
|
111
|
+
* batchRead tail-truncation threshold, accumulated over ENCODED (base64
|
|
112
|
+
* response) bytes. NOT a hard response cap: the entry that crosses it is
|
|
113
|
+
* still returned in full (never read-then-discard); subsequent entries get
|
|
114
|
+
* 503 BATCH_TAIL_SKIPPED without being read.
|
|
115
|
+
*/
|
|
116
|
+
readTailSkipThresholdBytes: number;
|
|
117
|
+
/**
|
|
118
|
+
* Pre-parse cap on the ENCODED request body (whole endpoint, not just
|
|
119
|
+
* batch): checked against Content-Length AND enforced by bounded read
|
|
120
|
+
* BEFORE `request.json()`, so an unauthenticated oversized body can't buy
|
|
121
|
+
* parse CPU/memory. Covers single-op 16MB decoded ≈ 21.4MB encoded + slack.
|
|
122
|
+
*/
|
|
123
|
+
maxEncodedRequestBytes: number;
|
|
124
|
+
}
|
|
125
|
+
/** Cloudflare-tier limits (free-tier portability baseline; P0-confirmed). */
|
|
126
|
+
declare const BATCH_LIMITS_CF: BatchLimits;
|
|
127
|
+
/** Node-daemon limits (no subrequest budget; bounded by memory/UX only). */
|
|
128
|
+
declare const BATCH_LIMITS_NODE: BatchLimits;
|
|
129
|
+
/** batchWrite entry = single-op write body minus type/blocklet/sessionId. */
|
|
130
|
+
interface BatchWriteWireEntry {
|
|
131
|
+
path: string;
|
|
132
|
+
content?: string;
|
|
133
|
+
encoding?: string;
|
|
134
|
+
contentType?: string;
|
|
135
|
+
options?: Record<string, unknown>;
|
|
136
|
+
/**
|
|
137
|
+
* Application metadata (createdAt / updatedAt / …) carried on the entry's
|
|
138
|
+
* top-level `meta` — distinct from `options.meta` (sync provenance). Forwarded
|
|
139
|
+
* to `AFSWriteEntryPayload.meta` so metadata-aware providers index it.
|
|
140
|
+
*/
|
|
141
|
+
meta?: Record<string, unknown>;
|
|
142
|
+
}
|
|
143
|
+
/** batchDelete entry — ifMatch/provenance ride options.meta, like single op. */
|
|
144
|
+
interface BatchDeleteWireEntry {
|
|
145
|
+
path: string;
|
|
146
|
+
options?: Record<string, unknown>;
|
|
147
|
+
}
|
|
148
|
+
/** batchRead entry — `optional` mirrors the single-op wire field. */
|
|
149
|
+
interface BatchReadWireEntry {
|
|
150
|
+
path: string;
|
|
151
|
+
optional?: boolean;
|
|
152
|
+
options?: Record<string, unknown>;
|
|
153
|
+
}
|
|
154
|
+
type BatchWireEntry = BatchWriteWireEntry & BatchDeleteWireEntry & BatchReadWireEntry;
|
|
155
|
+
/** Per-entry decode outcome for batchWrite (aligned by index with entries). */
|
|
156
|
+
type BatchWriteDecode = {
|
|
157
|
+
ok: true;
|
|
158
|
+
bytes: Uint8Array;
|
|
159
|
+
} | {
|
|
160
|
+
ok: false;
|
|
161
|
+
status: number;
|
|
162
|
+
error: string;
|
|
163
|
+
code?: string;
|
|
164
|
+
};
|
|
165
|
+
type BatchValidation = {
|
|
166
|
+
ok: true;
|
|
167
|
+
entries: BatchWireEntry[];
|
|
168
|
+
writeDecodes?: BatchWriteDecode[];
|
|
169
|
+
} | {
|
|
170
|
+
ok: false;
|
|
171
|
+
status: number;
|
|
172
|
+
error: string;
|
|
173
|
+
code?: string;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Envelope-level validation for the three batch ops (wire-contract §9).
|
|
177
|
+
*
|
|
178
|
+
* Envelope rejections (zero entries executed): entries shape, per-type
|
|
179
|
+
* maxEntries / Σ-decoded-bytes budget (400 BATCH_OVER_BUDGET), forbidden
|
|
180
|
+
* per-entry `blocklet`/`sessionId` fields, invalid/traversal paths, and a
|
|
181
|
+
* single entry over the per-entry decoded cap (413 PAYLOAD_TOO_LARGE — the
|
|
182
|
+
* single-op code).
|
|
183
|
+
*
|
|
184
|
+
* Content-shape problems (missing/empty content, unknown encoding, bad
|
|
185
|
+
* base64) are NOT envelope rejections: single-op parity says each such entry
|
|
186
|
+
* fails alone, so they come back as per-entry decode outcomes in
|
|
187
|
+
* `writeDecodes` for the dispatch loop to surface as `results[i]`.
|
|
188
|
+
*/
|
|
189
|
+
declare function validateBatchBody(body: {
|
|
190
|
+
type?: string;
|
|
191
|
+
entries?: unknown;
|
|
192
|
+
}, limits: BatchLimits, sanitizePath: (path: string) => string | null): BatchValidation;
|
|
193
|
+
//#endregion
|
|
194
|
+
export { BATCH_LIMITS_CF, BATCH_LIMITS_NODE, BatchDeleteWireEntry, BatchLimits, BatchReadWireEntry, BatchWriteWireEntry, RpcWriteBody, WIRE_ERROR_CODES, WireEncoding, WireValidation, decodeContentBase64, encodeContentBase64, parseBearerToken, readWriteIfMatch, validateAndDecodeWrite, validateBatchBody };
|
|
195
|
+
//# sourceMappingURL=afs-rpc-wire.d.cts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"afs-rpc-wire.d.cts","names":[],"sources":["../../src/http/afs-rpc-wire.ts"],"mappings":";;AAcA;;;;;;;;;;;AAsBA;AAAA,cAtBa,gBAAA;EAAA;iDAsBqD;EAAA,+CAQ1C;EAAA;EAAA;;AAGxB;;;;;EAHwB;;;;;;;iBARR,gBAAA,CAAiB,MAAA;;KAQrB,YAAA;;UAGK,YAAA;EACf,IAAA;EACA,IAAA;EACA,OAAA;EACA,QAAA;EACA,WAAA;EACA,OAAA;IACE,OAAA;IACA,IAAA;MAAS,QAAA;MAAoB,KAAA;MAAiB,OAAA;IAAA;EAAA;AAAA;AAAA,KAItC,cAAA;EACN,EAAA;EAAU,KAAA,EAAO,UAAA;AAAA;EACjB,EAAA;EAAW,MAAA;EAAgB,KAAA;EAAe,IAAA;AAAA;AA0ChD;;;;AAAA,iBApCgB,mBAAA,CAAoB,GAAA,WAAc,UAAA;;iBAUlC,mBAAA,CAAoB,KAAA,EAAO,UAAA;;;AAgD3C;;;;;AAcA;;;;;;;;;iBApCgB,sBAAA,CAAuB,IAAA,EAAM,YAAA,GAAe,cAAA;;;;AAkE5D;;iBA5CgB,gBAAA,CAAiB,OAAA,EAAS,YAAA;;;AAuD1C;;;;;UAzCiB,WAAA;EAoDmB;EAlDlC,eAAA;EA6Da;EA3Db,gBAAA;EAkDA;EAhDA,cAAA;EAkDA;EAhDA,kBAAA;EAiDU;EA/CV,kBAAA;EAqDO;;;AAIT;;;EAlDE,0BAAA;EAmDA;;;;;AAKF;EAjDE,sBAAA;AAAA;;cAMW,eAAA,EAAiB,WAAA;;cAWjB,iBAAA,EAAmB,WAAA;;UAWf,mBAAA;EACf,IAAA;EACA,OAAA;EACA,QAAA;EACA,WAAA;EACA,OAAA,GAAU,MAAA;EAsBuC;;;;;EAhBjD,IAAA,GAAO,MAAA;AAAA;;UAIQ,oBAAA;EACf,IAAA;EACA,OAAA,GAAU,MAAA;AAAA;;UAIK,kBAAA;EACf,IAAA;EACA,QAAA;EACA,OAAA,GAAU,MAAA;AAAA;AAAA,KAGA,cAAA,GAAiB,mBAAA,GAAsB,oBAAA,GAAuB,kBAAA;;KAG9D,gBAAA;EACN,EAAA;EAAU,KAAA,EAAO,UAAA;AAAA;EACjB,EAAA;EAAW,MAAA;EAAgB,KAAA;EAAe,IAAA;AAAA;AAAA,KAEpC,eAAA;EACN,EAAA;EAAU,OAAA,EAAS,cAAA;EAAkB,YAAA,GAAe,gBAAA;AAAA;EACpD,EAAA;EAAW,MAAA;EAAgB,KAAA;EAAe,IAAA;AAAA;;;;;;;;;;;;;;;iBAwBhC,iBAAA,CACd,IAAA;EAAQ,IAAA;EAAe,OAAA;AAAA,GACvB,MAAA,EAAQ,WAAA,EACR,YAAA,GAAe,IAAA,6BACd,eAAA"}
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
//#region src/http/afs-rpc-wire.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* afs-rpc wire contract — encoding + validation helpers.
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth for the binary content encoding (base64) and the
|
|
6
|
+
* write/delete body validation rules pinned in
|
|
7
|
+
* `planning/did-integration/mobile-didspace-transport/wire-contract.md`.
|
|
8
|
+
*
|
|
9
|
+
* Both runtime handlers (Node `daemon/server.ts`, Cloudflare `index.ts`) share
|
|
10
|
+
* `createAfsRpcHandler`; this module is where the write/delete dispatch (Phase
|
|
11
|
+
* 4) decodes `content` and enforces field-position rules. Defined in Phase 0
|
|
12
|
+
* so the contract is frozen before any implementation.
|
|
13
|
+
*/
|
|
14
|
+
/** Stable error codes surfaced on the wire (see wire-contract.md §7/§9). */
|
|
15
|
+
declare const WIRE_ERROR_CODES: {
|
|
16
|
+
readonly conflict: "AFS_CONFLICT";
|
|
17
|
+
readonly payloadTooLarge: "PAYLOAD_TOO_LARGE"; /** Batch envelope rejected up-front (entry count / Σ bytes) — zero entries executed. */
|
|
18
|
+
readonly batchOverBudget: "BATCH_OVER_BUDGET"; /** batchRead tail entry skipped (encoded-byte threshold reached) — retry next batch. */
|
|
19
|
+
readonly batchTailSkipped: "BATCH_TAIL_SKIPPED";
|
|
20
|
+
/**
|
|
21
|
+
* Declared-size upload rejected BEFORE any bytes move (ingest-prepare early
|
|
22
|
+
* reject — DID-Space upload-limits, design §8 / D7). Distinct from
|
|
23
|
+
* `PAYLOAD_TOO_LARGE` ("actual decoded bytes over the cap"): `FILE_TOO_LARGE`
|
|
24
|
+
* fires on the client-declared size at the planning stage, is per-entry, and
|
|
25
|
+
* is never auto-retried by the sync engine.
|
|
26
|
+
*/
|
|
27
|
+
readonly fileTooLarge: "FILE_TOO_LARGE";
|
|
28
|
+
};
|
|
29
|
+
/**
|
|
30
|
+
* Extract the JWT from an `Authorization: Bearer <jwt>` header, or null when
|
|
31
|
+
* absent/malformed. Shared by both runtimes' `resolveCaller` (Phase 4) so the
|
|
32
|
+
* Bearer parsing is single-sourced and case-insensitive on the scheme.
|
|
33
|
+
*/
|
|
34
|
+
declare function parseBearerToken(header: string | null | undefined): string | null;
|
|
35
|
+
/** Only encoding understood today. `bypass` (D-A) is reserved for large blobs. */
|
|
36
|
+
type WireEncoding = "base64";
|
|
37
|
+
/** Shape of a `write` RpcBody after JSON parse, before decoding. */
|
|
38
|
+
interface RpcWriteBody {
|
|
39
|
+
type: "write";
|
|
40
|
+
path?: string;
|
|
41
|
+
content?: string;
|
|
42
|
+
encoding?: string;
|
|
43
|
+
contentType?: string;
|
|
44
|
+
options?: {
|
|
45
|
+
ifMatch?: unknown;
|
|
46
|
+
meta?: {
|
|
47
|
+
deviceId?: unknown;
|
|
48
|
+
mtime?: unknown;
|
|
49
|
+
ifMatch?: unknown;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
type WireValidation = {
|
|
54
|
+
ok: true;
|
|
55
|
+
bytes: Uint8Array;
|
|
56
|
+
} | {
|
|
57
|
+
ok: false;
|
|
58
|
+
status: number;
|
|
59
|
+
error: string;
|
|
60
|
+
code?: string;
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Decode a base64 string into bytes. Pure; no DOM/Buffer assumptions beyond
|
|
64
|
+
* `atob` (present in workerd + Node 18+ globalThis). Throws on malformed input.
|
|
65
|
+
*/
|
|
66
|
+
declare function decodeContentBase64(b64: string): Uint8Array;
|
|
67
|
+
/** Encode bytes into a base64 string. Inverse of {@link decodeContentBase64}. */
|
|
68
|
+
declare function encodeContentBase64(bytes: Uint8Array): string;
|
|
69
|
+
/**
|
|
70
|
+
* Validate + decode a `write` body per the wire contract.
|
|
71
|
+
*
|
|
72
|
+
* Enforces:
|
|
73
|
+
* - `content` present and `encoding === "base64"` (missing/other → 400).
|
|
74
|
+
* The empty string IS present — it is the canonical base64 of a 0-byte
|
|
75
|
+
* file, which must roundtrip (P6 crafted-sample finding; rejecting it
|
|
76
|
+
* made empty files unsyncable on every client).
|
|
77
|
+
* - `content` is valid base64 (bad → 400).
|
|
78
|
+
*
|
|
79
|
+
* Does NOT touch `options.ifMatch` placement: the field-position rule
|
|
80
|
+
* (ifMatch belongs at `options.ifMatch`, never `options.meta.ifMatch` for
|
|
81
|
+
* writes) is enforced by the handler reading ONLY `options.ifMatch`. A
|
|
82
|
+
* misplaced `meta.ifMatch` is simply ignored (treated as absent top-level
|
|
83
|
+
* ifMatch → LWW), per wire-contract.md §8.3.
|
|
84
|
+
*/
|
|
85
|
+
declare function validateAndDecodeWrite(body: RpcWriteBody): WireValidation;
|
|
86
|
+
/**
|
|
87
|
+
* Read the top-level write ifMatch precondition. The misplaced
|
|
88
|
+
* `options.meta.ifMatch` is intentionally NOT consulted for writes — only
|
|
89
|
+
* `delete` carries ifMatch under `meta`.
|
|
90
|
+
*/
|
|
91
|
+
declare function readWriteIfMatch(options: RpcWriteBody["options"]): string | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* Per-type batch limits — the wire-contract §9 constant table. These are
|
|
94
|
+
* CONTRACT constants (clients mirror the same numbers when packing batches;
|
|
95
|
+
* no negotiation endpoint), injected into `createAfsRpcHandler` per runtime.
|
|
96
|
+
* Derived from the worst-case subrequest costs measured in P0
|
|
97
|
+
* (planning/afs-rpc-batch/p0-measurements.md).
|
|
98
|
+
*/
|
|
99
|
+
interface BatchLimits {
|
|
100
|
+
/** Max entries per batchWrite envelope. */
|
|
101
|
+
maxWriteEntries: number;
|
|
102
|
+
/** Max entries per batchDelete envelope. */
|
|
103
|
+
maxDeleteEntries: number;
|
|
104
|
+
/** Max entries per batchRead envelope. */
|
|
105
|
+
maxReadEntries: number;
|
|
106
|
+
/** Σ decoded bytes cap across a batchWrite envelope (400 BATCH_OVER_BUDGET). */
|
|
107
|
+
maxWriteBatchBytes: number;
|
|
108
|
+
/** Single-entry decoded cap (413 PAYLOAD_TOO_LARGE — same code as single op). */
|
|
109
|
+
maxEntryWriteBytes: number;
|
|
110
|
+
/**
|
|
111
|
+
* batchRead tail-truncation threshold, accumulated over ENCODED (base64
|
|
112
|
+
* response) bytes. NOT a hard response cap: the entry that crosses it is
|
|
113
|
+
* still returned in full (never read-then-discard); subsequent entries get
|
|
114
|
+
* 503 BATCH_TAIL_SKIPPED without being read.
|
|
115
|
+
*/
|
|
116
|
+
readTailSkipThresholdBytes: number;
|
|
117
|
+
/**
|
|
118
|
+
* Pre-parse cap on the ENCODED request body (whole endpoint, not just
|
|
119
|
+
* batch): checked against Content-Length AND enforced by bounded read
|
|
120
|
+
* BEFORE `request.json()`, so an unauthenticated oversized body can't buy
|
|
121
|
+
* parse CPU/memory. Covers single-op 16MB decoded ≈ 21.4MB encoded + slack.
|
|
122
|
+
*/
|
|
123
|
+
maxEncodedRequestBytes: number;
|
|
124
|
+
}
|
|
125
|
+
/** Cloudflare-tier limits (free-tier portability baseline; P0-confirmed). */
|
|
126
|
+
declare const BATCH_LIMITS_CF: BatchLimits;
|
|
127
|
+
/** Node-daemon limits (no subrequest budget; bounded by memory/UX only). */
|
|
128
|
+
declare const BATCH_LIMITS_NODE: BatchLimits;
|
|
129
|
+
/** batchWrite entry = single-op write body minus type/blocklet/sessionId. */
|
|
130
|
+
interface BatchWriteWireEntry {
|
|
131
|
+
path: string;
|
|
132
|
+
content?: string;
|
|
133
|
+
encoding?: string;
|
|
134
|
+
contentType?: string;
|
|
135
|
+
options?: Record<string, unknown>;
|
|
136
|
+
/**
|
|
137
|
+
* Application metadata (createdAt / updatedAt / …) carried on the entry's
|
|
138
|
+
* top-level `meta` — distinct from `options.meta` (sync provenance). Forwarded
|
|
139
|
+
* to `AFSWriteEntryPayload.meta` so metadata-aware providers index it.
|
|
140
|
+
*/
|
|
141
|
+
meta?: Record<string, unknown>;
|
|
142
|
+
}
|
|
143
|
+
/** batchDelete entry — ifMatch/provenance ride options.meta, like single op. */
|
|
144
|
+
interface BatchDeleteWireEntry {
|
|
145
|
+
path: string;
|
|
146
|
+
options?: Record<string, unknown>;
|
|
147
|
+
}
|
|
148
|
+
/** batchRead entry — `optional` mirrors the single-op wire field. */
|
|
149
|
+
interface BatchReadWireEntry {
|
|
150
|
+
path: string;
|
|
151
|
+
optional?: boolean;
|
|
152
|
+
options?: Record<string, unknown>;
|
|
153
|
+
}
|
|
154
|
+
type BatchWireEntry = BatchWriteWireEntry & BatchDeleteWireEntry & BatchReadWireEntry;
|
|
155
|
+
/** Per-entry decode outcome for batchWrite (aligned by index with entries). */
|
|
156
|
+
type BatchWriteDecode = {
|
|
157
|
+
ok: true;
|
|
158
|
+
bytes: Uint8Array;
|
|
159
|
+
} | {
|
|
160
|
+
ok: false;
|
|
161
|
+
status: number;
|
|
162
|
+
error: string;
|
|
163
|
+
code?: string;
|
|
164
|
+
};
|
|
165
|
+
type BatchValidation = {
|
|
166
|
+
ok: true;
|
|
167
|
+
entries: BatchWireEntry[];
|
|
168
|
+
writeDecodes?: BatchWriteDecode[];
|
|
169
|
+
} | {
|
|
170
|
+
ok: false;
|
|
171
|
+
status: number;
|
|
172
|
+
error: string;
|
|
173
|
+
code?: string;
|
|
174
|
+
};
|
|
175
|
+
/**
|
|
176
|
+
* Envelope-level validation for the three batch ops (wire-contract §9).
|
|
177
|
+
*
|
|
178
|
+
* Envelope rejections (zero entries executed): entries shape, per-type
|
|
179
|
+
* maxEntries / Σ-decoded-bytes budget (400 BATCH_OVER_BUDGET), forbidden
|
|
180
|
+
* per-entry `blocklet`/`sessionId` fields, invalid/traversal paths, and a
|
|
181
|
+
* single entry over the per-entry decoded cap (413 PAYLOAD_TOO_LARGE — the
|
|
182
|
+
* single-op code).
|
|
183
|
+
*
|
|
184
|
+
* Content-shape problems (missing/empty content, unknown encoding, bad
|
|
185
|
+
* base64) are NOT envelope rejections: single-op parity says each such entry
|
|
186
|
+
* fails alone, so they come back as per-entry decode outcomes in
|
|
187
|
+
* `writeDecodes` for the dispatch loop to surface as `results[i]`.
|
|
188
|
+
*/
|
|
189
|
+
declare function validateBatchBody(body: {
|
|
190
|
+
type?: string;
|
|
191
|
+
entries?: unknown;
|
|
192
|
+
}, limits: BatchLimits, sanitizePath: (path: string) => string | null): BatchValidation;
|
|
193
|
+
//#endregion
|
|
194
|
+
export { BATCH_LIMITS_CF, BATCH_LIMITS_NODE, BatchDeleteWireEntry, BatchLimits, BatchReadWireEntry, BatchWriteWireEntry, RpcWriteBody, WIRE_ERROR_CODES, WireEncoding, WireValidation, decodeContentBase64, encodeContentBase64, parseBearerToken, readWriteIfMatch, validateAndDecodeWrite, validateBatchBody };
|
|
195
|
+
//# sourceMappingURL=afs-rpc-wire.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"afs-rpc-wire.d.mts","names":[],"sources":["../../src/http/afs-rpc-wire.ts"],"mappings":";;AAcA;;;;;;;;;;;AAsBA;AAAA,cAtBa,gBAAA;EAAA;iDAsBqD;EAAA,+CAQ1C;EAAA;EAAA;;AAGxB;;;;;EAHwB;;;;;;;iBARR,gBAAA,CAAiB,MAAA;;KAQrB,YAAA;;UAGK,YAAA;EACf,IAAA;EACA,IAAA;EACA,OAAA;EACA,QAAA;EACA,WAAA;EACA,OAAA;IACE,OAAA;IACA,IAAA;MAAS,QAAA;MAAoB,KAAA;MAAiB,OAAA;IAAA;EAAA;AAAA;AAAA,KAItC,cAAA;EACN,EAAA;EAAU,KAAA,EAAO,UAAA;AAAA;EACjB,EAAA;EAAW,MAAA;EAAgB,KAAA;EAAe,IAAA;AAAA;AA0ChD;;;;AAAA,iBApCgB,mBAAA,CAAoB,GAAA,WAAc,UAAA;;iBAUlC,mBAAA,CAAoB,KAAA,EAAO,UAAA;;;AAgD3C;;;;;AAcA;;;;;;;;;iBApCgB,sBAAA,CAAuB,IAAA,EAAM,YAAA,GAAe,cAAA;;;;AAkE5D;;iBA5CgB,gBAAA,CAAiB,OAAA,EAAS,YAAA;;;AAuD1C;;;;;UAzCiB,WAAA;EAoDmB;EAlDlC,eAAA;EA6Da;EA3Db,gBAAA;EAkDA;EAhDA,cAAA;EAkDA;EAhDA,kBAAA;EAiDU;EA/CV,kBAAA;EAqDO;;;AAIT;;;EAlDE,0BAAA;EAmDA;;;;;AAKF;EAjDE,sBAAA;AAAA;;cAMW,eAAA,EAAiB,WAAA;;cAWjB,iBAAA,EAAmB,WAAA;;UAWf,mBAAA;EACf,IAAA;EACA,OAAA;EACA,QAAA;EACA,WAAA;EACA,OAAA,GAAU,MAAA;EAsBuC;;;;;EAhBjD,IAAA,GAAO,MAAA;AAAA;;UAIQ,oBAAA;EACf,IAAA;EACA,OAAA,GAAU,MAAA;AAAA;;UAIK,kBAAA;EACf,IAAA;EACA,QAAA;EACA,OAAA,GAAU,MAAA;AAAA;AAAA,KAGA,cAAA,GAAiB,mBAAA,GAAsB,oBAAA,GAAuB,kBAAA;;KAG9D,gBAAA;EACN,EAAA;EAAU,KAAA,EAAO,UAAA;AAAA;EACjB,EAAA;EAAW,MAAA;EAAgB,KAAA;EAAe,IAAA;AAAA;AAAA,KAEpC,eAAA;EACN,EAAA;EAAU,OAAA,EAAS,cAAA;EAAkB,YAAA,GAAe,gBAAA;AAAA;EACpD,EAAA;EAAW,MAAA;EAAgB,KAAA;EAAe,IAAA;AAAA;;;;;;;;;;;;;;;iBAwBhC,iBAAA,CACd,IAAA;EAAQ,IAAA;EAAe,OAAA;AAAA,GACvB,MAAA,EAAQ,WAAA,EACR,YAAA,GAAe,IAAA,6BACd,eAAA"}
|