space-data-module-sdk 0.8.4 → 0.8.5
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 +117 -20
- package/bin/space-data-module.js +263 -0
- package/docs/.nojekyll +1 -0
- package/docs/AGENTS.md +34 -0
- package/docs/architecture.svg +141 -0
- package/docs/browser-wasmedge-isomorphic.md +179 -0
- package/docs/flatsql-streaming-standard.md +341 -0
- package/docs/gpu-module-abi.md +193 -0
- package/docs/index.html +125 -0
- package/docs/isomorphic-pthreads.md +188 -0
- package/docs/isomorphic-sdn-runtime-plan.md +167 -0
- package/docs/language-runtime-matrix.md +82 -0
- package/docs/manifest-structure.svg +114 -0
- package/docs/module-bundle-runtime-plan.md +19 -0
- package/docs/module-lifecycle.svg +70 -0
- package/docs/module-publication-standard.md +540 -0
- package/docs/node-red-default-node-parity.md +88 -0
- package/docs/protocol-installation.md +196 -0
- package/docs/secrets-capability.md +152 -0
- package/docs/styles.css +288 -0
- package/docs/testing-harness.md +408 -0
- package/docs/tri-runtime-parity.md +132 -0
- package/docs/wallet-callback.html +2 -0
- package/package.json +25 -6
- package/schemas/HttpRequestAbi.fbs +41 -0
- package/schemas/HttpResponseAbi.fbs +36 -0
- package/schemas/PluginManifest.fbs +2 -1
- package/src/AGENTS.md +1 -1
- package/src/app/codec.js +548 -0
- package/src/app/index.js +6 -0
- package/src/browser.js +5 -0
- package/src/bundle/constants.js +1 -0
- package/src/bundle/index.js +15 -0
- package/src/bundle/sigdomain.js +179 -0
- package/src/bundle/signing.js +767 -0
- package/src/bundle/wasm.js +3 -2
- package/src/capabilities.js +3 -0
- package/src/compat/index.js +7 -0
- package/src/compat/sdnLegacy.js +449 -0
- package/src/compiler/compileModule.js +556 -55
- package/src/compiler/flatcSupport.js +41 -27
- package/src/compiler/index.d.ts +2 -0
- package/src/compiler/index.js +18 -0
- package/src/compiler/invokeGlue.js +1212 -183
- package/src/compiler/pthreadArtifactGuard.js +910 -0
- package/src/compiler/sdnShimGenerator.js +323 -0
- package/src/compiler/wasiThreadsToolchain.js +150 -0
- package/src/compliance/index.js +11 -1
- package/src/compliance/legacyWildcardPorts.js +228 -0
- package/src/compliance/pluginCompliance.js +1000 -96
- package/src/field-stream/index.d.ts +31 -0
- package/src/field-stream/index.js +119 -0
- package/src/flow/dependencyStreamBridge.js +234 -0
- package/src/flow/flatsqlLinkShim.js +304 -0
- package/src/flow/flowCodec.js +107 -0
- package/src/flow/flowCompiler.js +2900 -0
- package/src/flow/flowRuntimeHost.js +877 -0
- package/src/flow/index.d.ts +117 -0
- package/src/flow/index.js +31 -0
- package/src/flow/isomorphicFlowHost.js +384 -0
- package/src/flow/jsFlowRuntime.js +275 -0
- package/src/flow/normalize.js +294 -0
- package/src/flow/runtime-src/flow_runtime.cpp +1699 -0
- package/src/flow/vendor/sdn-flow/MethodRegistry.js +400 -0
- package/src/flow/vendor/sdn-flow/constants.js +39 -0
- package/src/flow/vendor/sdn-flow/index.js +29 -0
- package/src/flow/vendor/sdn-flow/normalize.js +506 -0
- package/src/flow/vendor/sdn-flow/wasmCompatibility.js +189 -0
- package/src/generated/http/cpp/HttpRequestAbi_generated.h +285 -0
- package/src/generated/http/cpp/HttpResponseAbi_generated.h +192 -0
- package/src/generated/http/sdn/http/http-header.js +53 -0
- package/src/generated/http/sdn/http/http-header.ts +67 -0
- package/src/generated/http/sdn/http/http-request.js +132 -0
- package/src/generated/http/sdn/http/http-request.ts +179 -0
- package/src/generated/http/sdn/http/http-response.js +144 -0
- package/src/generated/http/sdn/http/http-response.ts +168 -0
- package/src/generated/http/sdn/http.js +11 -0
- package/src/generated/http/sdn/http.ts +4 -0
- package/src/generated/orbpro/flow/backpressure-policy.d.ts +12 -0
- package/src/generated/orbpro/flow/backpressure-policy.d.ts.map +1 -0
- package/src/generated/orbpro/flow/backpressure-policy.js +17 -0
- package/src/generated/orbpro/flow/backpressure-policy.js.map +1 -0
- package/src/generated/orbpro/flow/backpressure-policy.ts +15 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.d.ts +142 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.js +304 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.js.map +1 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.ts +399 -0
- package/src/generated/orbpro/flow/flow-edge.d.ts +113 -0
- package/src/generated/orbpro/flow/flow-edge.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-edge.js +221 -0
- package/src/generated/orbpro/flow/flow-edge.js.map +1 -0
- package/src/generated/orbpro/flow/flow-edge.ts +292 -0
- package/src/generated/orbpro/flow/flow-node.d.ts +80 -0
- package/src/generated/orbpro/flow/flow-node.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-node.js +158 -0
- package/src/generated/orbpro/flow/flow-node.js.map +1 -0
- package/src/generated/orbpro/flow/flow-node.ts +202 -0
- package/src/generated/orbpro/flow/flow-program.d.ts +164 -0
- package/src/generated/orbpro/flow/flow-program.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-program.js +350 -0
- package/src/generated/orbpro/flow/flow-program.js.map +1 -0
- package/src/generated/orbpro/flow/flow-program.ts +477 -0
- package/src/generated/orbpro/flow/flow-trigger.d.ts +108 -0
- package/src/generated/orbpro/flow/flow-trigger.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-trigger.js +207 -0
- package/src/generated/orbpro/flow/flow-trigger.js.map +1 -0
- package/src/generated/orbpro/flow/flow-trigger.ts +276 -0
- package/src/generated/orbpro/flow/node-kind.d.ts +13 -0
- package/src/generated/orbpro/flow/node-kind.d.ts.map +1 -0
- package/src/generated/orbpro/flow/node-kind.js +16 -0
- package/src/generated/orbpro/flow/node-kind.js.map +1 -0
- package/src/generated/orbpro/{invoke.ts → flow/node-kind.ts} +12 -2
- package/src/generated/orbpro/flow/plugin-version-binding.d.ts +52 -0
- package/src/generated/orbpro/flow/plugin-version-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/plugin-version-binding.js +85 -0
- package/src/generated/orbpro/flow/plugin-version-binding.js.map +1 -0
- package/src/generated/orbpro/flow/plugin-version-binding.ts +121 -0
- package/src/generated/orbpro/flow/schema-hash-binding.d.ts +70 -0
- package/src/generated/orbpro/flow/schema-hash-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/schema-hash-binding.js +143 -0
- package/src/generated/orbpro/flow/schema-hash-binding.js.map +1 -0
- package/src/generated/orbpro/flow/schema-hash-binding.ts +189 -0
- package/src/generated/orbpro/flow/trigger-binding.d.ts +71 -0
- package/src/generated/orbpro/flow/trigger-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/trigger-binding.js +142 -0
- package/src/generated/orbpro/flow/trigger-binding.js.map +1 -0
- package/src/generated/orbpro/flow/trigger-binding.ts +181 -0
- package/src/generated/orbpro/flow/trigger-kind.d.ts +14 -0
- package/src/generated/orbpro/flow/trigger-kind.d.ts.map +1 -0
- package/src/generated/orbpro/flow/trigger-kind.js +17 -0
- package/src/generated/orbpro/flow/trigger-kind.js.map +1 -0
- package/src/generated/orbpro/flow/trigger-kind.ts +17 -0
- package/src/generated/orbpro/flow.d.ts +21 -0
- package/src/generated/orbpro/flow.d.ts.map +1 -0
- package/src/generated/orbpro/flow.js +23 -0
- package/src/generated/orbpro/flow.js.map +1 -0
- package/src/generated/orbpro/flow.ts +24 -0
- package/src/generated/orbpro/manifest/capability-kind.d.ts +2 -1
- package/src/generated/orbpro/manifest/capability-kind.js +1 -0
- package/src/generated/orbpro/manifest/capability-kind.ts +1 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.d.ts +93 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.js +160 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.ts +211 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.d.ts +99 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.js +175 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.ts +226 -0
- package/src/generated/orbpro/plugin.js +8 -0
- package/src/generated/orbpro/stream.d.ts +12 -0
- package/src/generated/orbpro/stream.js +14 -0
- package/src/generated/orbpro/stream.ts +15 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.d.ts +52 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.js +106 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.ts +162 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.d.ts +90 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.js +189 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.ts +270 -0
- package/src/generated/spacedatastandards/plg/PLG.d.ts +492 -0
- package/src/generated/spacedatastandards/plg/PLG.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLG.js +1139 -0
- package/src/generated/spacedatastandards/plg/PLG.ts +1600 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.d.ts +63 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.js +138 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.ts +189 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.d.ts +41 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.js +104 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.ts +151 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.d.ts +68 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.js +124 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.ts +184 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.d.ts +58 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.js +126 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.ts +161 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.d.ts +82 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.js +164 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.ts +244 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.d.ts +55 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.js +105 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.ts +162 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.d.ts +42 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.js +83 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.ts +127 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.d.ts +36 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.js +90 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.ts +127 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.d.ts +53 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.js +153 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.ts +210 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.d.ts +70 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.js +149 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.ts +212 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.d.ts +73 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.js +199 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.ts +292 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.d.ts +40 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.js +103 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.ts +148 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.d.ts +41 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.js +82 -0
- package/src/generated/spacedatastandards/plg/{plugin-capability.ts → PluginCapability.ts} +55 -18
- package/src/generated/spacedatastandards/plg/PluginDependency.d.ts +42 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.js +80 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.ts +124 -0
- package/src/generated/spacedatastandards/plg/TAB.d.ts +85 -0
- package/src/generated/spacedatastandards/plg/TAB.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/TAB.js +173 -0
- package/src/generated/spacedatastandards/plg/TAB.ts +228 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.js +20 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.ts +23 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.js +20 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.ts +23 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.d.ts +20 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.js +22 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.ts +25 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.d.ts +10 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.js +12 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.ts +13 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.d.ts +51 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.js +53 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.ts +55 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.d.ts +15 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.js +17 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.ts +19 -0
- package/src/generated/spacedatastandards/plg/main.d.ts +29 -0
- package/src/generated/spacedatastandards/plg/main.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/main.js +30 -0
- package/src/generated/spacedatastandards/plg/main.ts +32 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.d.ts +17 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.js +19 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.ts +21 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.d.ts +82 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.js +84 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.ts +103 -0
- package/src/generated/spacedatastandards/plg/publicationState.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/publicationState.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/publicationState.js +20 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.js +20 -0
- package/src/host/AGENTS.md +2 -2
- package/src/host/abi.js +53 -66
- package/src/host/browserHost.js +355 -8
- package/src/host/cpp/keyslotClient.hpp +231 -0
- package/src/host/cpp/secretsClient.hpp +583 -0
- package/src/host/hostcallWire.js +183 -0
- package/src/host/index.js +2 -0
- package/src/host/isomorphicLoader.js +44 -7
- package/src/host/nodeHost.js +227 -8
- package/src/host/sabHostcallChannel.js +206 -0
- package/src/host/timerDriver.js +203 -0
- package/src/host/wasiShim.js +41 -1
- package/src/host/wasiThreadBrowserWorker.mjs +48 -0
- package/src/host/wasiThreadHost.js +393 -0
- package/src/host/wasiThreadWorker.mjs +32 -0
- package/src/host/wasiThreadWorkerRuntime.js +93 -0
- package/src/http/index.js +339 -0
- package/src/index.d.ts +716 -10
- package/src/index.js +4 -0
- package/src/invoke/codec.js +1202 -128
- package/src/invoke/index.js +5 -1
- package/src/licensing/index.d.ts +2 -0
- package/src/licensing/index.js +2 -0
- package/src/licensing/records.js +287 -8
- package/src/manifest/codec.js +62 -14
- package/src/manifest/index.js +2 -0
- package/src/manifest/legacyToPlg.js +164 -25
- package/src/manifest/normalize.js +1 -0
- package/src/manifest/plgCodec.js +1303 -62
- package/src/manifest/typeRefs.js +162 -24
- package/src/runtime/compiledRuntimeAbi.js +47 -0
- package/src/runtime/compiledRuntimeAbi.json +33 -0
- package/src/runtime/index.d.ts +32 -0
- package/src/runtime/index.js +1 -0
- package/src/runtime-host/index.js +3 -0
- package/src/runtime-host/methodRegistry.js +55 -0
- package/src/standards/index.js +200 -56
- package/src/standards/sharedCatalog.js +16 -0
- package/src/testing/browserModuleHarness.js +604 -31
- package/src/testing/docker/wasmedge-parity.Dockerfile +39 -0
- package/src/testing/index.d.ts +151 -0
- package/src/testing/index.js +21 -0
- package/src/testing/native/wasmedge_emscripten_pthread_runner.c +25 -1
- package/src/testing/parityBrowserRunner.js +138 -0
- package/src/testing/parityHarness.js +616 -0
- package/src/testing/parityLanes.js +537 -0
- package/src/testing/processInvoke.js +29 -21
- package/src/testing/streamInvokeCodec.js +10 -175
- package/src/testing/wasmedgePin.json +6 -0
- package/src/testing/workerModuleHarness.js +242 -0
- package/src/testing/workerModuleHarnessWorker.js +176 -0
- package/src/transport/index.js +3 -0
- package/src/transport/pki.js +299 -11
- package/src/transport/records.js +16 -7
- package/src/utils/ecdsaDer.js +106 -0
- package/src/utils/wasmCrypto.js +0 -43
- package/templates/gpu-module/README.md +48 -0
- package/templates/gpu-module/include/space_data_gpu_abi.h +122 -0
- package/templates/gpu-module/manifest.json +84 -0
- package/schemas/PluginInvokeRequest.fbs +0 -18
- package/schemas/PluginInvokeResponse.fbs +0 -30
- package/schemas/spacedatastandards/PLG.fbs +0 -191
- package/src/generated/orbpro/invoke/plugin-invoke-request.d.ts +0 -51
- package/src/generated/orbpro/invoke/plugin-invoke-request.d.ts.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-request.js +0 -131
- package/src/generated/orbpro/invoke/plugin-invoke-request.js.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-request.ts +0 -173
- package/src/generated/orbpro/invoke/plugin-invoke-response.d.ts +0 -76
- package/src/generated/orbpro/invoke/plugin-invoke-response.d.ts.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-response.js +0 -184
- package/src/generated/orbpro/invoke/plugin-invoke-response.js.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-response.ts +0 -243
- package/src/generated/orbpro/invoke.d.ts +0 -3
- package/src/generated/orbpro/invoke.js +0 -5
- package/src/generated/spacedatastandards/plg/entry-function.js +0 -86
- package/src/generated/spacedatastandards/plg/entry-function.ts +0 -119
- package/src/generated/spacedatastandards/plg/index.js +0 -16
- package/src/generated/spacedatastandards/plg/index.ts +0 -11
- package/src/generated/spacedatastandards/plg/plg.js +0 -657
- package/src/generated/spacedatastandards/plg/plg.ts +0 -924
- package/src/generated/spacedatastandards/plg/plugin-capability.js +0 -66
- package/src/generated/spacedatastandards/plg/plugin-category.js +0 -15
- package/src/generated/spacedatastandards/plg/plugin-category.ts +0 -53
- package/src/generated/spacedatastandards/plg/plugin-dependency.js +0 -63
- package/src/generated/spacedatastandards/plg/plugin-dependency.ts +0 -86
- package/src/generated/spacedatastandards/plg/publication-state.js +0 -9
- package/src/generated/spacedatastandards/plg/purchase-tier.js +0 -9
- /package/src/generated/spacedatastandards/plg/{publication-state.ts → publicationState.ts} +0 -0
- /package/src/generated/spacedatastandards/plg/{purchase-tier.ts → purchaseTier.ts} +0 -0
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Canonical HTTP response envelope for WASM-served HTTP (host-owned ABI).
|
|
2
|
+
//
|
|
3
|
+
// Counterpart of schemas/HttpRequestAbi.fbs (which declares the shared
|
|
4
|
+
// HttpHeader table). The host streams STATUS/HEADERS/BODY back to the client
|
|
5
|
+
// verbatim; it must not add, drop, or rewrite any of them.
|
|
6
|
+
|
|
7
|
+
include "HttpRequestAbi.fbs";
|
|
8
|
+
|
|
9
|
+
namespace sdn.http;
|
|
10
|
+
|
|
11
|
+
table HttpResponse {
|
|
12
|
+
/// HTTP status code (200, 304, 400, 404, 502, ...).
|
|
13
|
+
STATUS:ushort;
|
|
14
|
+
/// Response headers, sorted by NAME. All content-type / caching / count
|
|
15
|
+
/// headers are decided inside the module.
|
|
16
|
+
HEADERS:[HttpHeader];
|
|
17
|
+
/// Raw response body bytes (empty for 304).
|
|
18
|
+
BODY:[ubyte];
|
|
19
|
+
/// OPTIONAL out-of-band body reference (near-zero-copy egress, loop C.5c).
|
|
20
|
+
/// When BODY_REF_SIZE > 0 (and BODY is absent), the body bytes do NOT
|
|
21
|
+
/// travel through the flow's linear memory: the module passes through the
|
|
22
|
+
/// opaque token it received from a capability hostcall that answered in
|
|
23
|
+
/// reference mode (e.g. storage.flatsql_*_stream with "deliver":"ref"),
|
|
24
|
+
/// and the host substitutes the exact byte buffer it registered under
|
|
25
|
+
/// that token. Still the dumb-pipe contract: the module DECIDED the body
|
|
26
|
+
/// (it made the query and forwarded the result reference); the host only
|
|
27
|
+
/// resolves its own token — a descriptor read, never a decision. Tokens
|
|
28
|
+
/// are scoped to the module instance's hostcall bridge and to the current
|
|
29
|
+
/// exchange.
|
|
30
|
+
BODY_REF_TOKEN:ulong;
|
|
31
|
+
/// Byte length of the referenced body (0 = no reference present).
|
|
32
|
+
BODY_REF_SIZE:ulong;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
root_type HttpResponse;
|
|
36
|
+
file_identifier "$HTR";
|
package/src/AGENTS.md
CHANGED
|
@@ -12,7 +12,7 @@ the SDK source, not a prompt to edit SDK internals by default.
|
|
|
12
12
|
- `src/compiler`: compile flow, manifest embedding, runtime targets, toolchains,
|
|
13
13
|
and artifact layout.
|
|
14
14
|
- `src/bundle`: REC+MBL single-file packaging, wasm section handling, and vector compatibility.
|
|
15
|
-
- `src/host`: Node host, browser shims, `
|
|
15
|
+
- `src/host`: Node host, browser shims, `space_data_module_host`, WasmEdge runners, and
|
|
16
16
|
isomorphic loaders.
|
|
17
17
|
- `src/runtime-host`: FlatSQL-backed runtime host, row/region identity, and
|
|
18
18
|
binary stream ingest.
|
package/src/app/codec.js
ADDED
|
@@ -0,0 +1,548 @@
|
|
|
1
|
+
import * as flatbuffers from "flatbuffers";
|
|
2
|
+
import {
|
|
3
|
+
APP,
|
|
4
|
+
APPT,
|
|
5
|
+
APPDataflowT,
|
|
6
|
+
APPDataRefT,
|
|
7
|
+
APPModuleRefT,
|
|
8
|
+
APPSourceRefT,
|
|
9
|
+
APPUIPageT,
|
|
10
|
+
appContentEncoding,
|
|
11
|
+
appDataDirection,
|
|
12
|
+
appFlowDirection,
|
|
13
|
+
appFlowTransport,
|
|
14
|
+
appRuntimeTarget,
|
|
15
|
+
appSourceKind,
|
|
16
|
+
} from "spacedatastandards.org/lib/js/APP/main.js";
|
|
17
|
+
import { toUint8Array } from "../runtime/bufferLike.js";
|
|
18
|
+
|
|
19
|
+
export const APP_FILE_IDENTIFIER = "$APP";
|
|
20
|
+
|
|
21
|
+
const HEX_SHA256 = /^[a-f0-9]{64}$/;
|
|
22
|
+
const RFC3339_FIXED_MILLISECONDS =
|
|
23
|
+
/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/;
|
|
24
|
+
|
|
25
|
+
const contentEncodingToFB = Object.freeze({
|
|
26
|
+
utf8: appContentEncoding.UTF8,
|
|
27
|
+
base64: appContentEncoding.BASE64,
|
|
28
|
+
base64_gzip: appContentEncoding.BASE64_GZIP,
|
|
29
|
+
base64_brotli: appContentEncoding.BASE64_BROTLI,
|
|
30
|
+
});
|
|
31
|
+
const contentEncodingFromFB = invertEnumMap(contentEncodingToFB);
|
|
32
|
+
|
|
33
|
+
const dataDirectionToFB = Object.freeze({
|
|
34
|
+
produces: appDataDirection.PRODUCES,
|
|
35
|
+
consumes: appDataDirection.CONSUMES,
|
|
36
|
+
both: appDataDirection.BOTH,
|
|
37
|
+
});
|
|
38
|
+
const dataDirectionFromFB = invertEnumMap(dataDirectionToFB);
|
|
39
|
+
|
|
40
|
+
const sourceKindToFB = Object.freeze({
|
|
41
|
+
module: appSourceKind.MODULE,
|
|
42
|
+
"external-api": appSourceKind.EXTERNAL_API,
|
|
43
|
+
dataset: appSourceKind.DATASET,
|
|
44
|
+
});
|
|
45
|
+
const sourceKindFromFB = invertEnumMap(sourceKindToFB);
|
|
46
|
+
|
|
47
|
+
const runtimeTargetToFB = Object.freeze({
|
|
48
|
+
node: appRuntimeTarget.NODE,
|
|
49
|
+
page: appRuntimeTarget.PAGE,
|
|
50
|
+
both: appRuntimeTarget.BOTH,
|
|
51
|
+
});
|
|
52
|
+
const runtimeTargetFromFB = invertEnumMap(runtimeTargetToFB);
|
|
53
|
+
|
|
54
|
+
const flowDirectionToFB = Object.freeze({
|
|
55
|
+
to_page: appFlowDirection.TO_PAGE,
|
|
56
|
+
from_page: appFlowDirection.FROM_PAGE,
|
|
57
|
+
bidirectional: appFlowDirection.BIDIRECTIONAL,
|
|
58
|
+
});
|
|
59
|
+
const flowDirectionFromFB = invertEnumMap(flowDirectionToFB);
|
|
60
|
+
|
|
61
|
+
const flowTransportToFB = Object.freeze({
|
|
62
|
+
ipfs_cid: appFlowTransport.IPFS_CID,
|
|
63
|
+
pubsub_topic: appFlowTransport.PUBSUB_TOPIC,
|
|
64
|
+
gateway_route: appFlowTransport.GATEWAY_ROUTE,
|
|
65
|
+
});
|
|
66
|
+
const flowTransportFromFB = invertEnumMap(flowTransportToFB);
|
|
67
|
+
|
|
68
|
+
function invertEnumMap(value) {
|
|
69
|
+
return Object.freeze(
|
|
70
|
+
Object.fromEntries(Object.entries(value).map(([name, code]) => [code, name])),
|
|
71
|
+
);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function isObject(value) {
|
|
75
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function requireObject(value, label) {
|
|
79
|
+
if (!isObject(value)) {
|
|
80
|
+
throw new TypeError(`${label} must be an object.`);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
function requireString(value, label) {
|
|
85
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
86
|
+
throw new TypeError(`${label} must be a non-empty string.`);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
function optionalString(value, label) {
|
|
91
|
+
if (value !== undefined && value !== null && typeof value !== "string") {
|
|
92
|
+
throw new TypeError(`${label} must be a string when present.`);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function requireArray(value, label) {
|
|
97
|
+
if (!Array.isArray(value)) {
|
|
98
|
+
throw new TypeError(`${label} must be an array.`);
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function requireEnum(value, values, label, fallback) {
|
|
103
|
+
const normalized = value === undefined || value === null || value === ""
|
|
104
|
+
? fallback
|
|
105
|
+
: String(value);
|
|
106
|
+
if (!Object.hasOwn(values, normalized)) {
|
|
107
|
+
throw new TypeError(
|
|
108
|
+
`${label} must be one of ${Object.keys(values).join(", ")}.`,
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
return normalized;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function requireUnsignedInteger(value, label) {
|
|
115
|
+
const normalized = value ?? 0;
|
|
116
|
+
if (
|
|
117
|
+
!Number.isSafeInteger(normalized) ||
|
|
118
|
+
normalized < 0
|
|
119
|
+
) {
|
|
120
|
+
throw new TypeError(`${label} must be a non-negative safe integer.`);
|
|
121
|
+
}
|
|
122
|
+
return normalized;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function requireUniqueID(value, seen, label, noun) {
|
|
126
|
+
requireString(value, `${label}.id`);
|
|
127
|
+
if (seen.has(value)) {
|
|
128
|
+
throw new Error(`APP manifest contains duplicate ${noun} id ${JSON.stringify(value)}.`);
|
|
129
|
+
}
|
|
130
|
+
seen.add(value);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function validateTimestamp(value, label) {
|
|
134
|
+
if (value === undefined || value === null || value === "") return;
|
|
135
|
+
if (typeof value !== "string" || !RFC3339_FIXED_MILLISECONDS.test(value)) {
|
|
136
|
+
throw new TypeError(
|
|
137
|
+
`${label} must be an RFC 3339 UTC timestamp with fixed milliseconds.`,
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function validateSha256(value, label) {
|
|
143
|
+
if (typeof value !== "string" || !HEX_SHA256.test(value)) {
|
|
144
|
+
throw new TypeError(`${label} must be 64 lowercase hexadecimal characters.`);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function validateReferences(manifest, moduleIDs) {
|
|
149
|
+
for (const [index, data] of manifest.data.entries()) {
|
|
150
|
+
if (data.moduleId && !moduleIDs.has(data.moduleId)) {
|
|
151
|
+
throw new Error(
|
|
152
|
+
`APP manifest data[${index}].moduleId references unknown module ${JSON.stringify(data.moduleId)}.`,
|
|
153
|
+
);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
for (const [index, source] of manifest.sources.entries()) {
|
|
157
|
+
if (source.kind === "module" && !moduleIDs.has(source.ref)) {
|
|
158
|
+
throw new Error(
|
|
159
|
+
`APP manifest sources[${index}].ref references unknown module ${JSON.stringify(source.ref)}.`,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
for (const [index, page] of manifest.pages.entries()) {
|
|
164
|
+
if (page.moduleId && !moduleIDs.has(page.moduleId)) {
|
|
165
|
+
throw new Error(
|
|
166
|
+
`APP manifest pages[${index}].moduleId references unknown module ${JSON.stringify(page.moduleId)}.`,
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
for (const [index, flow] of manifest.dataflow.entries()) {
|
|
171
|
+
if (flow.moduleId && !moduleIDs.has(flow.moduleId)) {
|
|
172
|
+
throw new Error(
|
|
173
|
+
`APP manifest dataflow[${index}].moduleId references unknown module ${JSON.stringify(flow.moduleId)}.`,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
const APP_ARRAY_FIELDS = Object.freeze([
|
|
180
|
+
"modules",
|
|
181
|
+
"data",
|
|
182
|
+
"sources",
|
|
183
|
+
"pages",
|
|
184
|
+
"dataflow",
|
|
185
|
+
]);
|
|
186
|
+
|
|
187
|
+
function withArrayDefaults(manifest) {
|
|
188
|
+
return Object.fromEntries([
|
|
189
|
+
...Object.entries(manifest),
|
|
190
|
+
...APP_ARRAY_FIELDS.map((field) => [field, manifest[field] ?? []]),
|
|
191
|
+
]);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Validate the canonical camelCase representation of an SDS `$APP` record.
|
|
196
|
+
* The validator is intentionally stricter than the FlatBuffer schema at the
|
|
197
|
+
* publication boundary: every module must already be content-addressed and
|
|
198
|
+
* every inline page must carry its decoded-content digest.
|
|
199
|
+
*/
|
|
200
|
+
export function validateAppManifest(manifest) {
|
|
201
|
+
requireObject(manifest, "APP manifest");
|
|
202
|
+
const normalized = withArrayDefaults(manifest);
|
|
203
|
+
requireString(manifest.id, "APP manifest id");
|
|
204
|
+
requireString(manifest.name, "APP manifest name");
|
|
205
|
+
requireString(manifest.version, "APP manifest version");
|
|
206
|
+
optionalString(manifest.description, "APP manifest description");
|
|
207
|
+
validateTimestamp(manifest.createdAt, "APP manifest createdAt");
|
|
208
|
+
validateTimestamp(manifest.updatedAt, "APP manifest updatedAt");
|
|
209
|
+
|
|
210
|
+
for (const field of APP_ARRAY_FIELDS) {
|
|
211
|
+
requireArray(normalized[field], `APP manifest ${field}`);
|
|
212
|
+
}
|
|
213
|
+
if (normalized.modules.length === 0) {
|
|
214
|
+
throw new Error("APP manifest must reference at least one module.");
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
const moduleIDs = new Set();
|
|
218
|
+
for (const [index, module] of normalized.modules.entries()) {
|
|
219
|
+
const label = `APP manifest modules[${index}]`;
|
|
220
|
+
requireObject(module, label);
|
|
221
|
+
requireUniqueID(module.id, moduleIDs, label, "module");
|
|
222
|
+
requireString(module.pluginId, `${label}.pluginId`);
|
|
223
|
+
validateSha256(module.contentHash, `${label}.contentHash`);
|
|
224
|
+
optionalString(module.version, `${label}.version`);
|
|
225
|
+
optionalString(module.role, `${label}.role`);
|
|
226
|
+
optionalString(module.description, `${label}.description`);
|
|
227
|
+
requireUnsignedInteger(module.maxWallClockMs, `${label}.maxWallClockMs`);
|
|
228
|
+
requireUnsignedInteger(module.maxCostUnits, `${label}.maxCostUnits`);
|
|
229
|
+
const maxMemoryPages = requireUnsignedInteger(
|
|
230
|
+
module.maxMemoryPages,
|
|
231
|
+
`${label}.maxMemoryPages`,
|
|
232
|
+
);
|
|
233
|
+
if (maxMemoryPages > 0xffffffff) {
|
|
234
|
+
throw new TypeError(`${label}.maxMemoryPages must fit in uint32.`);
|
|
235
|
+
}
|
|
236
|
+
requireEnum(
|
|
237
|
+
module.runtimeTarget,
|
|
238
|
+
runtimeTargetToFB,
|
|
239
|
+
`${label}.runtimeTarget`,
|
|
240
|
+
"node",
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
const dataIDs = new Set();
|
|
245
|
+
for (const [index, data] of normalized.data.entries()) {
|
|
246
|
+
const label = `APP manifest data[${index}]`;
|
|
247
|
+
requireObject(data, label);
|
|
248
|
+
requireUniqueID(data.id, dataIDs, label, "data");
|
|
249
|
+
requireString(data.sdsType, `${label}.sdsType`);
|
|
250
|
+
requireEnum(data.direction, dataDirectionToFB, `${label}.direction`, "produces");
|
|
251
|
+
optionalString(data.moduleId, `${label}.moduleId`);
|
|
252
|
+
optionalString(data.description, `${label}.description`);
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const sourceIDs = new Set();
|
|
256
|
+
for (const [index, source] of normalized.sources.entries()) {
|
|
257
|
+
const label = `APP manifest sources[${index}]`;
|
|
258
|
+
requireObject(source, label);
|
|
259
|
+
requireUniqueID(source.id, sourceIDs, label, "source");
|
|
260
|
+
requireEnum(source.kind, sourceKindToFB, `${label}.kind`, "module");
|
|
261
|
+
requireString(source.ref, `${label}.ref`);
|
|
262
|
+
optionalString(source.description, `${label}.description`);
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
const pageIDs = new Set();
|
|
266
|
+
let entryPages = 0;
|
|
267
|
+
for (const [index, page] of normalized.pages.entries()) {
|
|
268
|
+
const label = `APP manifest pages[${index}]`;
|
|
269
|
+
requireObject(page, label);
|
|
270
|
+
requireUniqueID(page.id, pageIDs, label, "page");
|
|
271
|
+
for (const field of ["title", "description", "icon", "color", "textColor"]) {
|
|
272
|
+
optionalString(page[field], `${label}.${field}`);
|
|
273
|
+
}
|
|
274
|
+
const inline = typeof page.content === "string" && page.content.length > 0;
|
|
275
|
+
const moduleServed =
|
|
276
|
+
typeof page.moduleId === "string" && page.moduleId.length > 0 &&
|
|
277
|
+
typeof page.url === "string" && page.url.length > 0;
|
|
278
|
+
if (inline === moduleServed) {
|
|
279
|
+
throw new Error(
|
|
280
|
+
`${label} must use exactly one delivery lane: inline content or moduleId+url.`,
|
|
281
|
+
);
|
|
282
|
+
}
|
|
283
|
+
if (inline) {
|
|
284
|
+
requireEnum(page.encoding, contentEncodingToFB, `${label}.encoding`, "utf8");
|
|
285
|
+
requireString(page.mediaType, `${label}.mediaType`);
|
|
286
|
+
validateSha256(page.contentSha256, `${label}.contentSha256`);
|
|
287
|
+
if (page.moduleId || page.url) {
|
|
288
|
+
throw new Error(
|
|
289
|
+
`${label} must use exactly one delivery lane: inline content or moduleId+url.`,
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
} else {
|
|
293
|
+
optionalString(page.content, `${label}.content`);
|
|
294
|
+
optionalString(page.contentSha256, `${label}.contentSha256`);
|
|
295
|
+
}
|
|
296
|
+
if (page.entry === true) entryPages += 1;
|
|
297
|
+
else if (page.entry !== undefined && page.entry !== false) {
|
|
298
|
+
throw new TypeError(`${label}.entry must be boolean when present.`);
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
if (normalized.pages.length > 0 && entryPages !== 1) {
|
|
302
|
+
throw new Error(
|
|
303
|
+
`APP manifest must have exactly one entry page (found ${entryPages}).`,
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
const flowNames = new Set();
|
|
308
|
+
for (const [index, flow] of normalized.dataflow.entries()) {
|
|
309
|
+
const label = `APP manifest dataflow[${index}]`;
|
|
310
|
+
requireObject(flow, label);
|
|
311
|
+
requireUniqueID(flow.name, flowNames, label, "dataflow");
|
|
312
|
+
requireEnum(flow.direction, flowDirectionToFB, `${label}.direction`, "to_page");
|
|
313
|
+
requireString(flow.sdsSchema, `${label}.sdsSchema`);
|
|
314
|
+
requireEnum(flow.transport, flowTransportToFB, `${label}.transport`, "ipfs_cid");
|
|
315
|
+
optionalString(flow.locator, `${label}.locator`);
|
|
316
|
+
optionalString(flow.moduleId, `${label}.moduleId`);
|
|
317
|
+
optionalString(flow.methodId, `${label}.methodId`);
|
|
318
|
+
optionalString(flow.portId, `${label}.portId`);
|
|
319
|
+
requireEnum(
|
|
320
|
+
flow.contentEncoding,
|
|
321
|
+
contentEncodingToFB,
|
|
322
|
+
`${label}.contentEncoding`,
|
|
323
|
+
"utf8",
|
|
324
|
+
);
|
|
325
|
+
optionalString(flow.description, `${label}.description`);
|
|
326
|
+
const moduleBindingFields = [flow.moduleId, flow.methodId, flow.portId].filter(
|
|
327
|
+
(value) => typeof value === "string" && value.length > 0,
|
|
328
|
+
).length;
|
|
329
|
+
if (moduleBindingFields !== 0 && moduleBindingFields !== 3) {
|
|
330
|
+
throw new Error(
|
|
331
|
+
`${label} must declare moduleId, methodId, and portId together.`,
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
validateReferences(normalized, moduleIDs);
|
|
337
|
+
return manifest;
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
function nullable(value) {
|
|
341
|
+
return value === undefined || value === "" ? null : value;
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
function toBigInt(value) {
|
|
345
|
+
return BigInt(value ?? 0);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function toAppObject(manifest) {
|
|
349
|
+
return new APPT(
|
|
350
|
+
manifest.id,
|
|
351
|
+
manifest.name,
|
|
352
|
+
manifest.version,
|
|
353
|
+
nullable(manifest.description),
|
|
354
|
+
manifest.modules.map(
|
|
355
|
+
(module) =>
|
|
356
|
+
new APPModuleRefT(
|
|
357
|
+
module.id,
|
|
358
|
+
module.pluginId,
|
|
359
|
+
module.contentHash,
|
|
360
|
+
nullable(module.version),
|
|
361
|
+
nullable(module.role),
|
|
362
|
+
nullable(module.description),
|
|
363
|
+
toBigInt(module.maxWallClockMs),
|
|
364
|
+
toBigInt(module.maxCostUnits),
|
|
365
|
+
module.maxMemoryPages ?? 0,
|
|
366
|
+
runtimeTargetToFB[module.runtimeTarget ?? "node"],
|
|
367
|
+
),
|
|
368
|
+
),
|
|
369
|
+
manifest.data.map(
|
|
370
|
+
(data) =>
|
|
371
|
+
new APPDataRefT(
|
|
372
|
+
data.id,
|
|
373
|
+
data.sdsType,
|
|
374
|
+
dataDirectionToFB[data.direction ?? "produces"],
|
|
375
|
+
nullable(data.moduleId),
|
|
376
|
+
nullable(data.description),
|
|
377
|
+
),
|
|
378
|
+
),
|
|
379
|
+
manifest.sources.map(
|
|
380
|
+
(source) =>
|
|
381
|
+
new APPSourceRefT(
|
|
382
|
+
source.id,
|
|
383
|
+
sourceKindToFB[source.kind ?? "module"],
|
|
384
|
+
source.ref,
|
|
385
|
+
nullable(source.description),
|
|
386
|
+
),
|
|
387
|
+
),
|
|
388
|
+
manifest.pages.map(
|
|
389
|
+
(page) =>
|
|
390
|
+
new APPUIPageT(
|
|
391
|
+
page.id,
|
|
392
|
+
nullable(page.title),
|
|
393
|
+
nullable(page.description),
|
|
394
|
+
nullable(page.icon),
|
|
395
|
+
nullable(page.color),
|
|
396
|
+
nullable(page.textColor),
|
|
397
|
+
nullable(page.content),
|
|
398
|
+
contentEncodingToFB[page.encoding ?? "utf8"],
|
|
399
|
+
nullable(page.mediaType),
|
|
400
|
+
nullable(page.contentSha256),
|
|
401
|
+
page.entry === true,
|
|
402
|
+
nullable(page.moduleId),
|
|
403
|
+
nullable(page.url),
|
|
404
|
+
),
|
|
405
|
+
),
|
|
406
|
+
nullable(manifest.createdAt),
|
|
407
|
+
nullable(manifest.updatedAt),
|
|
408
|
+
manifest.dataflow.map(
|
|
409
|
+
(flow) =>
|
|
410
|
+
new APPDataflowT(
|
|
411
|
+
flow.name,
|
|
412
|
+
flowDirectionToFB[flow.direction ?? "to_page"],
|
|
413
|
+
flow.sdsSchema,
|
|
414
|
+
flowTransportToFB[flow.transport ?? "ipfs_cid"],
|
|
415
|
+
nullable(flow.locator),
|
|
416
|
+
nullable(flow.moduleId),
|
|
417
|
+
nullable(flow.methodId),
|
|
418
|
+
nullable(flow.portId),
|
|
419
|
+
contentEncodingToFB[flow.contentEncoding ?? "utf8"],
|
|
420
|
+
nullable(flow.description),
|
|
421
|
+
),
|
|
422
|
+
),
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/** Encode a validated manifest as canonical size-prefixed SDS `$APP` bytes. */
|
|
427
|
+
export function encodeAppManifest(manifest) {
|
|
428
|
+
validateAppManifest(manifest);
|
|
429
|
+
const normalized = withArrayDefaults(manifest);
|
|
430
|
+
const builder = new flatbuffers.Builder(1024);
|
|
431
|
+
const root = toAppObject(normalized).pack(builder);
|
|
432
|
+
APP.finishSizePrefixedAPPBuffer(builder, root);
|
|
433
|
+
return new Uint8Array(builder.asUint8Array());
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
function fromBigInt(value) {
|
|
437
|
+
return value <= BigInt(Number.MAX_SAFE_INTEGER) ? Number(value) : value.toString();
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
function assignOptional(target, key, value) {
|
|
441
|
+
if (value !== null && value !== undefined && value !== "") {
|
|
442
|
+
target[key] = value;
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function decodeModule(module) {
|
|
447
|
+
const out = {
|
|
448
|
+
id: module.ID,
|
|
449
|
+
pluginId: module.PLUGIN_ID,
|
|
450
|
+
contentHash: module.CONTENT_HASH,
|
|
451
|
+
};
|
|
452
|
+
assignOptional(out, "version", module.VERSION);
|
|
453
|
+
assignOptional(out, "role", module.ROLE);
|
|
454
|
+
assignOptional(out, "description", module.DESCRIPTION);
|
|
455
|
+
const maxWallClockMs = fromBigInt(module.MAX_WALL_CLOCK_MS);
|
|
456
|
+
const maxCostUnits = fromBigInt(module.MAX_COST_UNITS);
|
|
457
|
+
if (maxWallClockMs !== 0) out.maxWallClockMs = maxWallClockMs;
|
|
458
|
+
if (maxCostUnits !== 0) out.maxCostUnits = maxCostUnits;
|
|
459
|
+
if (module.MAX_MEMORY_PAGES !== 0) out.maxMemoryPages = module.MAX_MEMORY_PAGES;
|
|
460
|
+
out.runtimeTarget = runtimeTargetFromFB[module.RUNTIME_TARGET];
|
|
461
|
+
return out;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
function decodeData(data) {
|
|
465
|
+
const out = {
|
|
466
|
+
id: data.ID,
|
|
467
|
+
sdsType: data.SDS_TYPE,
|
|
468
|
+
direction: dataDirectionFromFB[data.DIRECTION],
|
|
469
|
+
};
|
|
470
|
+
assignOptional(out, "moduleId", data.MODULE_ID);
|
|
471
|
+
assignOptional(out, "description", data.DESCRIPTION);
|
|
472
|
+
return out;
|
|
473
|
+
}
|
|
474
|
+
|
|
475
|
+
function decodeSource(source) {
|
|
476
|
+
const out = {
|
|
477
|
+
id: source.ID,
|
|
478
|
+
kind: sourceKindFromFB[source.KIND],
|
|
479
|
+
ref: source.REF,
|
|
480
|
+
};
|
|
481
|
+
assignOptional(out, "description", source.DESCRIPTION);
|
|
482
|
+
return out;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
function decodePage(page) {
|
|
486
|
+
const out = { id: page.ID };
|
|
487
|
+
assignOptional(out, "title", page.TITLE);
|
|
488
|
+
assignOptional(out, "description", page.DESCRIPTION);
|
|
489
|
+
assignOptional(out, "icon", page.ICON);
|
|
490
|
+
assignOptional(out, "color", page.COLOR);
|
|
491
|
+
assignOptional(out, "textColor", page.TEXT_COLOR);
|
|
492
|
+
assignOptional(out, "content", page.CONTENT);
|
|
493
|
+
out.encoding = contentEncodingFromFB[page.ENCODING];
|
|
494
|
+
assignOptional(out, "mediaType", page.MEDIA_TYPE);
|
|
495
|
+
assignOptional(out, "contentSha256", page.CONTENT_SHA256);
|
|
496
|
+
out.entry = page.ENTRY;
|
|
497
|
+
assignOptional(out, "moduleId", page.MODULE_ID);
|
|
498
|
+
assignOptional(out, "url", page.URL);
|
|
499
|
+
return out;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
function decodeDataflow(flow) {
|
|
503
|
+
const out = {
|
|
504
|
+
name: flow.NAME,
|
|
505
|
+
direction: flowDirectionFromFB[flow.DIRECTION],
|
|
506
|
+
sdsSchema: flow.SDS_SCHEMA,
|
|
507
|
+
transport: flowTransportFromFB[flow.TRANSPORT],
|
|
508
|
+
};
|
|
509
|
+
assignOptional(out, "locator", flow.LOCATOR);
|
|
510
|
+
assignOptional(out, "moduleId", flow.MODULE_ID);
|
|
511
|
+
assignOptional(out, "methodId", flow.METHOD_ID);
|
|
512
|
+
assignOptional(out, "portId", flow.PORT_ID);
|
|
513
|
+
out.contentEncoding = contentEncodingFromFB[flow.CONTENT_ENCODING];
|
|
514
|
+
assignOptional(out, "description", flow.DESCRIPTION);
|
|
515
|
+
return out;
|
|
516
|
+
}
|
|
517
|
+
|
|
518
|
+
/** Decode and revalidate canonical size-prefixed SDS `$APP` bytes. */
|
|
519
|
+
export function decodeAppManifest(data) {
|
|
520
|
+
const bytes = toUint8Array(data);
|
|
521
|
+
if (!bytes || bytes.length < 12) {
|
|
522
|
+
throw new TypeError("decodeAppManifest expects non-truncated FlatBuffer bytes.");
|
|
523
|
+
}
|
|
524
|
+
const identifier = new TextDecoder().decode(bytes.subarray(8, 12));
|
|
525
|
+
if (identifier !== APP_FILE_IDENTIFIER) {
|
|
526
|
+
throw new Error(
|
|
527
|
+
`APP manifest buffer identifier mismatch (expected ${APP_FILE_IDENTIFIER}).`,
|
|
528
|
+
);
|
|
529
|
+
}
|
|
530
|
+
const root = APP.getSizePrefixedRootAsAPP(
|
|
531
|
+
new flatbuffers.ByteBuffer(new Uint8Array(bytes)),
|
|
532
|
+
).unpack();
|
|
533
|
+
const manifest = {
|
|
534
|
+
id: root.ID,
|
|
535
|
+
name: root.NAME ?? "",
|
|
536
|
+
version: root.VERSION ?? "",
|
|
537
|
+
modules: root.MODULES.map(decodeModule),
|
|
538
|
+
data: root.DATA.map(decodeData),
|
|
539
|
+
sources: root.SOURCES.map(decodeSource),
|
|
540
|
+
pages: root.UI.map(decodePage),
|
|
541
|
+
dataflow: root.DATAFLOW.map(decodeDataflow),
|
|
542
|
+
};
|
|
543
|
+
assignOptional(manifest, "description", root.DESCRIPTION);
|
|
544
|
+
assignOptional(manifest, "createdAt", root.CREATED_AT);
|
|
545
|
+
assignOptional(manifest, "updatedAt", root.UPDATED_AT);
|
|
546
|
+
validateAppManifest(manifest);
|
|
547
|
+
return manifest;
|
|
548
|
+
}
|
package/src/app/index.js
ADDED
package/src/browser.js
CHANGED
|
@@ -12,6 +12,11 @@ export * from "./host/browserHost.js";
|
|
|
12
12
|
export * from "./host/browserEdgeShims.js";
|
|
13
13
|
export * from "./host/wasiShim.js";
|
|
14
14
|
export * from "./host/abi.js";
|
|
15
|
+
export * from "./host/sabHostcallChannel.js";
|
|
16
|
+
export * from "./host/timerDriver.js";
|
|
17
|
+
export * from "./flow/index.js";
|
|
18
|
+
export * from "./compat/index.js";
|
|
15
19
|
export * from "./host/isomorphicLoader.js";
|
|
16
20
|
export { createBrowserModuleHarness, detectArtifactProfile } from "./testing/browserModuleHarness.js";
|
|
21
|
+
export { createWorkerModuleHarness } from "./testing/workerModuleHarness.js";
|
|
17
22
|
export { createModuleFlatBufferStreamPump } from "./testing/moduleFlatbufferStreamPump.js";
|
package/src/bundle/constants.js
CHANGED
|
@@ -5,6 +5,7 @@ export const DEFAULT_HASH_ALGORITHM = "sha256";
|
|
|
5
5
|
export const DEFAULT_MANIFEST_EXPORT_SYMBOL = "plugin_get_manifest_flatbuffer";
|
|
6
6
|
export const DEFAULT_MANIFEST_SIZE_SYMBOL =
|
|
7
7
|
"plugin_get_manifest_flatbuffer_size";
|
|
8
|
+
export const SDS_MANIFEST_SECTION_NAME = "sds.manifest";
|
|
8
9
|
export const SDS_DEPLOYMENT_SECTION_NAME = "sds.deployment";
|
|
9
10
|
export const SDS_DEPLOYMENT_ENTRY_ID = "deployment-plan";
|
|
10
11
|
export const SDS_DEPLOYMENT_MEDIA_TYPE =
|
package/src/bundle/index.js
CHANGED
|
@@ -1,3 +1,18 @@
|
|
|
1
1
|
export * from "./constants.js";
|
|
2
2
|
export * from "./codec.js";
|
|
3
3
|
export * from "./wasm.js";
|
|
4
|
+
export * from "./signing.js";
|
|
5
|
+
// Re-exported under explicit names rather than `export *`: sigdomain's own
|
|
6
|
+
// names (`statement`, `domains`, `describe`, `registered`) are deliberately
|
|
7
|
+
// terse for callers that import the module directly, and far too generic to
|
|
8
|
+
// put in a shared namespace.
|
|
9
|
+
export {
|
|
10
|
+
CONTENT_HASH_SIZE as SIGNATURE_STATEMENT_CONTENT_HASH_SIZE,
|
|
11
|
+
DOMAIN_MODULE_PUBLICATION_V1,
|
|
12
|
+
DOMAIN_UPDATE_MANIFEST_V1,
|
|
13
|
+
SignatureDomainError,
|
|
14
|
+
describe as describeSignatureDomain,
|
|
15
|
+
domains as registeredSignatureDomains,
|
|
16
|
+
registered as isRegisteredSignatureDomain,
|
|
17
|
+
statement as buildSignatureStatement,
|
|
18
|
+
} from "./sigdomain.js";
|