space-data-module-sdk 0.8.3 → 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 +26 -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,339 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Canonical HTTP envelope helpers for WASM-served HTTP.
|
|
3
|
+
*
|
|
4
|
+
* Schema source of truth: `schemas/HttpRequestAbi.fbs` ($HTQ) and
|
|
5
|
+
* `schemas/HttpResponseAbi.fbs` ($HTR); generated bindings live in
|
|
6
|
+
* `src/generated/http/` (regenerate with
|
|
7
|
+
* `node scripts/generate-http-abi-bindings.mjs`).
|
|
8
|
+
*
|
|
9
|
+
* Contract (TRUE isomorphism): the host is a dumb pipe. It encodes exactly
|
|
10
|
+
* what arrived on the wire into an HttpRequest frame, hands it to the
|
|
11
|
+
* module's HTTP method, and streams the returned HttpResponse frame back
|
|
12
|
+
* verbatim. Query parsing, routing, format negotiation, and caching
|
|
13
|
+
* decisions all happen inside the wasm module.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
import * as flatbuffers from "flatbuffers";
|
|
17
|
+
|
|
18
|
+
import { HttpHeader } from "../generated/http/sdn/http/http-header.js";
|
|
19
|
+
import { HttpRequest } from "../generated/http/sdn/http/http-request.js";
|
|
20
|
+
import { HttpResponse } from "../generated/http/sdn/http/http-response.js";
|
|
21
|
+
|
|
22
|
+
export const HTTP_REQUEST_SCHEMA_NAME = "HttpRequestAbi.fbs";
|
|
23
|
+
export const HTTP_REQUEST_FILE_IDENTIFIER = "$HTQ";
|
|
24
|
+
export const HTTP_REQUEST_ROOT_TYPE_NAME = "HttpRequest";
|
|
25
|
+
export const HTTP_RESPONSE_SCHEMA_NAME = "HttpResponseAbi.fbs";
|
|
26
|
+
export const HTTP_RESPONSE_FILE_IDENTIFIER = "$HTR";
|
|
27
|
+
export const HTTP_RESPONSE_ROOT_TYPE_NAME = "HttpResponse";
|
|
28
|
+
|
|
29
|
+
/** Manifest-ready type refs for HTTP method ports. */
|
|
30
|
+
export const HTTP_REQUEST_TYPE_REF = Object.freeze({
|
|
31
|
+
schemaName: HTTP_REQUEST_SCHEMA_NAME,
|
|
32
|
+
fileIdentifier: HTTP_REQUEST_FILE_IDENTIFIER,
|
|
33
|
+
rootTypeName: HTTP_REQUEST_ROOT_TYPE_NAME,
|
|
34
|
+
});
|
|
35
|
+
export const HTTP_RESPONSE_TYPE_REF = Object.freeze({
|
|
36
|
+
schemaName: HTTP_RESPONSE_SCHEMA_NAME,
|
|
37
|
+
fileIdentifier: HTTP_RESPONSE_FILE_IDENTIFIER,
|
|
38
|
+
rootTypeName: HTTP_RESPONSE_ROOT_TYPE_NAME,
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function toHeaderEntries(headers) {
|
|
42
|
+
if (headers === undefined || headers === null) {
|
|
43
|
+
return [];
|
|
44
|
+
}
|
|
45
|
+
let entries;
|
|
46
|
+
if (headers instanceof Map) {
|
|
47
|
+
entries = Array.from(headers.entries());
|
|
48
|
+
} else if (Array.isArray(headers)) {
|
|
49
|
+
entries = headers.map((entry) => {
|
|
50
|
+
if (Array.isArray(entry)) {
|
|
51
|
+
return [entry[0], entry[1]];
|
|
52
|
+
}
|
|
53
|
+
if (entry && typeof entry === "object") {
|
|
54
|
+
return [entry.name, entry.value];
|
|
55
|
+
}
|
|
56
|
+
throw new TypeError(
|
|
57
|
+
"HTTP headers array entries must be [name, value] pairs or {name, value} objects.",
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
} else if (typeof headers === "object") {
|
|
61
|
+
entries = Object.entries(headers);
|
|
62
|
+
} else {
|
|
63
|
+
throw new TypeError(
|
|
64
|
+
"HTTP headers must be an object, a Map, or an array of pairs.",
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
const normalized = entries.map(([name, value]) => [
|
|
68
|
+
String(name),
|
|
69
|
+
String(value ?? ""),
|
|
70
|
+
]);
|
|
71
|
+
// HttpHeader.NAME is a FlatBuffers key field: the vector must be sorted by
|
|
72
|
+
// NAME (byte order) so binary-search lookups stay valid.
|
|
73
|
+
normalized.sort((left, right) =>
|
|
74
|
+
left[0] < right[0] ? -1 : left[0] > right[0] ? 1 : 0,
|
|
75
|
+
);
|
|
76
|
+
return normalized;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function toBodyBytes(body) {
|
|
80
|
+
if (body === undefined || body === null) {
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
if (typeof body === "string") {
|
|
84
|
+
return new TextEncoder().encode(body);
|
|
85
|
+
}
|
|
86
|
+
if (body instanceof Uint8Array) {
|
|
87
|
+
return body;
|
|
88
|
+
}
|
|
89
|
+
if (body instanceof ArrayBuffer) {
|
|
90
|
+
return new Uint8Array(body);
|
|
91
|
+
}
|
|
92
|
+
if (ArrayBuffer.isView(body)) {
|
|
93
|
+
return new Uint8Array(body.buffer, body.byteOffset, body.byteLength);
|
|
94
|
+
}
|
|
95
|
+
throw new TypeError("HTTP body must be a string, Uint8Array, or ArrayBuffer.");
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
function buildHeadersVector(builder, table, headers) {
|
|
99
|
+
const entries = toHeaderEntries(headers);
|
|
100
|
+
if (entries.length === 0) {
|
|
101
|
+
return 0;
|
|
102
|
+
}
|
|
103
|
+
const offsets = entries.map(([name, value]) =>
|
|
104
|
+
HttpHeader.createHttpHeader(
|
|
105
|
+
builder,
|
|
106
|
+
builder.createString(name),
|
|
107
|
+
builder.createString(value),
|
|
108
|
+
),
|
|
109
|
+
);
|
|
110
|
+
return table.createHeadersVector(builder, offsets);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/**
|
|
114
|
+
* Encode an HttpRequest envelope ($HTQ).
|
|
115
|
+
*
|
|
116
|
+
* @param {object} request
|
|
117
|
+
* @param {string} [request.method] HTTP verb (upper-cased here).
|
|
118
|
+
* @param {string} [request.path] URL path without the query string.
|
|
119
|
+
* @param {string} [request.query] Raw query string without the leading "?".
|
|
120
|
+
* @param {object|Map|Array} [request.headers] Header name/value pairs.
|
|
121
|
+
* @param {string|Uint8Array|ArrayBuffer} [request.body]
|
|
122
|
+
* @param {string} [request.remote] Remote "ip:port".
|
|
123
|
+
* @returns {Uint8Array} Finished FlatBuffer with file identifier "$HTQ".
|
|
124
|
+
*/
|
|
125
|
+
export function encodeHttpRequest(request = {}) {
|
|
126
|
+
const builder = new flatbuffers.Builder(1024);
|
|
127
|
+
const headersVector = buildHeadersVector(builder, HttpRequest, request.headers);
|
|
128
|
+
const bodyBytes = toBodyBytes(request.body);
|
|
129
|
+
const bodyVector = bodyBytes ? HttpRequest.createBodyVector(builder, bodyBytes) : 0;
|
|
130
|
+
const methodOffset = builder.createString(
|
|
131
|
+
String(request.method ?? "GET").toUpperCase(),
|
|
132
|
+
);
|
|
133
|
+
const pathOffset = builder.createString(String(request.path ?? "/"));
|
|
134
|
+
const queryOffset = builder.createString(String(request.query ?? ""));
|
|
135
|
+
const remoteOffset = builder.createString(String(request.remote ?? ""));
|
|
136
|
+
const root = HttpRequest.createHttpRequest(
|
|
137
|
+
builder,
|
|
138
|
+
methodOffset,
|
|
139
|
+
pathOffset,
|
|
140
|
+
queryOffset,
|
|
141
|
+
headersVector,
|
|
142
|
+
bodyVector,
|
|
143
|
+
remoteOffset,
|
|
144
|
+
);
|
|
145
|
+
HttpRequest.finishHttpRequestBuffer(builder, root);
|
|
146
|
+
return builder.asUint8Array();
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
function decodeHeaders(table) {
|
|
150
|
+
const headers = [];
|
|
151
|
+
for (let index = 0; index < table.headersLength(); index += 1) {
|
|
152
|
+
const header = table.headers(index);
|
|
153
|
+
headers.push({
|
|
154
|
+
name: header?.name() ?? "",
|
|
155
|
+
value: header?.value() ?? "",
|
|
156
|
+
});
|
|
157
|
+
}
|
|
158
|
+
return headers;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Decode an HttpRequest envelope ($HTQ) back into a plain object.
|
|
163
|
+
*
|
|
164
|
+
* @param {Uint8Array} bytes
|
|
165
|
+
* @returns {{method: string, path: string, query: string,
|
|
166
|
+
* headers: Array<{name: string, value: string}>, body: Uint8Array,
|
|
167
|
+
* remote: string}}
|
|
168
|
+
*/
|
|
169
|
+
export function decodeHttpRequest(bytes) {
|
|
170
|
+
const buffer = new flatbuffers.ByteBuffer(bytes);
|
|
171
|
+
if (!HttpRequest.bufferHasIdentifier(buffer)) {
|
|
172
|
+
throw new TypeError(
|
|
173
|
+
`HTTP request envelope is missing the "${HTTP_REQUEST_FILE_IDENTIFIER}" file identifier.`,
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
const request = HttpRequest.getRootAsHttpRequest(buffer);
|
|
177
|
+
return {
|
|
178
|
+
method: request.method() ?? "",
|
|
179
|
+
path: request.path() ?? "",
|
|
180
|
+
query: request.query() ?? "",
|
|
181
|
+
headers: decodeHeaders(request),
|
|
182
|
+
body: request.bodyArray() ?? new Uint8Array(0),
|
|
183
|
+
remote: request.remote() ?? "",
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/**
|
|
188
|
+
* Encode an HttpResponse envelope ($HTR).
|
|
189
|
+
*
|
|
190
|
+
* @param {object} response
|
|
191
|
+
* @param {number} [response.status]
|
|
192
|
+
* @param {object|Map|Array} [response.headers]
|
|
193
|
+
* @param {string|Uint8Array|ArrayBuffer} [response.body]
|
|
194
|
+
* @param {number|bigint} [response.bodyRefToken] Opaque host body-ref token
|
|
195
|
+
* (out-of-band body substitution — see the schema doc). Only meaningful
|
|
196
|
+
* together with bodyRefSize > 0 and an absent body.
|
|
197
|
+
* @param {number|bigint} [response.bodyRefSize] Byte length of the
|
|
198
|
+
* referenced body.
|
|
199
|
+
* @returns {Uint8Array} Finished FlatBuffer with file identifier "$HTR".
|
|
200
|
+
*/
|
|
201
|
+
export function encodeHttpResponse(response = {}) {
|
|
202
|
+
const status = Number(response.status ?? 200);
|
|
203
|
+
if (!Number.isInteger(status) || status < 0 || status > 0xffff) {
|
|
204
|
+
throw new RangeError("HTTP response status must be a ushort.");
|
|
205
|
+
}
|
|
206
|
+
const builder = new flatbuffers.Builder(1024);
|
|
207
|
+
const headersVector = buildHeadersVector(builder, HttpResponse, response.headers);
|
|
208
|
+
const bodyBytes = toBodyBytes(response.body);
|
|
209
|
+
const bodyVector = bodyBytes ? HttpResponse.createBodyVector(builder, bodyBytes) : 0;
|
|
210
|
+
const root = HttpResponse.createHttpResponse(
|
|
211
|
+
builder,
|
|
212
|
+
status,
|
|
213
|
+
headersVector,
|
|
214
|
+
bodyVector,
|
|
215
|
+
BigInt(response.bodyRefToken ?? 0),
|
|
216
|
+
BigInt(response.bodyRefSize ?? 0),
|
|
217
|
+
);
|
|
218
|
+
HttpResponse.finishHttpResponseBuffer(builder, root);
|
|
219
|
+
return builder.asUint8Array();
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/**
|
|
223
|
+
* Decode an HttpResponse envelope ($HTR) back into a plain object.
|
|
224
|
+
*
|
|
225
|
+
* bodyRefToken/bodyRefSize surface the optional out-of-band body reference
|
|
226
|
+
* (both 0 when the response carries an inline body or none). Hosts resolve
|
|
227
|
+
* a non-zero reference against their own body-ref registry (the buffer they
|
|
228
|
+
* registered when a capability hostcall answered in "deliver":"ref" mode).
|
|
229
|
+
*
|
|
230
|
+
* @param {Uint8Array} bytes
|
|
231
|
+
* @returns {{status: number, headers: Array<{name: string, value: string}>,
|
|
232
|
+
* body: Uint8Array, bodyRefToken: bigint, bodyRefSize: number}}
|
|
233
|
+
*/
|
|
234
|
+
export function decodeHttpResponse(bytes) {
|
|
235
|
+
const buffer = new flatbuffers.ByteBuffer(bytes);
|
|
236
|
+
if (!HttpResponse.bufferHasIdentifier(buffer)) {
|
|
237
|
+
throw new TypeError(
|
|
238
|
+
`HTTP response envelope is missing the "${HTTP_RESPONSE_FILE_IDENTIFIER}" file identifier.`,
|
|
239
|
+
);
|
|
240
|
+
}
|
|
241
|
+
const response = HttpResponse.getRootAsHttpResponse(buffer);
|
|
242
|
+
return {
|
|
243
|
+
status: response.status(),
|
|
244
|
+
headers: decodeHeaders(response),
|
|
245
|
+
body: response.bodyArray() ?? new Uint8Array(0),
|
|
246
|
+
bodyRefToken: response.bodyRefToken(),
|
|
247
|
+
bodyRefSize: Number(response.bodyRefSize()),
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Word-folded FNV-1a 64 over a byte buffer — THE content-hash algorithm of
|
|
253
|
+
* body-reference descriptors ({"$sdnbodyref":1,...,"fnv1a64":"<16 hex>"}) and
|
|
254
|
+
* of the flow modules' stream entity tags (W/"fnv1a64-<16 hex>"). Folds
|
|
255
|
+
* 8-byte little-endian words, then the tail bytes individually; both hosts
|
|
256
|
+
* (Go: sdn-server, JS: this function) and the in-wasm hashers
|
|
257
|
+
* (foundation/decision-gate) MUST produce identical values over identical
|
|
258
|
+
* bytes so reference-mode etags equal hashed-stream etags.
|
|
259
|
+
*
|
|
260
|
+
* @param {Uint8Array} bytes
|
|
261
|
+
* @returns {string} 16-char lower-case hex digest.
|
|
262
|
+
*/
|
|
263
|
+
export function fnv1a64Hex(bytes) {
|
|
264
|
+
const prime = 1099511628211n;
|
|
265
|
+
const mask = 0xffffffffffffffffn;
|
|
266
|
+
// NOTE: this offset basis (1469598103934665603) is the value the deployed
|
|
267
|
+
// foundation/decision-gate hasher has always used (it drops the trailing
|
|
268
|
+
// "7" of the textbook FNV-1a 64 basis 14695981039346656037). The tag is an
|
|
269
|
+
// opaque validator, so the exact constant does not matter — MATCHING the
|
|
270
|
+
// in-wasm hasher bit-for-bit does.
|
|
271
|
+
let hash = 1469598103934665603n;
|
|
272
|
+
const words = bytes.length - (bytes.length % 8);
|
|
273
|
+
const view = new DataView(bytes.buffer, bytes.byteOffset, bytes.byteLength);
|
|
274
|
+
let i = 0;
|
|
275
|
+
for (; i < words; i += 8) {
|
|
276
|
+
hash ^= view.getBigUint64(i, true);
|
|
277
|
+
hash = (hash * prime) & mask;
|
|
278
|
+
}
|
|
279
|
+
for (; i < bytes.length; i += 1) {
|
|
280
|
+
hash ^= BigInt(bytes[i]);
|
|
281
|
+
hash = (hash * prime) & mask;
|
|
282
|
+
}
|
|
283
|
+
return hash.toString(16).padStart(16, "0");
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
/**
|
|
287
|
+
* Host-side body-reference registry for "deliver":"ref" capability results
|
|
288
|
+
* and $HTR BODY_REF resolution — the JS counterpart of the Go hostcall
|
|
289
|
+
* bridge's registry (sdn-server internal/modulert). One registry per module
|
|
290
|
+
* instance / hostcall bridge; tokens are monotonic and single-exchange:
|
|
291
|
+
* `take` removes the entry, `reset` clears everything at the end of an
|
|
292
|
+
* exchange.
|
|
293
|
+
*
|
|
294
|
+
* @returns {{put(bytes: Uint8Array): number,
|
|
295
|
+
* take(token: number|bigint): Uint8Array|null,
|
|
296
|
+
* reset(): void, size(): number}}
|
|
297
|
+
*/
|
|
298
|
+
export function createBodyRefRegistry() {
|
|
299
|
+
const entries = new Map();
|
|
300
|
+
let next = 1;
|
|
301
|
+
return {
|
|
302
|
+
put(bytes) {
|
|
303
|
+
const token = next;
|
|
304
|
+
next += 1;
|
|
305
|
+
entries.set(token, bytes);
|
|
306
|
+
return token;
|
|
307
|
+
},
|
|
308
|
+
take(token) {
|
|
309
|
+
const key = Number(token);
|
|
310
|
+
const bytes = entries.get(key);
|
|
311
|
+
if (bytes === undefined) return null;
|
|
312
|
+
entries.delete(key);
|
|
313
|
+
return bytes;
|
|
314
|
+
},
|
|
315
|
+
reset() {
|
|
316
|
+
entries.clear();
|
|
317
|
+
},
|
|
318
|
+
size() {
|
|
319
|
+
return entries.size;
|
|
320
|
+
},
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* Case-insensitive header lookup over decoded `{name, value}` entries.
|
|
326
|
+
*
|
|
327
|
+
* @param {Array<{name: string, value: string}>} headers
|
|
328
|
+
* @param {string} name
|
|
329
|
+
* @returns {string|null}
|
|
330
|
+
*/
|
|
331
|
+
export function findHttpHeader(headers, name) {
|
|
332
|
+
const needle = String(name).toLowerCase();
|
|
333
|
+
for (const header of Array.isArray(headers) ? headers : []) {
|
|
334
|
+
if (String(header?.name ?? "").toLowerCase() === needle) {
|
|
335
|
+
return header.value ?? "";
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
return null;
|
|
339
|
+
}
|