@floegence/flowersec-core 5.11.0 → 6.1.0
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/LICENSE +1 -1
- package/README.md +170 -58
- package/THIRD_PARTY_NOTICES.md +3072 -7
- package/dist/application/rpcJSON.d.ts +15 -0
- package/dist/{rpc/validate.js → application/rpcJSON.js} +1 -1
- package/dist/browser/clientV4.d.ts +61 -0
- package/dist/browser/clientV4.js +179 -0
- package/dist/browser/index.d.ts +15 -8
- package/dist/browser/index.js +5 -3
- package/dist/browser/indexedDBPoolV4.d.ts +101 -0
- package/dist/browser/indexedDBPoolV4.js +634 -0
- package/dist/browser/liveHTTPSV4.d.ts +35 -0
- package/dist/browser/liveHTTPSV4.js +162 -0
- package/dist/browser/localBrowserBridge.d.ts +20 -0
- package/dist/browser/localBrowserBridge.js +82 -0
- package/dist/browser/poolServerAllow.d.ts +21 -0
- package/dist/browser/poolServerAllow.js +151 -0
- package/dist/browser/webTransportPositionsV4.d.ts +16 -0
- package/dist/browser/webTransportPositionsV4.js +75 -0
- package/dist/browser/webTransportStreamV4.d.ts +36 -0
- package/dist/browser/webTransportStreamV4.js +370 -0
- package/dist/browser/webTransportV4.d.ts +126 -0
- package/dist/browser/webTransportV4.js +627 -0
- package/dist/browser/wssV4.d.ts +69 -0
- package/dist/browser/wssV4.js +339 -0
- package/dist/cli.d.ts +24 -1
- package/dist/cli.js +91 -119
- package/dist/defaults.d.ts +1 -23
- package/dist/defaults.js +1 -23
- package/dist/facade.d.ts +104 -21
- package/dist/facade.js +45 -8
- package/dist/generated/brotliWorker.d.ts +1 -0
- package/dist/generated/brotliWorker.js +3 -0
- package/dist/generated/idna151.d.ts +2 -0
- package/dist/generated/idna151.js +38 -0
- package/dist/generated/normalization151.d.ts +5 -0
- package/dist/generated/normalization151.js +878 -0
- package/dist/generated/sqliteWorkers.d.ts +2 -0
- package/dist/generated/sqliteWorkers.js +3 -0
- package/dist/generated/transportV4APIResults.d.ts +21 -1
- package/dist/generated/transportV4APIResults.js +42 -1
- package/dist/generated/transportV4Registry.d.ts +276 -2
- package/dist/generated/transportV4Registry.js +10 -4
- package/dist/interop/browserRunner.d.ts +72 -0
- package/dist/interop/browserRunner.js +354 -0
- package/dist/interop/currentClock.d.ts +3 -0
- package/dist/interop/currentClock.js +39 -0
- package/dist/interop/currentContracts.d.ts +6 -0
- package/dist/interop/currentContracts.js +14 -0
- package/dist/interop/currentNativeTunnel.d.ts +31 -0
- package/dist/interop/currentNativeTunnel.js +185 -0
- package/dist/interop/currentParity.d.ts +68 -0
- package/dist/interop/currentParity.js +392 -0
- package/dist/interop/currentPeer.d.ts +252 -0
- package/dist/interop/currentPeer.js +677 -0
- package/dist/interop/currentRegisteredTunnelPeer.d.ts +37 -0
- package/dist/interop/currentRegisteredTunnelPeer.js +93 -0
- package/dist/interop/currentRelayPeer.d.ts +131 -0
- package/dist/interop/currentRelayPeer.js +263 -0
- package/dist/interop/currentServer.d.ts +44 -0
- package/dist/interop/currentServer.js +299 -0
- package/dist/interop/currentTLSPin.d.ts +9 -0
- package/dist/interop/currentTLSPin.js +44 -0
- package/dist/interop/currentTunnelMaterial.d.ts +34 -0
- package/dist/interop/currentTunnelMaterial.js +100 -0
- package/dist/interop/httpApplicationPeer.d.ts +15 -0
- package/dist/interop/httpApplicationPeer.js +167 -0
- package/dist/interop/invalidProofPeer.d.ts +8 -0
- package/dist/interop/invalidProofPeer.js +106 -0
- package/dist/interop/proxyServerPeer.js +8 -56
- package/dist/interop/serverParityPeer.d.ts +101 -1
- package/dist/interop/serverParityPeer.js +550 -578
- package/dist/node/acceptorCurrent.d.ts +55 -0
- package/dist/node/acceptorCurrent.js +286 -0
- package/dist/node/admissionRecord.d.ts +23 -0
- package/dist/node/admissionRecord.js +178 -0
- package/dist/node/clientV4.d.ts +59 -0
- package/dist/node/clientV4.js +197 -0
- package/dist/node/connectionPath.d.ts +2 -0
- package/dist/node/connectionPath.js +18 -0
- package/dist/node/endpointDialer.d.ts +70 -0
- package/dist/node/endpointDialer.js +231 -0
- package/dist/node/endpointListener.d.ts +48 -0
- package/dist/node/endpointListener.js +403 -0
- package/dist/node/endpointTransport.d.ts +7 -0
- package/dist/node/endpointTransport.js +18 -0
- package/dist/node/grantIssuerCurrent.d.ts +64 -0
- package/dist/node/grantIssuerCurrent.js +355 -0
- package/dist/node/index.d.ts +52 -16
- package/dist/node/index.js +24 -6
- package/dist/node/liveHTTPSV4.d.ts +28 -0
- package/dist/node/liveHTTPSV4.js +298 -0
- package/dist/node/liveTunnelAuthorityCurrent.d.ts +153 -0
- package/dist/node/liveTunnelAuthorityCurrent.js +590 -0
- package/dist/node/nativeDuplexBridgeV4.d.ts +41 -0
- package/dist/node/nativeDuplexBridgeV4.js +494 -0
- package/dist/node/nativeTransportCurrent.d.ts +196 -0
- package/dist/node/nativeTransportCurrent.js +37 -0
- package/dist/node/poolServerAllow.d.ts +33 -0
- package/dist/node/poolServerAllow.js +277 -0
- package/dist/node/proxyCredentials.d.ts +67 -0
- package/dist/node/proxyCredentials.js +364 -0
- package/dist/node/proxyNetwork.d.ts +18 -0
- package/dist/node/proxyNetwork.js +213 -0
- package/dist/node/proxyServer.d.ts +30 -4
- package/dist/node/proxyServer.js +599 -154
- package/dist/node/rawQUICCurrent.d.ts +139 -0
- package/dist/node/rawQUICCurrent.js +1177 -0
- package/dist/node/registeredLiveTunnelControl.d.ts +74 -0
- package/dist/node/registeredLiveTunnelControl.js +865 -0
- package/dist/node/registeredPoolTunnelAuthority.d.ts +50 -0
- package/dist/node/registeredPoolTunnelAuthority.js +305 -0
- package/dist/node/registeredTunnelControl.d.ts +189 -0
- package/dist/node/registeredTunnelControl.js +1007 -0
- package/dist/node/registeredWinnerContinuation.d.ts +26 -0
- package/dist/node/registeredWinnerContinuation.js +83 -0
- package/dist/node/relayNativePair.d.ts +62 -0
- package/dist/node/relayNativePair.js +737 -0
- package/dist/node/relayRecord.d.ts +57 -0
- package/dist/node/relayRecord.js +275 -0
- package/dist/node/serveRawQUIC.d.ts +58 -0
- package/dist/node/serveRawQUIC.js +331 -0
- package/dist/node/serveWSS.d.ts +58 -0
- package/dist/node/serveWSS.js +309 -0
- package/dist/node/sqliteAdmission.d.ts +100 -0
- package/dist/node/sqliteAdmission.js +1185 -0
- package/dist/node/sqliteExecutionContentV4.d.ts +63 -0
- package/dist/node/sqliteExecutionContentV4.js +251 -0
- package/dist/node/sqliteExecutionV4.d.ts +114 -0
- package/dist/node/sqliteExecutionV4.js +1052 -0
- package/dist/node/sqliteFormat.d.ts +20 -0
- package/dist/node/sqliteFormat.js +72 -0
- package/dist/node/sqliteInspectionV4.d.ts +7 -0
- package/dist/node/sqliteInspectionV4.js +47 -0
- package/dist/node/sqliteNativeV4.d.ts +3 -0
- package/dist/node/sqliteNativeV4.js +16 -0
- package/dist/node/sqlitePoolV4.d.ts +41 -0
- package/dist/node/sqlitePoolV4.js +282 -0
- package/dist/node/sqlitePoolWorkerProgramV4.js +411 -0
- package/dist/node/sqlitePoolWorkerV4.d.ts +67 -0
- package/dist/node/sqlitePoolWorkerV4.js +206 -0
- package/dist/node/sqliteV4.d.ts +82 -0
- package/dist/node/sqliteV4.js +166 -0
- package/dist/node/sqliteWorkerProgramV4.js +175 -0
- package/dist/node/sqliteWorkerV4.d.ts +47 -0
- package/dist/node/sqliteWorkerV4.js +142 -0
- package/dist/node/streamDuplexV4.d.ts +33 -0
- package/dist/node/streamDuplexV4.js +359 -0
- package/dist/node/tunnelListenerPreparation.d.ts +37 -0
- package/dist/node/tunnelListenerPreparation.js +162 -0
- package/dist/node/tunnelRuntime.d.ts +124 -0
- package/dist/node/tunnelRuntime.js +1205 -0
- package/dist/node/webTransportCurrent.d.ts +24 -0
- package/dist/node/webTransportCurrent.js +12 -0
- package/dist/node/wssV4.d.ts +99 -0
- package/dist/node/wssV4.js +846 -0
- package/dist/proxy/admission.d.ts +21 -0
- package/dist/proxy/admission.js +126 -0
- package/dist/proxy/brotliBody.d.ts +10 -0
- package/dist/proxy/brotliBody.js +85 -0
- package/dist/proxy/credentialControl.d.ts +30 -0
- package/dist/proxy/credentialControl.js +86 -0
- package/dist/proxy/currentStream.d.ts +24 -0
- package/dist/proxy/currentStream.js +158 -0
- package/dist/proxy/fetch.d.ts +3 -2
- package/dist/proxy/fetch.js +96 -29
- package/dist/proxy/headers.d.ts +8 -0
- package/dist/proxy/headers.js +63 -0
- package/dist/proxy/index.d.ts +4 -0
- package/dist/proxy/index.js +2 -0
- package/dist/proxy/integration.d.ts +12 -8
- package/dist/proxy/integration.js +23 -16
- package/dist/proxy/policy.d.ts +5 -0
- package/dist/proxy/policy.js +60 -22
- package/dist/proxy/publicationOwner.d.ts +10 -0
- package/dist/proxy/publicationOwner.js +130 -0
- package/dist/proxy/requestAssociation.d.ts +11 -0
- package/dist/proxy/requestAssociation.js +8 -0
- package/dist/proxy/runtime.d.ts +3 -1
- package/dist/proxy/runtime.js +403 -170
- package/dist/proxy/scope.js +2 -2
- package/dist/proxy/serviceWorker.d.ts +3 -0
- package/dist/proxy/serviceWorker.js +634 -176
- package/dist/proxy/serviceWorkerRuntime.js +26 -1
- package/dist/proxy/stream.d.ts +16 -3
- package/dist/proxy/stream.js +6 -0
- package/dist/proxy/surface.d.ts +45 -0
- package/dist/proxy/surface.js +384 -0
- package/dist/proxy/types.d.ts +49 -6
- package/dist/proxy/windowBridge.d.ts +11 -3
- package/dist/proxy/windowBridge.js +62 -19
- package/dist/proxy/wire.d.ts +11 -0
- package/dist/proxy/wire.js +214 -0
- package/dist/proxy/wsPatch.js +13 -6
- package/dist/public/contract.d.ts +0 -71
- package/dist/public/contract.js +0 -8
- package/dist/public/streamKind.d.ts +3 -0
- package/dist/public/streamKind.js +19 -0
- package/dist/public/streamMetadata.d.ts +34 -2
- package/dist/public/streamMetadata.js +206 -13
- package/dist/v4/admissionOffer.d.ts +8 -0
- package/dist/v4/checkpoint.d.ts +23 -0
- package/dist/v4/checkpoint.js +16 -0
- package/dist/v4/clientServices.d.ts +35 -0
- package/dist/v4/clientServices.js +11 -0
- package/dist/v4/connectionDiagnostic.d.ts +42 -0
- package/dist/v4/connectionDiagnostic.js +45 -0
- package/dist/v4/connectionRequirements.d.ts +5 -0
- package/dist/v4/connectionRequirements.js +34 -0
- package/dist/v4/controller.d.ts +122 -0
- package/dist/v4/controller.js +1161 -0
- package/dist/v4/controllerNotifications.d.ts +81 -0
- package/dist/v4/controllerNotifications.js +610 -0
- package/dist/v4/diagnostics.d.ts +44 -0
- package/dist/v4/diagnostics.js +9 -0
- package/dist/v4/drain.d.ts +39 -0
- package/dist/v4/drain.js +80 -0
- package/dist/v4/duplexBridge.d.ts +53 -0
- package/dist/v4/duplexBridge.js +446 -0
- package/dist/v4/entrypoints.d.ts +20 -0
- package/dist/v4/entrypoints.js +50 -0
- package/dist/v4/eventSource.d.ts +34 -0
- package/dist/v4/eventSource.js +28 -0
- package/dist/v4/handlerPlan.d.ts +53 -0
- package/dist/v4/handlerPlan.js +129 -0
- package/dist/v4/liveness.d.ts +20 -0
- package/dist/v4/liveness.js +10 -0
- package/dist/v4/localReport.d.ts +17 -0
- package/dist/v4/localReport.js +10 -0
- package/dist/v4/messageDefinition.d.ts +66 -0
- package/dist/v4/messageDefinition.js +109 -0
- package/dist/v4/messageStream.d.ts +89 -0
- package/dist/v4/messageStream.js +1375 -0
- package/dist/v4/notificationOperation.d.ts +30 -0
- package/dist/v4/notificationOperation.js +31 -0
- package/dist/v4/notificationSubscription.d.ts +47 -0
- package/dist/v4/notificationSubscription.js +24 -0
- package/dist/v4/operationReference.d.ts +28 -0
- package/dist/v4/operationReference.js +61 -0
- package/dist/v4/operationReferenceCodec.d.ts +20 -0
- package/dist/v4/operationReferenceCodec.js +129 -0
- package/dist/v4/operationReferenceStore.d.ts +90 -0
- package/dist/v4/operationReferenceStore.js +272 -0
- package/dist/v4/operationResultRead.d.ts +26 -0
- package/dist/v4/operationResultRead.js +24 -0
- package/dist/v4/poolControl.d.ts +11 -0
- package/dist/v4/poolControl.js +50 -0
- package/dist/v4/poolSource.d.ts +93 -0
- package/dist/v4/poolSource.js +900 -0
- package/dist/v4/public.d.ts +232 -0
- package/dist/v4/public.js +632 -0
- package/dist/v4/responsePublication.d.ts +48 -0
- package/dist/v4/responsePublication.js +227 -0
- package/dist/v4/resume.d.ts +17 -0
- package/dist/v4/resume.js +15 -0
- package/dist/v4/runtime/applicationExecutor.d.ts +190 -0
- package/dist/v4/runtime/applicationExecutor.js +759 -0
- package/dist/v4/runtime/applicationHeader.d.ts +61 -0
- package/dist/v4/runtime/applicationHeader.js +222 -0
- package/dist/v4/runtime/canonicalText.d.ts +8 -0
- package/dist/v4/runtime/canonicalText.js +142 -0
- package/dist/v4/runtime/cbor.d.ts +92 -0
- package/dist/v4/runtime/cbor.js +728 -0
- package/dist/v4/runtime/cborWriter.d.ts +18 -0
- package/dist/v4/runtime/cborWriter.js +59 -0
- package/dist/v4/runtime/checkpointToken.d.ts +41 -0
- package/dist/v4/runtime/checkpointToken.js +61 -0
- package/dist/v4/runtime/clientAdmission.d.ts +40 -0
- package/dist/v4/runtime/clientAdmission.js +378 -0
- package/dist/v4/runtime/clientSessionSpec.d.ts +45 -0
- package/dist/v4/runtime/clientSessionSpec.js +91 -0
- package/dist/v4/runtime/clock.d.ts +80 -0
- package/dist/v4/runtime/clock.js +284 -0
- package/dist/v4/runtime/connectionFacts.d.ts +23 -0
- package/dist/v4/runtime/connectionFacts.js +106 -0
- package/dist/v4/runtime/contractAcceptance.d.ts +20 -0
- package/dist/v4/runtime/contractAcceptance.js +91 -0
- package/dist/v4/runtime/contractQuery.d.ts +57 -0
- package/dist/v4/runtime/contractQuery.js +265 -0
- package/dist/v4/runtime/contractQueryAccess.d.ts +25 -0
- package/dist/v4/runtime/contractQueryAccess.js +117 -0
- package/dist/v4/runtime/contractQueryAcquisition.d.ts +83 -0
- package/dist/v4/runtime/contractQueryAcquisition.js +572 -0
- package/dist/v4/runtime/contractQueryClient.d.ts +70 -0
- package/dist/v4/runtime/contractQueryClient.js +411 -0
- package/dist/v4/runtime/contractQueryCodecs.d.ts +20 -0
- package/dist/v4/runtime/contractQueryCodecs.js +71 -0
- package/dist/v4/runtime/contractQueryExchange.d.ts +36 -0
- package/dist/v4/runtime/contractQueryExchange.js +160 -0
- package/dist/v4/runtime/contractQueryService.d.ts +42 -0
- package/dist/v4/runtime/contractQueryService.js +572 -0
- package/dist/v4/runtime/contractQuerySession.d.ts +38 -0
- package/dist/v4/runtime/contractQuerySession.js +158 -0
- package/dist/v4/runtime/contractRoutes.d.ts +87 -0
- package/dist/v4/runtime/contractRoutes.js +396 -0
- package/dist/v4/runtime/contractSnapshotReader.d.ts +59 -0
- package/dist/v4/runtime/contractSnapshotReader.js +418 -0
- package/dist/v4/runtime/contractSnapshotWriter.d.ts +32 -0
- package/dist/v4/runtime/contractSnapshotWriter.js +208 -0
- package/dist/v4/runtime/controllerServiceSource.d.ts +23 -0
- package/dist/v4/runtime/controllerServiceSource.js +109 -0
- package/dist/v4/runtime/controllerUnaryRoute.d.ts +28 -0
- package/dist/v4/runtime/credentialNamespace.d.ts +143 -0
- package/dist/v4/runtime/credentialNamespace.js +1286 -0
- package/dist/v4/runtime/credentialSupport.d.ts +60 -0
- package/dist/v4/runtime/credentialSupport.js +294 -0
- package/dist/v4/runtime/credentialVerifier.d.ts +404 -0
- package/dist/v4/runtime/credentialVerifier.js +1443 -0
- package/dist/v4/runtime/cryptoUsage.d.ts +135 -0
- package/dist/v4/runtime/cryptoUsage.js +552 -0
- package/dist/v4/runtime/deadline.d.ts +31 -0
- package/dist/v4/runtime/deadline.js +188 -0
- package/dist/v4/runtime/diagnosticCounters.d.ts +15 -0
- package/dist/v4/runtime/diagnosticCounters.js +78 -0
- package/dist/v4/runtime/diagnosticObservation.d.ts +25 -0
- package/dist/v4/runtime/diagnosticObservation.js +67 -0
- package/dist/v4/runtime/diagnosticSink.d.ts +16 -0
- package/dist/v4/runtime/diagnosticSink.js +320 -0
- package/dist/v4/runtime/ed25519.d.ts +1 -0
- package/dist/v4/runtime/ed25519.js +34 -0
- package/dist/v4/runtime/endpointHop.d.ts +12 -0
- package/dist/v4/runtime/endpointHop.js +26 -0
- package/dist/v4/runtime/envelope.d.ts +66 -0
- package/dist/v4/runtime/envelope.js +275 -0
- package/dist/v4/runtime/environment.d.ts +277 -0
- package/dist/v4/runtime/environment.js +1913 -0
- package/dist/v4/runtime/executionManagementChannel.d.ts +27 -0
- package/dist/v4/runtime/executionManagementChannel.js +733 -0
- package/dist/v4/runtime/executionManagementCodec.d.ts +84 -0
- package/dist/v4/runtime/executionManagementCodec.js +127 -0
- package/dist/v4/runtime/executionStorage.d.ts +71 -0
- package/dist/v4/runtime/executionStorage.js +10 -0
- package/dist/v4/runtime/fixedDiagnosticExecutor.d.ts +34 -0
- package/dist/v4/runtime/fixedDiagnosticExecutor.js +149 -0
- package/dist/v4/runtime/fixedManagementExecutor.d.ts +21 -0
- package/dist/v4/runtime/fixedManagementExecutor.js +153 -0
- package/dist/v4/runtime/fixedQueryExecutor.d.ts +46 -0
- package/dist/v4/runtime/fixedQueryExecutor.js +311 -0
- package/dist/v4/runtime/grantDigest.d.ts +9 -0
- package/dist/v4/runtime/grantDigest.js +31 -0
- package/dist/v4/runtime/hopAuthentication.d.ts +51 -0
- package/dist/v4/runtime/hopAuthentication.js +392 -0
- package/dist/v4/runtime/host.d.ts +15 -0
- package/dist/v4/runtime/host.js +332 -0
- package/dist/v4/runtime/initializerWorkload.d.ts +38 -0
- package/dist/v4/runtime/initializerWorkload.js +164 -0
- package/dist/v4/runtime/lifecycle.d.ts +5 -0
- package/dist/v4/runtime/lifecycle.js +17 -0
- package/dist/v4/runtime/liveAuthorization.d.ts +42 -0
- package/dist/v4/runtime/liveAuthorization.js +133 -0
- package/dist/v4/runtime/liveAuthorizationWire.d.ts +8 -0
- package/dist/v4/runtime/liveAuthorizationWire.js +31 -0
- package/dist/v4/runtime/liveCarrierPreparation.d.ts +9 -0
- package/dist/v4/runtime/liveCarrierPreparation.js +27 -0
- package/dist/v4/runtime/liveness.d.ts +37 -0
- package/dist/v4/runtime/liveness.js +319 -0
- package/dist/v4/runtime/maintenancePositions.d.ts +29 -0
- package/dist/v4/runtime/maintenancePositions.js +152 -0
- package/dist/v4/runtime/messageCodec.d.ts +20 -0
- package/dist/v4/runtime/messageCodec.js +192 -0
- package/dist/v4/runtime/namespaceContinuity.d.ts +20 -0
- package/dist/v4/runtime/namespaceContinuity.js +176 -0
- package/dist/v4/runtime/nativeCandidates.d.ts +18 -0
- package/dist/v4/runtime/nativeCandidates.js +109 -0
- package/dist/v4/runtime/nativeFailure.d.ts +10 -0
- package/dist/v4/runtime/nativeFailure.js +32 -0
- package/dist/v4/runtime/nativeFrame.d.ts +47 -0
- package/dist/v4/runtime/nativeFrame.js +318 -0
- package/dist/v4/runtime/nativeIngress.d.ts +30 -0
- package/dist/v4/runtime/nativeIngress.js +177 -0
- package/dist/v4/runtime/nativePositions.d.ts +24 -0
- package/dist/v4/runtime/nativePositions.js +131 -0
- package/dist/v4/runtime/nativeProviderPositions.d.ts +16 -0
- package/dist/v4/runtime/nativeProviderPositions.js +75 -0
- package/dist/v4/runtime/nativeSend.d.ts +15 -0
- package/dist/v4/runtime/nativeSend.js +57 -0
- package/dist/v4/runtime/noiseHandshake.d.ts +70 -0
- package/dist/v4/runtime/noiseHandshake.js +373 -0
- package/dist/v4/runtime/noiseWasmBinary.d.ts +2 -0
- package/dist/v4/runtime/noiseWasmBinary.js +3 -0
- package/dist/v4/runtime/notifyChannel.d.ts +37 -0
- package/dist/v4/runtime/notifyChannel.js +277 -0
- package/dist/v4/runtime/notifyDispatch.d.ts +108 -0
- package/dist/v4/runtime/notifyDispatch.js +717 -0
- package/dist/v4/runtime/notifyExecution.d.ts +18 -0
- package/dist/v4/runtime/notifyExecution.js +59 -0
- package/dist/v4/runtime/notifyPreparation.d.ts +70 -0
- package/dist/v4/runtime/notifyPreparation.js +465 -0
- package/dist/v4/runtime/openAdmission.d.ts +125 -0
- package/dist/v4/runtime/openAdmission.js +810 -0
- package/dist/v4/runtime/peerOpenPreparation.d.ts +18 -0
- package/dist/v4/runtime/peerOpenPreparation.js +61 -0
- package/dist/v4/runtime/poolJournal.d.ts +18 -0
- package/dist/v4/runtime/poolJournal.js +14 -0
- package/dist/v4/runtime/poolJournalStorage.d.ts +4 -0
- package/dist/v4/runtime/poolJournalStorage.js +172 -0
- package/dist/v4/runtime/poolRecord.d.ts +9 -0
- package/dist/v4/runtime/poolRecord.js +23 -0
- package/dist/v4/runtime/poolRecordStorage.d.ts +10 -0
- package/dist/v4/runtime/poolRecordStorage.js +216 -0
- package/dist/v4/runtime/poolServerAllow.d.ts +49 -0
- package/dist/v4/runtime/poolServerAllow.js +38 -0
- package/dist/v4/runtime/poolSpend.d.ts +20 -0
- package/dist/v4/runtime/poolSpend.js +4 -0
- package/dist/v4/runtime/queryRenewalPosition.d.ts +59 -0
- package/dist/v4/runtime/queryRenewalPosition.js +220 -0
- package/dist/v4/runtime/random.d.ts +15 -0
- package/dist/v4/runtime/random.js +71 -0
- package/dist/v4/runtime/rawStreamPreparation.d.ts +40 -0
- package/dist/v4/runtime/rawStreamPreparation.js +125 -0
- package/dist/v4/runtime/receiveDirection.d.ts +135 -0
- package/dist/v4/runtime/receiveDirection.js +957 -0
- package/dist/v4/runtime/receiveWorkspace.d.ts +19 -0
- package/dist/v4/runtime/receiveWorkspace.js +82 -0
- package/dist/v4/runtime/record.d.ts +7 -0
- package/dist/v4/runtime/record.js +173 -0
- package/dist/v4/runtime/recordCrypto.d.ts +121 -0
- package/dist/v4/runtime/recordCrypto.js +633 -0
- package/dist/v4/runtime/recordWorkspace.d.ts +17 -0
- package/dist/v4/runtime/recordWorkspace.js +69 -0
- package/dist/v4/runtime/registeredCarrierPreparation.d.ts +17 -0
- package/dist/v4/runtime/registeredCarrierPreparation.js +191 -0
- package/dist/v4/runtime/rekey.d.ts +40 -0
- package/dist/v4/runtime/rekey.js +362 -0
- package/dist/v4/runtime/relayCredentials.d.ts +126 -0
- package/dist/v4/runtime/relayCredentials.js +349 -0
- package/dist/v4/runtime/replayWindow.d.ts +6 -0
- package/dist/v4/runtime/replayWindow.js +59 -0
- package/dist/v4/runtime/resources.d.ts +200 -0
- package/dist/v4/runtime/resources.js +1236 -0
- package/dist/v4/runtime/resumeCodec.d.ts +44 -0
- package/dist/v4/runtime/resumeCodec.js +192 -0
- package/dist/v4/runtime/resumeStream.d.ts +23 -0
- package/dist/v4/runtime/resumeStream.js +23 -0
- package/dist/v4/runtime/rpcApplication.d.ts +234 -0
- package/dist/v4/runtime/rpcApplication.js +2170 -0
- package/dist/v4/runtime/rpcApplicationServices.d.ts +18 -0
- package/dist/v4/runtime/rpcApplicationServices.js +62 -0
- package/dist/v4/runtime/rpcCallCapacity.d.ts +62 -0
- package/dist/v4/runtime/rpcCallCapacity.js +289 -0
- package/dist/v4/runtime/rpcChannel.d.ts +58 -0
- package/dist/v4/runtime/rpcChannel.js +334 -0
- package/dist/v4/runtime/rpcCompletion.d.ts +42 -0
- package/dist/v4/runtime/rpcCompletion.js +152 -0
- package/dist/v4/runtime/rpcEventSource.d.ts +27 -0
- package/dist/v4/runtime/rpcEventSource.js +201 -0
- package/dist/v4/runtime/rpcFragment.d.ts +42 -0
- package/dist/v4/runtime/rpcFragment.js +227 -0
- package/dist/v4/runtime/rpcInput.d.ts +41 -0
- package/dist/v4/runtime/rpcInput.js +137 -0
- package/dist/v4/runtime/rpcNetwork.d.ts +143 -0
- package/dist/v4/runtime/rpcNetwork.js +652 -0
- package/dist/v4/runtime/rpcOutputInterest.d.ts +20 -0
- package/dist/v4/runtime/rpcOutputInterest.js +106 -0
- package/dist/v4/runtime/rpcPayload.d.ts +24 -0
- package/dist/v4/runtime/rpcPayload.js +82 -0
- package/dist/v4/runtime/rpcPreacceptedStreams.d.ts +46 -0
- package/dist/v4/runtime/rpcPreacceptedStreams.js +406 -0
- package/dist/v4/runtime/rpcPublisher.d.ts +49 -0
- package/dist/v4/runtime/rpcPublisher.js +406 -0
- package/dist/v4/runtime/rpcReceiver.d.ts +40 -0
- package/dist/v4/runtime/rpcReceiver.js +255 -0
- package/dist/v4/runtime/rpcResumeDispatch.d.ts +46 -0
- package/dist/v4/runtime/rpcResumeDispatch.js +266 -0
- package/dist/v4/runtime/rpcStream.d.ts +14 -0
- package/dist/v4/runtime/rpcStream.js +12 -0
- package/dist/v4/runtime/rpcStreamMessages.d.ts +53 -0
- package/dist/v4/runtime/rpcStreamMessages.js +428 -0
- package/dist/v4/runtime/rpcStreamPreparation.d.ts +21 -0
- package/dist/v4/runtime/rpcStreamPreparation.js +110 -0
- package/dist/v4/runtime/rpcStreamingDispatch.d.ts +26 -0
- package/dist/v4/runtime/rpcStreamingDispatch.js +607 -0
- package/dist/v4/runtime/rpcStreamingExchange.d.ts +91 -0
- package/dist/v4/runtime/rpcStreamingExchange.js +812 -0
- package/dist/v4/runtime/rpcUnaryCall.d.ts +16 -0
- package/dist/v4/runtime/rpcUnaryCall.js +152 -0
- package/dist/v4/runtime/rpcUnaryDispatch.d.ts +34 -0
- package/dist/v4/runtime/rpcUnaryDispatch.js +569 -0
- package/dist/v4/runtime/rpcUnaryExchange.d.ts +127 -0
- package/dist/v4/runtime/rpcUnaryExchange.js +1042 -0
- package/dist/v4/runtime/rpcUnaryPreparation.d.ts +102 -0
- package/dist/v4/runtime/rpcUnaryPreparation.js +736 -0
- package/dist/v4/runtime/rpcUnaryRegistration.d.ts +33 -0
- package/dist/v4/runtime/rpcUnaryRegistration.js +113 -0
- package/dist/v4/runtime/rpcUnaryResultRecipient.d.ts +21 -0
- package/dist/v4/runtime/rpcUnaryResultRecipient.js +57 -0
- package/dist/v4/runtime/schema.d.ts +26 -0
- package/dist/v4/runtime/schema.js +668 -0
- package/dist/v4/runtime/schemaRegistry.d.ts +128 -0
- package/dist/v4/runtime/schemaRegistry.js +74 -0
- package/dist/v4/runtime/sendBudget.d.ts +10 -0
- package/dist/v4/runtime/sendBudget.js +46 -0
- package/dist/v4/runtime/serveGroup.d.ts +73 -0
- package/dist/v4/runtime/serveGroup.js +589 -0
- package/dist/v4/runtime/serverAdmission.d.ts +33 -0
- package/dist/v4/runtime/serverAdmission.js +342 -0
- package/dist/v4/runtime/serverAdmissionAuthority.d.ts +23 -0
- package/dist/v4/runtime/serverAdmissionAuthority.js +5 -0
- package/dist/v4/runtime/serverSessionSpec.d.ts +9 -0
- package/dist/v4/runtime/serverSessionSpec.js +12 -0
- package/dist/v4/runtime/serviceBinding.d.ts +128 -0
- package/dist/v4/runtime/serviceBinding.js +1435 -0
- package/dist/v4/runtime/serviceBindingConfig.d.ts +72 -0
- package/dist/v4/runtime/serviceBindingConfig.js +85 -0
- package/dist/v4/runtime/serviceBindingPool.d.ts +58 -0
- package/dist/v4/runtime/serviceBindingPool.js +327 -0
- package/dist/v4/runtime/serviceContract.d.ts +111 -0
- package/dist/v4/runtime/serviceContract.js +588 -0
- package/dist/v4/runtime/serviceInputs.d.ts +30 -0
- package/dist/v4/runtime/serviceInputs.js +201 -0
- package/dist/v4/runtime/serviceOfferPlan.d.ts +81 -0
- package/dist/v4/runtime/serviceOfferPlan.js +335 -0
- package/dist/v4/runtime/serviceOfferScheduler.d.ts +12 -0
- package/dist/v4/runtime/serviceOfferScheduler.js +201 -0
- package/dist/v4/runtime/serviceOfferWork.d.ts +25 -0
- package/dist/v4/runtime/serviceOfferWork.js +1 -0
- package/dist/v4/runtime/session.d.ts +411 -0
- package/dist/v4/runtime/session.js +6369 -0
- package/dist/v4/runtime/sessionActivity.d.ts +19 -0
- package/dist/v4/runtime/sessionActivity.js +97 -0
- package/dist/v4/runtime/sessionAdmission.d.ts +93 -0
- package/dist/v4/runtime/sessionAdmission.js +498 -0
- package/dist/v4/runtime/sessionCleanup.d.ts +47 -0
- package/dist/v4/runtime/sessionCleanup.js +268 -0
- package/dist/v4/runtime/sessionKeyPreparation.d.ts +19 -0
- package/dist/v4/runtime/sessionKeyPreparation.js +50 -0
- package/dist/v4/runtime/signedMap.d.ts +68 -0
- package/dist/v4/runtime/signedMap.js +425 -0
- package/dist/v4/runtime/streamAdapter.d.ts +113 -0
- package/dist/v4/runtime/streamAdapter.js +62 -0
- package/dist/v4/runtime/streamData.d.ts +11 -0
- package/dist/v4/runtime/streamData.js +50 -0
- package/dist/v4/runtime/streamOpenPreparation.d.ts +23 -0
- package/dist/v4/runtime/streamOpenPreparation.js +77 -0
- package/dist/v4/runtime/streamRegistration.d.ts +87 -0
- package/dist/v4/runtime/streamRegistration.js +296 -0
- package/dist/v4/runtime/taskObservation.d.ts +1 -0
- package/dist/v4/runtime/taskObservation.js +48 -0
- package/dist/v4/runtime/timeArithmetic.d.ts +29 -0
- package/dist/v4/runtime/timeArithmetic.js +107 -0
- package/dist/v4/runtime/unreliable.d.ts +76 -0
- package/dist/v4/runtime/unreliable.js +473 -0
- package/dist/v4/runtime/volatileExecutions.d.ts +128 -0
- package/dist/v4/runtime/volatileExecutions.js +792 -0
- package/dist/v4/runtime/wireRegistry.d.ts +52 -0
- package/dist/v4/runtime/wireRegistry.js +29 -0
- package/dist/v4/runtime/writeRequest.d.ts +42 -0
- package/dist/v4/runtime/writeRequest.js +237 -0
- package/dist/v4/serve.d.ts +107 -0
- package/dist/v4/serve.js +80 -0
- package/dist/v4/serviceClient.d.ts +92 -0
- package/dist/v4/serviceClient.js +323 -0
- package/dist/v4/serviceDefinition.d.ts +138 -0
- package/dist/v4/serviceDefinition.js +150 -0
- package/dist/v4/serviceDependencies.d.ts +66 -0
- package/dist/v4/serviceDependencies.js +250 -0
- package/dist/v4/serviceFactory.d.ts +31 -0
- package/dist/v4/serviceFactory.js +157 -0
- package/dist/v4/serviceHandlers.d.ts +55 -0
- package/dist/v4/serviceHandlers.js +15 -0
- package/dist/v4/serviceMembers.d.ts +4 -0
- package/dist/v4/serviceMembers.js +12 -0
- package/dist/v4/staticServiceContracts.d.ts +43 -0
- package/dist/v4/staticServiceContracts.js +161 -0
- package/dist/v4/storageFormat.d.ts +16 -0
- package/dist/v4/storageFormat.js +5 -0
- package/dist/v4/streamContent.d.ts +30 -0
- package/dist/v4/streamContent.js +29 -0
- package/dist/v4/streamHandlers.d.ts +61 -0
- package/dist/v4/streamHandlers.js +16 -0
- package/dist/v4/streamingOperation.d.ts +64 -0
- package/dist/v4/streamingOperation.js +141 -0
- package/dist/v4/testSupport/cbor.d.ts +124 -0
- package/dist/v4/testSupport/cbor.js +230 -0
- package/dist/v4/testSupport/credentials.d.ts +55 -0
- package/dist/v4/testSupport/credentials.js +111 -0
- package/dist/v4/testSupport/unicode.d.ts +19 -0
- package/dist/v4/testSupport/unicode.js +112 -0
- package/dist/v4/unaryOperation.d.ts +59 -0
- package/dist/v4/unaryOperation.js +80 -0
- package/dist/v4/unreliable.d.ts +26 -0
- package/dist/v4/unreliable.js +10 -0
- package/dist/v4/webStreams.d.ts +30 -0
- package/dist/v4/webStreams.js +377 -0
- package/package.json +19 -16
- package/sbom/cyclonedx.json +761 -43
- package/sbom/spdx.json +566 -49
- package/dist/browser/connectSessionV3.d.ts +0 -31
- package/dist/browser/connectSessionV3.js +0 -241
- package/dist/browser/directWebSocketProfileV1.d.ts +0 -14
- package/dist/browser/directWebSocketProfileV1.js +0 -71
- package/dist/browser/httpDirectV1.d.ts +0 -30
- package/dist/browser/httpDirectV1.js +0 -52
- package/dist/browser/privateLoopbackV1.d.ts +0 -30
- package/dist/browser/privateLoopbackV1.js +0 -70
- package/dist/framing/index.d.ts +0 -1
- package/dist/framing/index.js +0 -1
- package/dist/framing/jsonframe.d.ts +0 -14
- package/dist/framing/jsonframe.js +0 -42
- package/dist/node/acceptor.d.ts +0 -36
- package/dist/node/acceptor.js +0 -155
- package/dist/node/acceptorV3.d.ts +0 -57
- package/dist/node/acceptorV3.js +0 -227
- package/dist/node/byteStreamDuplex.d.ts +0 -4
- package/dist/node/byteStreamDuplex.js +0 -69
- package/dist/node/connectSessionV3.d.ts +0 -24
- package/dist/node/connectSessionV3.js +0 -79
- package/dist/node/nativeTransportAddon.d.ts +0 -104
- package/dist/node/nativeTransportAddon.js +0 -212
- package/dist/node/rawQuicAdapterV3.d.ts +0 -10
- package/dist/node/rawQuicAdapterV3.js +0 -76
- package/dist/node/rawQuicServerV3.d.ts +0 -24
- package/dist/node/rawQuicServerV3.js +0 -34
- package/dist/node/runtimeAuthorizationV3.d.ts +0 -29
- package/dist/node/runtimeAuthorizationV3.js +0 -126
- package/dist/node/tunnelRuntimeV3.d.ts +0 -57
- package/dist/node/tunnelRuntimeV3.js +0 -857
- package/dist/node/webSocketServerV3.d.ts +0 -27
- package/dist/node/webSocketServerV3.js +0 -219
- package/dist/node/wsFactory.d.ts +0 -8
- package/dist/node/wsFactory.js +0 -84
- package/dist/public/streamHandlers.d.ts +0 -20
- package/dist/public/streamHandlers.js +0 -127
- package/dist/rpc/callError.d.ts +0 -5
- package/dist/rpc/callError.js +0 -11
- package/dist/rpc/caller.d.ts +0 -8
- package/dist/rpc/client.d.ts +0 -23
- package/dist/rpc/client.js +0 -171
- package/dist/rpc/index.d.ts +0 -6
- package/dist/rpc/index.js +0 -6
- package/dist/rpc/rpcProxy.d.ts +0 -16
- package/dist/rpc/rpcProxy.js +0 -58
- package/dist/rpc/server.d.ts +0 -51
- package/dist/rpc/server.js +0 -283
- package/dist/rpc/typed.d.ts +0 -5
- package/dist/rpc/typed.js +0 -9
- package/dist/rpc/validate.d.ts +0 -4
- package/dist/rpc/wire.d.ts +0 -15
- package/dist/v3/admissionError.d.ts +0 -4
- package/dist/v3/admissionError.js +0 -8
- package/dist/v3/artifact.d.ts +0 -145
- package/dist/v3/artifact.js +0 -1176
- package/dist/v3/artifactLease.d.ts +0 -17
- package/dist/v3/artifactLease.js +0 -109
- package/dist/v3/browserRuntime.d.ts +0 -37
- package/dist/v3/browserRuntime.js +0 -197
- package/dist/v3/browserSessionRuntime.d.ts +0 -2
- package/dist/v3/browserSessionRuntime.js +0 -21
- package/dist/v3/capability.d.ts +0 -32
- package/dist/v3/capability.js +0 -345
- package/dist/v3/carrier.d.ts +0 -84
- package/dist/v3/carrier.js +0 -411
- package/dist/v3/connectionController.d.ts +0 -100
- package/dist/v3/connectionController.js +0 -861
- package/dist/v3/contract.d.ts +0 -65
- package/dist/v3/contract.js +0 -3
- package/dist/v3/controller.d.ts +0 -45
- package/dist/v3/controller.js +0 -316
- package/dist/v3/handshake.d.ts +0 -81
- package/dist/v3/handshake.js +0 -471
- package/dist/v3/jcs.d.ts +0 -6
- package/dist/v3/jcs.js +0 -69
- package/dist/v3/jsonPreflight.d.ts +0 -1
- package/dist/v3/jsonPreflight.js +0 -251
- package/dist/v3/nodeRuntime.d.ts +0 -43
- package/dist/v3/nodeRuntime.js +0 -373
- package/dist/v3/nodeSessionRuntime.d.ts +0 -2
- package/dist/v3/nodeSessionRuntime.js +0 -13
- package/dist/v3/protocol.d.ts +0 -99
- package/dist/v3/protocol.js +0 -674
- package/dist/v3/publicApi.d.ts +0 -12
- package/dist/v3/publicApi.js +0 -46
- package/dist/v3/publicSession.js +0 -281
- package/dist/v3/retryDisposition.d.ts +0 -16
- package/dist/v3/retryDisposition.js +0 -23
- package/dist/v3/runtimeAdapters.d.ts +0 -9
- package/dist/v3/runtimeAdapters.js +0 -109
- package/dist/v3/security.d.ts +0 -36
- package/dist/v3/security.js +0 -113
- package/dist/v3/serverAdmission.d.ts +0 -38
- package/dist/v3/serverAdmission.js +0 -223
- package/dist/v3/session.d.ts +0 -322
- package/dist/v3/session.js +0 -2302
- package/dist/v3/sessionConnector.d.ts +0 -42
- package/dist/v3/sessionConnector.js +0 -513
- package/dist/v3/streamLifetimeLedger.d.ts +0 -31
- package/dist/v3/streamLifetimeLedger.js +0 -131
- package/dist/v3/streamMetadata.js +0 -7
- package/dist/v3/transportConstants.d.ts +0 -56
- package/dist/v3/transportConstants.js +0 -59
- package/dist/v3/unreliableMessage.d.ts +0 -44
- package/dist/v3/unreliableMessage.js +0 -287
- package/dist/v3/webSocketCarrier.d.ts +0 -31
- package/dist/v3/webSocketCarrier.js +0 -370
- package/dist/v3/webTransportCarrier.d.ts +0 -27
- package/dist/v3/webTransportCarrier.js +0 -552
- package/dist/ws-client/binaryTransport.d.ts +0 -64
- package/dist/ws-client/binaryTransport.js +0 -393
- package/dist/yamux/byteReader.d.ts +0 -13
- package/dist/yamux/byteReader.js +0 -81
- package/dist/yamux/constants.d.ts +0 -10
- package/dist/yamux/constants.js +0 -14
- package/dist/yamux/errors.d.ts +0 -15
- package/dist/yamux/errors.js +0 -34
- package/dist/yamux/header.d.ts +0 -17
- package/dist/yamux/header.js +0 -26
- package/dist/yamux/index.d.ts +0 -6
- package/dist/yamux/index.js +0 -6
- package/dist/yamux/session.d.ts +0 -81
- package/dist/yamux/session.js +0 -401
- package/dist/yamux/stream.d.ts +0 -42
- package/dist/yamux/stream.js +0 -296
- /package/dist/{rpc/caller.js → node/sqlitePoolWorkerProgramV4.d.ts} +0 -0
- /package/dist/{rpc/wire.js → node/sqliteWorkerProgramV4.d.ts} +0 -0
- /package/dist/{v3/publicSession.d.ts → v4/admissionOffer.js} +0 -0
- /package/dist/{v3/streamMetadata.d.ts → v4/runtime/controllerUnaryRoute.js} +0 -0
|
@@ -0,0 +1,792 @@
|
|
|
1
|
+
import { captureCheckpoint } from "./checkpointToken.js";
|
|
2
|
+
import { executionStorage, executionMode } from "./executionStorage.js";
|
|
3
|
+
import { captureExecutionTarget } from "./executionManagementCodec.js";
|
|
4
|
+
import { sha256 } from "@noble/hashes/sha2.js";
|
|
5
|
+
import { credentialOwner } from "./credentialSupport.js";
|
|
6
|
+
import { RPCPayload, rpcPayloadCharge } from "./rpcPayload.js";
|
|
7
|
+
import { RPCProtocolError } from "./rpcFragment.js";
|
|
8
|
+
import { ResourceVector } from "./resources.js";
|
|
9
|
+
import { timeAdd } from "./timeArithmetic.js";
|
|
10
|
+
function securityText(value) { return typeof value === "string" && /^[a-z0-9][a-z0-9._:/@-]{0,127}$/u.test(value); }
|
|
11
|
+
function digestText(value) { return typeof value === "string" && /^[0-9a-f]{64}$/u.test(value) && !/^0+$/u.test(value); }
|
|
12
|
+
export function executionResultReadCharge(runtimeBytes) {
|
|
13
|
+
return new ResourceVector([2048n + runtimeBytes, 0n, 0n, 4n, 0n, 0n, 0n, 0n, 0n, 0n, 0n]);
|
|
14
|
+
}
|
|
15
|
+
export function captureExecutionIdentity(input) {
|
|
16
|
+
if (input === undefined)
|
|
17
|
+
return;
|
|
18
|
+
const { authority, subject, identityDigest } = input;
|
|
19
|
+
if (!digestText(authority) || !securityText(subject) || !digestText(identityDigest))
|
|
20
|
+
throw new RPCProtocolError("configuration_capacity");
|
|
21
|
+
return Object.freeze({ authority, subject, identityDigest });
|
|
22
|
+
}
|
|
23
|
+
export function captureVolatileExecution(input) {
|
|
24
|
+
if (executionStorage(input) !== undefined)
|
|
25
|
+
return input;
|
|
26
|
+
const { tenant, audience, namespace, callerAuthorities, maxRecords, maxActive, resultBytes } = input;
|
|
27
|
+
if (![tenant, audience, namespace].every(securityText) || !Array.isArray(callerAuthorities) || callerAuthorities.length < 1 || callerAuthorities.length > 16 ||
|
|
28
|
+
callerAuthorities.some(value => !digestText(value)) || new Set(callerAuthorities).size !== callerAuthorities.length ||
|
|
29
|
+
!Number.isSafeInteger(maxRecords) || maxRecords < 1 || maxRecords > 8192 || !Number.isSafeInteger(maxActive) || maxActive < 1 || maxActive > Math.min(1024, maxRecords) ||
|
|
30
|
+
typeof resultBytes !== "bigint" || resultBytes < 1n || resultBytes > 16777216n)
|
|
31
|
+
throw new RPCProtocolError("configuration_capacity");
|
|
32
|
+
return Object.freeze({ tenant, audience, namespace, callerAuthorities: Object.freeze([...callerAuthorities].sort()), maxRecords, maxActive, resultBytes });
|
|
33
|
+
}
|
|
34
|
+
export function executionServiceKey(config) {
|
|
35
|
+
return `${config.tenant}\0${config.audience}\0${config.namespace}`;
|
|
36
|
+
}
|
|
37
|
+
export function volatileExecutionCharge(config, runtimeBytes) {
|
|
38
|
+
// All compact records, keys, floors, finite observer indices and GC cursor
|
|
39
|
+
// precede the first Session. Full result payloads are admitted per operation.
|
|
40
|
+
const bytes = 8192n + BigInt(config.maxRecords) * 1536n + BigInt(config.callerAuthorities.length) * 256n + BigInt(config.maxActive * 3 + 8) * 512n + runtimeBytes;
|
|
41
|
+
if (runtimeBytes <= 0n || bytes > 5242880n)
|
|
42
|
+
throw new RPCProtocolError("configuration_capacity");
|
|
43
|
+
return new ResourceVector([bytes, 0n, 0n, BigInt(config.maxRecords * 3 + 8), BigInt(config.maxActive * 3 + 8), BigInt(config.maxActive * 3 + 9), 1n, 0n, 0n, 0n, 0n]);
|
|
44
|
+
}
|
|
45
|
+
const capability = Symbol("original volatile execution attempt"), NativePromise = Promise;
|
|
46
|
+
const signalAborted = Object.getOwnPropertyDescriptor(AbortSignal.prototype, "aborted").get;
|
|
47
|
+
const addListener = EventTarget.prototype.addEventListener, removeListener = EventTarget.prototype.removeEventListener;
|
|
48
|
+
const aborted = (signal) => signalAborted.call(signal);
|
|
49
|
+
const hex = (bytes) => Array.from(bytes, value => value.toString(16).padStart(2, "0")).join("");
|
|
50
|
+
/** One continuous logical service history shared by every original Session.
|
|
51
|
+
* Absence is not cross-owner proof. No Session, certificate, method or contract
|
|
52
|
+
* digest is added to the key, and no pressure/LRU deletion grants a new Start. */
|
|
53
|
+
export class VolatileExecutions {
|
|
54
|
+
config;
|
|
55
|
+
configuration;
|
|
56
|
+
#resources;
|
|
57
|
+
#clock;
|
|
58
|
+
#storage;
|
|
59
|
+
#storageBound = false;
|
|
60
|
+
#pendingStorage = 0;
|
|
61
|
+
#pendingRecordWork = 0;
|
|
62
|
+
async #storageWork(action) {
|
|
63
|
+
if (this.#pendingStorage >= this.config.maxActive * 3 + 8)
|
|
64
|
+
throw new RPCProtocolError("resource_exhausted");
|
|
65
|
+
this.#pendingStorage++;
|
|
66
|
+
try {
|
|
67
|
+
return await action();
|
|
68
|
+
}
|
|
69
|
+
finally {
|
|
70
|
+
this.#pendingStorage--;
|
|
71
|
+
this.#collectClosed();
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
async #recordWork(record, action) {
|
|
75
|
+
if (record.transitions >= 64 || this.#pendingRecordWork >= this.config.maxActive * 3 + 8 || this.#pendingStorage >= this.config.maxActive * 3 + 8)
|
|
76
|
+
throw new RPCProtocolError("resource_exhausted");
|
|
77
|
+
const previous = record.transitionTail;
|
|
78
|
+
let release;
|
|
79
|
+
record.transitionTail = new Promise(resolve => { release = resolve; });
|
|
80
|
+
record.transitions++;
|
|
81
|
+
this.#pendingRecordWork++;
|
|
82
|
+
try {
|
|
83
|
+
return await this.#storageWork(async () => { await previous; return await action(); });
|
|
84
|
+
}
|
|
85
|
+
finally {
|
|
86
|
+
record.transitions--;
|
|
87
|
+
this.#pendingRecordWork--;
|
|
88
|
+
// Custody extends through applying the real receipt, including payloads.
|
|
89
|
+
// Failure and exit persist the final facts after all admitted transitions.
|
|
90
|
+
if (record.transitions === 0) {
|
|
91
|
+
const failure = record.deferredFailure;
|
|
92
|
+
record.deferredFailure = undefined;
|
|
93
|
+
if (failure !== undefined)
|
|
94
|
+
this.fail(record, failure);
|
|
95
|
+
if (record.exitRequested)
|
|
96
|
+
this.exit(record);
|
|
97
|
+
}
|
|
98
|
+
release();
|
|
99
|
+
this.#collectClosed();
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async #updateReceipt(facts, payload, guard, apply) {
|
|
103
|
+
if (this.#storage === undefined) {
|
|
104
|
+
guard?.();
|
|
105
|
+
apply();
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
let delivered = false;
|
|
109
|
+
await this.#storage.update(facts, payload, guard, () => {
|
|
110
|
+
if (delivered)
|
|
111
|
+
throw new RPCProtocolError("service_failed");
|
|
112
|
+
delivered = true;
|
|
113
|
+
apply();
|
|
114
|
+
});
|
|
115
|
+
if (!delivered)
|
|
116
|
+
throw new RPCProtocolError("service_failed");
|
|
117
|
+
}
|
|
118
|
+
#applyResultReceipt(record, receipt) {
|
|
119
|
+
// The admitted transition retains the original result allocation through
|
|
120
|
+
// COMMIT. Custody settlement does not recheck a now-closed publication gate.
|
|
121
|
+
record.result.write(0, receipt.payload);
|
|
122
|
+
record.result.seal();
|
|
123
|
+
record.resultDigest = receipt.facts.resultDigest;
|
|
124
|
+
record.resultBytes = receipt.facts.resultBytes;
|
|
125
|
+
record.resultCode = receipt.facts.resultCode;
|
|
126
|
+
record.resultUntil = receipt.facts.resultUntil;
|
|
127
|
+
record.state = receipt.facts.state;
|
|
128
|
+
this.#notify(record);
|
|
129
|
+
}
|
|
130
|
+
#reference;
|
|
131
|
+
#resultAccount;
|
|
132
|
+
#records = new Map();
|
|
133
|
+
#slots;
|
|
134
|
+
#floors = new Map();
|
|
135
|
+
#active = 0;
|
|
136
|
+
#next = 0n;
|
|
137
|
+
#cursor = 0;
|
|
138
|
+
#closed = false;
|
|
139
|
+
#busy = false;
|
|
140
|
+
#timer;
|
|
141
|
+
constructor(resources, clock, config) {
|
|
142
|
+
this.#storage = executionStorage(config);
|
|
143
|
+
this.config = captureVolatileExecution(config);
|
|
144
|
+
this.configuration = JSON.stringify(this.config, (_key, value) => typeof value === "bigint" ? value.toString() : value);
|
|
145
|
+
this.#resources = Object.freeze({ ...resources, accounts: Object.freeze([...resources.accounts]), owner: Object.freeze({ ...resources.owner }) });
|
|
146
|
+
this.#clock = clock;
|
|
147
|
+
const charge = volatileExecutionCharge(this.config, resources.runtimeBytes);
|
|
148
|
+
const id = hex(sha256(new TextEncoder().encode(JSON.stringify([resources.owner.tenant, resources.owner.environment, "execution_results", executionServiceKey(this.config)])))).slice(0, 32);
|
|
149
|
+
this.#reference = resources.root.reserve({ accounts: resources.accounts, owner: { ...resources.owner, kind: `execution_history_${id}` }, charge });
|
|
150
|
+
this.#slots = new Array(this.config.maxRecords);
|
|
151
|
+
try {
|
|
152
|
+
const values = [...resources.root.snapshot().limit.values()];
|
|
153
|
+
values[0] = config.resultBytes;
|
|
154
|
+
this.#resultAccount = resources.root.account("pool", id, new ResourceVector(values));
|
|
155
|
+
for (const authority of this.config.callerAuthorities)
|
|
156
|
+
this.#floors.set(authority, 0n);
|
|
157
|
+
if (this.#storage !== undefined) {
|
|
158
|
+
this.#storage.bind(this.#reference);
|
|
159
|
+
this.#storageBound = true;
|
|
160
|
+
for (const [authority, floor] of this.#storage.floors())
|
|
161
|
+
this.#floors.set(authority, floor);
|
|
162
|
+
for (const saved of this.#storage.records()) {
|
|
163
|
+
const facts = saved.facts;
|
|
164
|
+
if (this.#records.size >= this.config.maxRecords || facts.active || this.#records.has(facts.key))
|
|
165
|
+
throw new RPCProtocolError("service_unavailable");
|
|
166
|
+
let result;
|
|
167
|
+
if (saved.payload !== undefined) {
|
|
168
|
+
const reference = resources.root.reserve({
|
|
169
|
+
accounts: [...resources.accounts, this.#resultAccount],
|
|
170
|
+
owner: credentialOwner(resources, `execution_result_${++this.#next}`), charge: rpcPayloadCharge(facts.limit, resources.runtimeBytes)
|
|
171
|
+
});
|
|
172
|
+
try {
|
|
173
|
+
result = new RPCPayload(facts.limit, resources.runtimeBytes, reference);
|
|
174
|
+
result.write(0, saved.payload);
|
|
175
|
+
result.seal();
|
|
176
|
+
}
|
|
177
|
+
finally {
|
|
178
|
+
reference.release();
|
|
179
|
+
saved.payload.fill(0);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
const record = { ...facts, result, holders: 0, transitions: 0, transitionTail: Promise.resolve(), deferredFailure: undefined, exitRequested: false, stop: undefined, waiters: new Set() };
|
|
183
|
+
this.#slots[this.#records.size] = record;
|
|
184
|
+
this.#records.set(record.key, record);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
this.#timer = setTimeout(this.#tick, 1000);
|
|
188
|
+
Object.freeze(this);
|
|
189
|
+
}
|
|
190
|
+
catch (error) {
|
|
191
|
+
this.close();
|
|
192
|
+
throw error;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
sameEnvironment(reference) { this.#check(); return this.#reference.sameEnvironment(reference); }
|
|
196
|
+
#check() { if (this.#closed)
|
|
197
|
+
throw new RPCProtocolError("service_unavailable"); this.#reference.check(); this.#storage?.check(); }
|
|
198
|
+
async admit(input, route, routes, authentication, identity, access, stop) {
|
|
199
|
+
this.#check();
|
|
200
|
+
if (this.#busy)
|
|
201
|
+
throw new RPCProtocolError("service_unavailable");
|
|
202
|
+
this.#busy = true;
|
|
203
|
+
let result, committedRecord;
|
|
204
|
+
try {
|
|
205
|
+
const header = input.header, contract = route.contract, config = this.config;
|
|
206
|
+
const notification = header.kind === "execution_notify", streaming = header.kind === "execution_stream_request";
|
|
207
|
+
if (input.state !== "complete" || !notification && !streaming && header.kind !== "execution_unary_request" && header.kind !== "resume_request" || contract.optionalUint(13) !== executionMode(config) ||
|
|
208
|
+
contract.shape !== (notification ? "notify" : streaming ? "server_streaming" : "unary") || authentication.tenant !== config.tenant || authentication.audience !== config.audience ||
|
|
209
|
+
route.namespace !== config.namespace || identity.subject !== authentication.peerSubject || identity.identityDigest !== authentication.peerIdentityDigest ||
|
|
210
|
+
!this.#floors.has(identity.authority) || !input.sameEnvironment(this.#reference))
|
|
211
|
+
throw new RPCProtocolError("permission_denied");
|
|
212
|
+
const operation = new Uint8Array(32), request = new Uint8Array(32), digest = new Uint8Array(32);
|
|
213
|
+
header.copyBytes(1, operation);
|
|
214
|
+
header.copyBytes(4, request);
|
|
215
|
+
header.copyBytes(6, digest);
|
|
216
|
+
const key = `${identity.authority}\0${identity.subject}\0${hex(operation)}`, requestID = hex(request), contractID = hex(digest);
|
|
217
|
+
let cutoff = 0n;
|
|
218
|
+
for (let i = 0; i < 8; i++)
|
|
219
|
+
cutoff = (cutoff << 8n) | BigInt(operation[i]);
|
|
220
|
+
operation.fill(0);
|
|
221
|
+
request.fill(0);
|
|
222
|
+
digest.fill(0);
|
|
223
|
+
access.check();
|
|
224
|
+
this.#check();
|
|
225
|
+
const existing = this.#records.get(key);
|
|
226
|
+
if (existing !== undefined) {
|
|
227
|
+
if (existing.request !== requestID || existing.contract !== contractID)
|
|
228
|
+
throw new RPCProtocolError("operation_conflict");
|
|
229
|
+
if (existing.holders >= 64)
|
|
230
|
+
throw new RPCProtocolError("resource_exhausted");
|
|
231
|
+
existing.holders++;
|
|
232
|
+
return new VolatileExecutionAttempt(capability, this, existing, false);
|
|
233
|
+
}
|
|
234
|
+
const sample = this.#clock.sample(), now = sample.requireInterval();
|
|
235
|
+
access.check();
|
|
236
|
+
this.#check();
|
|
237
|
+
if (cutoff <= this.#floors.get(identity.authority) || now.upperMS >= cutoff || cutoff > timeAdd(now.lowerMS, contract.uint(16)) ||
|
|
238
|
+
now.upperMS >= header.uint(5) || header.uint(5) > timeAdd(now.lowerMS, contract.uint(17)))
|
|
239
|
+
throw new RPCProtocolError("deadline_exceeded");
|
|
240
|
+
routes.checkExecutionAdmission(route, cutoff, now);
|
|
241
|
+
if (this.#active >= config.maxActive || this.#records.size >= config.maxRecords || this.#next === (1n << 64n) - 1n)
|
|
242
|
+
throw new RPCProtocolError("resource_exhausted");
|
|
243
|
+
const historyUntil = timeAdd(header.uint(5), contract.uint(14)), retention = contract.optionalUint(15) ?? 0n, limit = Number(header.uint(8));
|
|
244
|
+
// Check the complete future retention arithmetic before registration.
|
|
245
|
+
timeAdd(header.uint(5), retention);
|
|
246
|
+
if (!notification && !streaming) {
|
|
247
|
+
const r = this.#resources, reference = r.root.reserve({
|
|
248
|
+
accounts: [...r.accounts, this.#resultAccount],
|
|
249
|
+
owner: credentialOwner(r, `execution_result_${++this.#next}`), charge: rpcPayloadCharge(limit, r.runtimeBytes)
|
|
250
|
+
});
|
|
251
|
+
try {
|
|
252
|
+
result = new RPCPayload(limit, r.runtimeBytes, reference);
|
|
253
|
+
}
|
|
254
|
+
finally {
|
|
255
|
+
reference.release();
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
access.check();
|
|
259
|
+
this.#check();
|
|
260
|
+
const finalTime = this.#clock.sample().requireInterval();
|
|
261
|
+
this.#check();
|
|
262
|
+
if (!access.current() || finalTime.upperMS >= cutoff || finalTime.upperMS >= header.uint(5) ||
|
|
263
|
+
cutoff > timeAdd(finalTime.lowerMS, contract.uint(16)) || header.uint(5) > timeAdd(finalTime.lowerMS, contract.uint(17)))
|
|
264
|
+
throw new RPCProtocolError("deadline_exceeded");
|
|
265
|
+
routes.checkExecutionAdmission(route, cutoff, finalTime);
|
|
266
|
+
const index = this.#slots.findIndex(value => value === undefined);
|
|
267
|
+
if (index < 0)
|
|
268
|
+
throw new RPCProtocolError("resource_exhausted");
|
|
269
|
+
const record = {
|
|
270
|
+
notification, streaming, metadataFinished: false, key, domain: identity.authority, request: requestID, contract: contractID, cutoff, historyUntil, retention, limit,
|
|
271
|
+
state: "accepted", active: true, dispatched: false, cancelMode: contract.optionalUint(19) === 1n, cancelRequested: false, resultDigest: "0".repeat(64), result, resultBytes: 0, resultCode: undefined, resultUntil: undefined, error: undefined,
|
|
272
|
+
holders: 1, transitions: 0, transitionTail: Promise.resolve(), deferredFailure: undefined, exitRequested: false, stop, waiters: new Set()
|
|
273
|
+
};
|
|
274
|
+
let registered = false;
|
|
275
|
+
const receipt = () => {
|
|
276
|
+
if (registered)
|
|
277
|
+
throw new RPCProtocolError("service_failed");
|
|
278
|
+
registered = true;
|
|
279
|
+
committedRecord = record;
|
|
280
|
+
this.#records.set(key, record);
|
|
281
|
+
this.#slots[index] = record;
|
|
282
|
+
this.#active++;
|
|
283
|
+
result = undefined;
|
|
284
|
+
};
|
|
285
|
+
await this.#storageWork(() => {
|
|
286
|
+
if (this.#storage === undefined) {
|
|
287
|
+
receipt();
|
|
288
|
+
return;
|
|
289
|
+
}
|
|
290
|
+
return this.#storage.register(record, contract, header.uint(5), () => { access.check(); this.#check(); routes.checkExecutionAdmission(route, cutoff, this.#clock.sample().requireInterval()); }, receipt);
|
|
291
|
+
});
|
|
292
|
+
if (!registered)
|
|
293
|
+
throw new RPCProtocolError("service_failed");
|
|
294
|
+
return new VolatileExecutionAttempt(capability, this, record, true);
|
|
295
|
+
}
|
|
296
|
+
catch (error) {
|
|
297
|
+
if (committedRecord !== undefined) {
|
|
298
|
+
// A receipt may have settled registration before a later SDK failure.
|
|
299
|
+
// No public attempt owns its one holder, but history cannot be erased.
|
|
300
|
+
this.fail(committedRecord, "service_unavailable");
|
|
301
|
+
this.exit(committedRecord);
|
|
302
|
+
this.release(committedRecord);
|
|
303
|
+
}
|
|
304
|
+
throw error;
|
|
305
|
+
}
|
|
306
|
+
finally {
|
|
307
|
+
result?.close();
|
|
308
|
+
this.#busy = false;
|
|
309
|
+
this.#collectClosed();
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
async enter(record, guard) {
|
|
313
|
+
return await this.#recordWork(record, async () => {
|
|
314
|
+
this.#check();
|
|
315
|
+
if (!record.active || record.dispatched || record.state !== "accepted")
|
|
316
|
+
throw new RPCProtocolError("service_unavailable");
|
|
317
|
+
await this.#updateReceipt({ ...record, dispatched: true, state: "executing" }, undefined, () => { this.#check(); guard?.(); }, () => {
|
|
318
|
+
record.dispatched = true;
|
|
319
|
+
record.state = "executing";
|
|
320
|
+
});
|
|
321
|
+
this.#check();
|
|
322
|
+
guard?.();
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
async finish(record, bytes, code, executionCap) {
|
|
326
|
+
return await this.#recordWork(record, async () => {
|
|
327
|
+
this.#check();
|
|
328
|
+
if (!record.active || !record.dispatched || record.resultUntil !== undefined || record.error !== undefined || bytes.length > record.limit)
|
|
329
|
+
throw new RPCProtocolError("service_failed");
|
|
330
|
+
const now = this.#clock.sample().requireInterval(), until = timeAdd(now.upperMS, record.retention);
|
|
331
|
+
this.#check();
|
|
332
|
+
if (record.error !== undefined || !record.active || record.resultUntil !== undefined || now.upperMS >= executionCap)
|
|
333
|
+
throw new RPCProtocolError("deadline_exceeded");
|
|
334
|
+
const resultDigest = hex(sha256(bytes)), state = code === undefined ? "completed" : "failed";
|
|
335
|
+
const completed = { ...record, resultDigest, resultBytes: bytes.length, resultCode: code, resultUntil: until, state };
|
|
336
|
+
await this.#updateReceipt(completed, bytes, () => { this.#check(); if (this.#clock.sample().requireInterval().upperMS >= executionCap)
|
|
337
|
+
throw new RPCProtocolError("deadline_exceeded"); }, () => {
|
|
338
|
+
this.#applyResultReceipt(record, { facts: completed, payload: bytes });
|
|
339
|
+
});
|
|
340
|
+
this.#check();
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
async saveContent(record, position, payload, executionCap, guard) {
|
|
344
|
+
return await this.#recordWork(record, async () => {
|
|
345
|
+
this.#check();
|
|
346
|
+
if (this.#storage === undefined || !record.streaming || !record.active || !record.dispatched || record.state !== "executing")
|
|
347
|
+
throw new RPCProtocolError("service_unavailable");
|
|
348
|
+
return (await this.#storage.saveContent(record, position, payload, executionCap, () => { this.#check(); guard(); }));
|
|
349
|
+
});
|
|
350
|
+
}
|
|
351
|
+
async readContent(record, target, position, destination, readerType, guard) {
|
|
352
|
+
return await this.#recordWork(record, async () => {
|
|
353
|
+
this.#check();
|
|
354
|
+
const captured = captureExecutionTarget(target), [authority, subject] = record.key.split("\0");
|
|
355
|
+
if (this.#storage === undefined || !record.active || !record.dispatched || record.state !== "executing" || record.streaming || record.notification ||
|
|
356
|
+
captured.authority !== authority || captured.subject !== subject || captured.tenant !== this.config.tenant || captured.audience !== this.config.audience || captured.namespace !== this.config.namespace)
|
|
357
|
+
throw new RPCProtocolError("permission_denied");
|
|
358
|
+
return (await this.#storage.readContent(record, captured, position, destination, readerType, () => { this.#check(); guard(); }));
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
async issueCheckpoint(record, original, checkpoint, options, policy, executionCap, guard) {
|
|
362
|
+
return await this.#recordWork(record, async () => {
|
|
363
|
+
this.#check();
|
|
364
|
+
if (this.#storage === undefined || record.notification || record.streaming || !record.active || !record.dispatched || record.state !== "executing" || record.resultUntil !== undefined || record.error !== undefined)
|
|
365
|
+
throw new RPCProtocolError("service_unavailable");
|
|
366
|
+
const captured = captureCheckpoint(original, checkpoint, options), target = captured.target;
|
|
367
|
+
const [authority, subject, operation] = record.key.split("\0");
|
|
368
|
+
if (target.tenant !== this.config.tenant || target.audience !== this.config.audience || target.namespace !== this.config.namespace ||
|
|
369
|
+
target.authority !== authority || target.subject !== subject || target.operation === operation)
|
|
370
|
+
throw new RPCProtocolError("permission_denied");
|
|
371
|
+
const check = () => { this.#check(); guard(); };
|
|
372
|
+
try {
|
|
373
|
+
const result = await this.#storage.issueCheckpoint(record, target, captured.checkpoint, captured.options, policy, executionCap, check, receipt => this.#applyResultReceipt(record, receipt));
|
|
374
|
+
result.payload.fill(0);
|
|
375
|
+
}
|
|
376
|
+
finally {
|
|
377
|
+
captured.checkpoint.position.fill(0);
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
}
|
|
381
|
+
async finishResume(record, request, target, policy, executionCap, guard) {
|
|
382
|
+
return await this.#recordWork(record, async () => {
|
|
383
|
+
this.#check();
|
|
384
|
+
if (this.#storage === undefined || record.notification || record.streaming || !record.active || !record.dispatched || record.resultUntil !== undefined || record.error !== undefined)
|
|
385
|
+
throw new RPCProtocolError("service_unavailable");
|
|
386
|
+
const result = await this.#storage.finishResume(record, request, target, policy, executionCap, () => { this.#check(); guard(); }, receipt => this.#applyResultReceipt(record, receipt));
|
|
387
|
+
try {
|
|
388
|
+
return result.outcome;
|
|
389
|
+
}
|
|
390
|
+
finally {
|
|
391
|
+
result.payload.fill(0);
|
|
392
|
+
}
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
async finishNotification(record, executionCap) {
|
|
396
|
+
return await this.#recordWork(record, async () => {
|
|
397
|
+
this.#check();
|
|
398
|
+
if (!record.notification || !record.active || !record.dispatched || record.error !== undefined || record.state !== "executing")
|
|
399
|
+
throw new RPCProtocolError("service_failed");
|
|
400
|
+
const now = this.#clock.sample().requireInterval();
|
|
401
|
+
this.#check();
|
|
402
|
+
if (now.upperMS >= executionCap)
|
|
403
|
+
throw new RPCProtocolError("deadline_exceeded");
|
|
404
|
+
await this.#updateReceipt({ ...record, state: "completed" }, undefined, () => { this.#check(); if (this.#clock.sample().requireInterval().upperMS >= executionCap)
|
|
405
|
+
throw new RPCProtocolError("deadline_exceeded"); }, () => {
|
|
406
|
+
record.state = "completed";
|
|
407
|
+
this.#notify(record);
|
|
408
|
+
});
|
|
409
|
+
this.#check();
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
async finishStreaming(record, executionCap, applicationError) {
|
|
413
|
+
return await this.#recordWork(record, async () => {
|
|
414
|
+
this.#check();
|
|
415
|
+
if (!record.streaming || !record.active || !record.dispatched || record.metadataFinished || record.error !== undefined)
|
|
416
|
+
throw new RPCProtocolError("service_failed");
|
|
417
|
+
const now = this.#clock.sample().requireInterval();
|
|
418
|
+
this.#check();
|
|
419
|
+
if (now.upperMS >= executionCap)
|
|
420
|
+
throw new RPCProtocolError("deadline_exceeded");
|
|
421
|
+
// The stable stream contract promises execution metadata, not saved
|
|
422
|
+
// items. Never turn the final item or an empty body into a unary result.
|
|
423
|
+
const state = applicationError === undefined ? "completed" : "failed";
|
|
424
|
+
await this.#updateReceipt({ ...record, metadataFinished: true, resultCode: applicationError, state }, undefined, () => { this.#check(); if (this.#clock.sample().requireInterval().upperMS >= executionCap)
|
|
425
|
+
throw new RPCProtocolError("deadline_exceeded"); }, () => {
|
|
426
|
+
record.metadataFinished = true;
|
|
427
|
+
record.resultCode = applicationError;
|
|
428
|
+
record.state = state;
|
|
429
|
+
this.#notify(record);
|
|
430
|
+
});
|
|
431
|
+
this.#check();
|
|
432
|
+
});
|
|
433
|
+
}
|
|
434
|
+
fail(record, code) {
|
|
435
|
+
if (record.transitions !== 0) {
|
|
436
|
+
record.deferredFailure ??= code;
|
|
437
|
+
return;
|
|
438
|
+
}
|
|
439
|
+
if (record.metadataFinished || record.state === "completed" || record.resultUntil !== undefined || record.error !== undefined)
|
|
440
|
+
return;
|
|
441
|
+
record.error = code;
|
|
442
|
+
record.state = record.dispatched ? "unknown" : "failed";
|
|
443
|
+
// An uncertain persistent write fences the store. Keep the actual local
|
|
444
|
+
// task and let explicit reopen recover its original persisted facts.
|
|
445
|
+
try {
|
|
446
|
+
void this.#recordWork(record, () => this.#storage?.update({ ...record })).catch(() => undefined);
|
|
447
|
+
}
|
|
448
|
+
catch { /* No publication authority. */ }
|
|
449
|
+
this.#notify(record);
|
|
450
|
+
}
|
|
451
|
+
exit(record) {
|
|
452
|
+
if (!record.active)
|
|
453
|
+
return;
|
|
454
|
+
if (record.transitions !== 0) {
|
|
455
|
+
record.exitRequested = true;
|
|
456
|
+
return;
|
|
457
|
+
}
|
|
458
|
+
record.exitRequested = false;
|
|
459
|
+
if (!record.metadataFinished && record.state !== "completed" && record.resultUntil === undefined && record.error === undefined)
|
|
460
|
+
this.fail(record, "service_failed");
|
|
461
|
+
record.active = false;
|
|
462
|
+
record.stop = undefined;
|
|
463
|
+
try {
|
|
464
|
+
void this.#recordWork(record, () => this.#storage?.update({ ...record })).catch(() => undefined);
|
|
465
|
+
}
|
|
466
|
+
catch { /* Reopen settles persisted active facts. */ }
|
|
467
|
+
this.#active--;
|
|
468
|
+
this.#collectClosed();
|
|
469
|
+
}
|
|
470
|
+
release(record) { record.holders--; this.#collectClosed(); }
|
|
471
|
+
#notify(record) { for (const wake of [...record.waiters])
|
|
472
|
+
wake(); }
|
|
473
|
+
async wait(record, signal) {
|
|
474
|
+
this.#check();
|
|
475
|
+
if (record.metadataFinished || record.state === "completed" || record.resultUntil !== undefined || record.error !== undefined)
|
|
476
|
+
return;
|
|
477
|
+
if (record.waiters.size >= 64 || aborted(signal))
|
|
478
|
+
throw new RPCProtocolError("service_unavailable");
|
|
479
|
+
await new NativePromise((resolve, reject) => {
|
|
480
|
+
const clean = () => { record.waiters.delete(wake); removeListener.call(signal, "abort", cancel); };
|
|
481
|
+
const wake = () => { clean(); resolve(); }, cancel = () => { clean(); reject(new RPCProtocolError("service_unavailable")); };
|
|
482
|
+
record.waiters.add(wake);
|
|
483
|
+
addListener.call(signal, "abort", cancel, { once: true });
|
|
484
|
+
if (aborted(signal))
|
|
485
|
+
cancel();
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
copyResult(record, destination) {
|
|
489
|
+
this.#check();
|
|
490
|
+
if (record.error !== undefined)
|
|
491
|
+
return { bytes: 0, sdkError: record.error };
|
|
492
|
+
const now = this.#clock.sample().requireInterval();
|
|
493
|
+
this.#check();
|
|
494
|
+
if (record.resultUntil === undefined)
|
|
495
|
+
throw new RPCProtocolError("service_unavailable");
|
|
496
|
+
if (record.result === undefined || now.lowerMS >= record.resultUntil)
|
|
497
|
+
return { bytes: 0, sdkError: "result_expired" };
|
|
498
|
+
if (now.upperMS >= record.resultUntil)
|
|
499
|
+
return { bytes: 0, sdkError: "service_unavailable" };
|
|
500
|
+
const borrow = record.result.borrowShared(record.resultBytes);
|
|
501
|
+
try {
|
|
502
|
+
destination.write(0, borrow.bytes);
|
|
503
|
+
}
|
|
504
|
+
finally {
|
|
505
|
+
borrow.release();
|
|
506
|
+
}
|
|
507
|
+
return { bytes: record.resultBytes, ...(record.resultCode === undefined ? {} : { applicationError: record.resultCode }) };
|
|
508
|
+
}
|
|
509
|
+
/** A read pins only the original immutable backing. Its charged metadata
|
|
510
|
+
* and the pin follow the publisher through the actual last fragment tail. */
|
|
511
|
+
captureResult(target, access, reference, runtimeBytes) {
|
|
512
|
+
this.#check();
|
|
513
|
+
if (this.#busy)
|
|
514
|
+
throw new RPCProtocolError("service_unavailable");
|
|
515
|
+
this.#busy = true;
|
|
516
|
+
let metadata, borrow;
|
|
517
|
+
try {
|
|
518
|
+
access.check();
|
|
519
|
+
this.#check();
|
|
520
|
+
if (!access.current() || !reference.sameEnvironment(this.#reference) || target.tenant !== this.config.tenant ||
|
|
521
|
+
target.audience !== this.config.audience || target.namespace !== this.config.namespace || !this.#floors.has(target.authority))
|
|
522
|
+
throw new RPCProtocolError("permission_denied");
|
|
523
|
+
const record = this.#records.get(`${target.authority}\0${target.subject}\0${target.operation}`);
|
|
524
|
+
// The fixed RPC error catalog has no absent-history assertion. The
|
|
525
|
+
// separate bounded QueryOperation supplies that observation when needed.
|
|
526
|
+
if (record === undefined)
|
|
527
|
+
throw new RPCProtocolError("service_unavailable");
|
|
528
|
+
if (record.request !== target.requestDigest || record.contract !== target.contractDigest)
|
|
529
|
+
throw new RPCProtocolError("operation_conflict");
|
|
530
|
+
const check = () => {
|
|
531
|
+
access.check();
|
|
532
|
+
this.#check();
|
|
533
|
+
const now = this.#clock.sample().requireInterval();
|
|
534
|
+
access.check();
|
|
535
|
+
this.#check();
|
|
536
|
+
if (!access.current() || record.resultUntil === undefined)
|
|
537
|
+
throw new RPCProtocolError("service_unavailable");
|
|
538
|
+
if (record.result === undefined || now.lowerMS >= record.resultUntil)
|
|
539
|
+
throw new RPCProtocolError("result_expired");
|
|
540
|
+
if (now.upperMS >= record.resultUntil)
|
|
541
|
+
throw new RPCProtocolError("service_unavailable");
|
|
542
|
+
};
|
|
543
|
+
check();
|
|
544
|
+
if (record.holders >= 64)
|
|
545
|
+
throw new RPCProtocolError("resource_exhausted");
|
|
546
|
+
metadata = reference.take(executionResultReadCharge(runtimeBytes));
|
|
547
|
+
borrow = record.result.borrowShared(record.resultBytes);
|
|
548
|
+
const original = borrow, owned = metadata;
|
|
549
|
+
let held = true;
|
|
550
|
+
const result = Object.freeze({
|
|
551
|
+
payload: Object.freeze({
|
|
552
|
+
bytes: original.bytes, retainSend: original.retainSend, release: () => {
|
|
553
|
+
if (!held)
|
|
554
|
+
return;
|
|
555
|
+
held = false;
|
|
556
|
+
original.release();
|
|
557
|
+
owned.release();
|
|
558
|
+
this.release(record);
|
|
559
|
+
}
|
|
560
|
+
}), guard: Object.freeze({
|
|
561
|
+
check: () => {
|
|
562
|
+
if (!held)
|
|
563
|
+
throw new RPCProtocolError("service_unavailable");
|
|
564
|
+
owned.check();
|
|
565
|
+
check();
|
|
566
|
+
if (!held)
|
|
567
|
+
throw new RPCProtocolError("service_unavailable");
|
|
568
|
+
}, current: () => held && !this.#closed && access.current()
|
|
569
|
+
})
|
|
570
|
+
});
|
|
571
|
+
record.holders++;
|
|
572
|
+
borrow = undefined;
|
|
573
|
+
metadata = undefined;
|
|
574
|
+
return result;
|
|
575
|
+
}
|
|
576
|
+
finally {
|
|
577
|
+
borrow?.release();
|
|
578
|
+
metadata?.release();
|
|
579
|
+
this.#busy = false;
|
|
580
|
+
this.#collectClosed();
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
/** Current Session authority must be checked before lookup. A remote target
|
|
584
|
+
* does not prove continuity of an absent RAM record. Cancellation changes
|
|
585
|
+
* the original record before any cooperative application signal is emitted. */
|
|
586
|
+
async manage(target, cancel, access) {
|
|
587
|
+
this.#check();
|
|
588
|
+
if (this.#busy)
|
|
589
|
+
return { status: "unavailable" };
|
|
590
|
+
this.#busy = true;
|
|
591
|
+
let notify;
|
|
592
|
+
try {
|
|
593
|
+
access.check();
|
|
594
|
+
this.#check();
|
|
595
|
+
const now = this.#clock.sample().requireInterval();
|
|
596
|
+
access.check();
|
|
597
|
+
this.#check();
|
|
598
|
+
if (!access.current() || target.tenant !== this.config.tenant || target.audience !== this.config.audience || target.namespace !== this.config.namespace ||
|
|
599
|
+
!this.#floors.has(target.authority))
|
|
600
|
+
throw new RPCProtocolError("permission_denied");
|
|
601
|
+
const record = this.#records.get(`${target.authority}\0${target.subject}\0${target.operation}`);
|
|
602
|
+
if (record === undefined) {
|
|
603
|
+
const key = `${target.authority}\0${target.subject}\0${target.operation}`, cutoff = BigInt("0x" + target.operation.slice(0, 16));
|
|
604
|
+
const reason = (await this.#storageWork(() => this.#storage?.absence(key, target.authority, cutoff, () => { access.check(); this.#check(); }))) ?? "history_unknown";
|
|
605
|
+
return Object.freeze({
|
|
606
|
+
status: cancel ? "ok" : reason === "not_registered" ? "not_found" : "history_unknown",
|
|
607
|
+
observation: Object.freeze({ found: false, reason }), ...(cancel ? { cancelResult: reason } : {})
|
|
608
|
+
});
|
|
609
|
+
}
|
|
610
|
+
if (record.request !== target.requestDigest || record.contract !== target.contractDigest)
|
|
611
|
+
throw new RPCProtocolError("operation_conflict");
|
|
612
|
+
if (cancel && !record.cancelMode)
|
|
613
|
+
return { status: "unsupported" };
|
|
614
|
+
let cancelResult = "terminal";
|
|
615
|
+
if (cancel)
|
|
616
|
+
await this.#recordWork(record, async () => {
|
|
617
|
+
access.check();
|
|
618
|
+
this.#check();
|
|
619
|
+
if (["accepted", "executing", "unknown"].includes(record.state)) {
|
|
620
|
+
const state = record.dispatched ? record.state : "failed", error = record.dispatched ? record.error : "service_unavailable";
|
|
621
|
+
await this.#updateReceipt({ ...record, cancelRequested: true, state, error }, undefined, () => { access.check(); this.#check(); }, () => {
|
|
622
|
+
// A failed or uncertain durable write cannot publish a cancellation
|
|
623
|
+
// fact or dispatch a cooperative signal as though it were confirmed.
|
|
624
|
+
if (!record.cancelRequested)
|
|
625
|
+
notify = record.stop;
|
|
626
|
+
record.cancelRequested = true;
|
|
627
|
+
record.state = state;
|
|
628
|
+
record.error = error;
|
|
629
|
+
cancelResult = "requested";
|
|
630
|
+
});
|
|
631
|
+
}
|
|
632
|
+
});
|
|
633
|
+
const formed = record.resultUntil !== undefined, deleted = formed && (record.result === undefined || now.lowerMS >= record.resultUntil);
|
|
634
|
+
const observation = Object.freeze({
|
|
635
|
+
found: true,
|
|
636
|
+
reason: record.error === undefined ? "none" : record.cancelRequested && !record.dispatched ? "cancelled" : record.error === "deadline_exceeded" ? "deadline_exceeded" : record.dispatched ? "work_outcome_unknown" : "dispatch_unavailable",
|
|
637
|
+
state: record.state, cancelRequested: record.cancelRequested, dispatched: record.dispatched, workActive: record.active,
|
|
638
|
+
historyNotBeforeGCMS: record.historyUntil, resultNotAfterMS: record.resultUntil ?? 0n,
|
|
639
|
+
resultAvailable: formed && record.result !== undefined && now.upperMS < record.resultUntil, resultDeleted: deleted,
|
|
640
|
+
resultBytes: record.resultBytes, applicationErrorCode: record.resultCode ?? 0, resultDigest: record.resultDigest
|
|
641
|
+
});
|
|
642
|
+
return Object.freeze({ status: cancel ? "ok" : deleted ? "result_expired" : "ok", observation, ...(cancel ? { cancelResult } : {}) });
|
|
643
|
+
}
|
|
644
|
+
finally {
|
|
645
|
+
this.#busy = false;
|
|
646
|
+
// AbortSignal dispatch can enter application listeners. Leave the finite
|
|
647
|
+
// history gate first; the signal never supplies work-exit evidence.
|
|
648
|
+
if (notify !== undefined)
|
|
649
|
+
queueMicrotask(notify);
|
|
650
|
+
this.#collectClosed();
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
#tick = async () => {
|
|
654
|
+
this.#timer = undefined;
|
|
655
|
+
if (this.#closed)
|
|
656
|
+
return;
|
|
657
|
+
if (this.#busy) {
|
|
658
|
+
this.#timer = setTimeout(this.#tick, 1000);
|
|
659
|
+
return;
|
|
660
|
+
}
|
|
661
|
+
this.#busy = true;
|
|
662
|
+
try {
|
|
663
|
+
const now = this.#clock.sample().requireInterval();
|
|
664
|
+
this.#check();
|
|
665
|
+
for (let count = 0; count < Math.min(8, this.#slots.length); count++) {
|
|
666
|
+
const index = this.#cursor;
|
|
667
|
+
this.#cursor = (index + 1) % this.#slots.length;
|
|
668
|
+
const record = this.#slots[index];
|
|
669
|
+
if (record === undefined || record.transitions !== 0)
|
|
670
|
+
continue;
|
|
671
|
+
if (!record.active && record.holders === 0 && record.result !== undefined && (record.resultUntil === undefined || now.lowerMS >= record.resultUntil)) {
|
|
672
|
+
(await this.#storageWork(() => this.#storage?.expireResult(record.key)));
|
|
673
|
+
record.result.close();
|
|
674
|
+
record.result = undefined;
|
|
675
|
+
}
|
|
676
|
+
if (record.active || record.holders !== 0 || record.result !== undefined || now.lowerMS < record.historyUntil || now.lowerMS < record.cutoff)
|
|
677
|
+
continue;
|
|
678
|
+
// Install the original domain's floor before deleting any key detail.
|
|
679
|
+
const floor = record.cutoff > this.#floors.get(record.domain) ? record.cutoff : this.#floors.get(record.domain);
|
|
680
|
+
(await this.#storageWork(() => this.#storage?.remove(record.key, record.domain, floor)));
|
|
681
|
+
this.#floors.set(record.domain, floor);
|
|
682
|
+
this.#records.delete(record.key);
|
|
683
|
+
this.#slots[index] = undefined;
|
|
684
|
+
}
|
|
685
|
+
}
|
|
686
|
+
catch { /* Unavailable trusted time cannot delete history or advance a floor. */ }
|
|
687
|
+
finally {
|
|
688
|
+
this.#busy = false;
|
|
689
|
+
this.#collectClosed();
|
|
690
|
+
}
|
|
691
|
+
if (!this.#closed)
|
|
692
|
+
this.#timer = setTimeout(this.#tick, 1000);
|
|
693
|
+
};
|
|
694
|
+
close() {
|
|
695
|
+
if (this.#closed)
|
|
696
|
+
return;
|
|
697
|
+
this.#closed = true;
|
|
698
|
+
if (this.#timer !== undefined)
|
|
699
|
+
clearTimeout(this.#timer);
|
|
700
|
+
this.#timer = undefined;
|
|
701
|
+
for (const record of this.#records.values()) {
|
|
702
|
+
this.fail(record, "service_unavailable");
|
|
703
|
+
record.stop?.();
|
|
704
|
+
}
|
|
705
|
+
this.#collectClosed();
|
|
706
|
+
}
|
|
707
|
+
#collectClosed() {
|
|
708
|
+
if (!this.#closed || this.#busy || this.#pendingStorage !== 0 || this.#pendingRecordWork !== 0 || this.#active !== 0 || [...this.#records.values()].some(record => record.holders !== 0 || record.transitions !== 0))
|
|
709
|
+
return;
|
|
710
|
+
for (const record of this.#records.values())
|
|
711
|
+
record.result?.close();
|
|
712
|
+
this.#records.clear();
|
|
713
|
+
this.#slots.fill(undefined);
|
|
714
|
+
this.#floors.clear();
|
|
715
|
+
if (this.#storageBound) {
|
|
716
|
+
this.#storageBound = false;
|
|
717
|
+
this.#storage.release();
|
|
718
|
+
}
|
|
719
|
+
this.#resultAccount?.close();
|
|
720
|
+
this.#resultAccount = undefined;
|
|
721
|
+
this.#reference?.release();
|
|
722
|
+
this.#reference = undefined;
|
|
723
|
+
}
|
|
724
|
+
cleanupComplete() { this.#collectClosed(); return this.#reference === undefined; }
|
|
725
|
+
}
|
|
726
|
+
/** A duplicate has observation rights only. Only the first complete input
|
|
727
|
+
* receives the original one-use execution work capability. */
|
|
728
|
+
export class VolatileExecutionAttempt {
|
|
729
|
+
created;
|
|
730
|
+
#owner;
|
|
731
|
+
#exited = false;
|
|
732
|
+
#record;
|
|
733
|
+
constructor(token, owner, record, created) {
|
|
734
|
+
this.created = created;
|
|
735
|
+
if (token !== capability)
|
|
736
|
+
throw new RPCProtocolError("rpc_owner");
|
|
737
|
+
this.#owner = owner;
|
|
738
|
+
this.#record = record;
|
|
739
|
+
Object.freeze(this);
|
|
740
|
+
}
|
|
741
|
+
async enter(guard) {
|
|
742
|
+
if (!this.created)
|
|
743
|
+
throw new RPCProtocolError("rpc_owner");
|
|
744
|
+
(await this.#owner.enter(this.#record, guard));
|
|
745
|
+
}
|
|
746
|
+
async finish(bytes, code, executionCap) {
|
|
747
|
+
if (!this.created)
|
|
748
|
+
throw new RPCProtocolError("rpc_owner");
|
|
749
|
+
(await this.#owner.finish(this.#record, bytes, code, executionCap));
|
|
750
|
+
}
|
|
751
|
+
async saveContent(position, payload, executionCap, guard) {
|
|
752
|
+
if (!this.created || this.#exited)
|
|
753
|
+
throw new RPCProtocolError("rpc_owner");
|
|
754
|
+
return (await this.#owner.saveContent(this.#record, position, payload, executionCap, guard));
|
|
755
|
+
}
|
|
756
|
+
async readContent(target, position, destination, readerType, guard) {
|
|
757
|
+
if (!this.created || this.#exited)
|
|
758
|
+
throw new RPCProtocolError("rpc_owner");
|
|
759
|
+
return (await this.#owner.readContent(this.#record, target, position, destination, readerType, guard));
|
|
760
|
+
}
|
|
761
|
+
async issueCheckpoint(original, checkpoint, options, policy, executionCap, guard) {
|
|
762
|
+
if (!this.created || this.#exited)
|
|
763
|
+
throw new RPCProtocolError("rpc_owner");
|
|
764
|
+
(await this.#owner.issueCheckpoint(this.#record, original, checkpoint, options, policy, executionCap, guard));
|
|
765
|
+
}
|
|
766
|
+
async finishResume(request, target, policy, executionCap, guard) {
|
|
767
|
+
if (!this.created || this.#exited)
|
|
768
|
+
throw new RPCProtocolError("rpc_owner");
|
|
769
|
+
return (await this.#owner.finishResume(this.#record, request, target, policy, executionCap, guard));
|
|
770
|
+
}
|
|
771
|
+
async finishNotification(executionCap) {
|
|
772
|
+
if (!this.created)
|
|
773
|
+
throw new RPCProtocolError("rpc_owner");
|
|
774
|
+
(await this.#owner.finishNotification(this.#record, executionCap));
|
|
775
|
+
}
|
|
776
|
+
async finishStreaming(executionCap, applicationError) {
|
|
777
|
+
if (!this.created)
|
|
778
|
+
throw new RPCProtocolError("rpc_owner");
|
|
779
|
+
(await this.#owner.finishStreaming(this.#record, executionCap, applicationError));
|
|
780
|
+
}
|
|
781
|
+
fail(code) { if (this.created)
|
|
782
|
+
this.#owner?.fail(this.#record, code); }
|
|
783
|
+
exit() { if (this.#exited || !this.created)
|
|
784
|
+
return; this.#exited = true; this.#owner?.exit(this.#record); }
|
|
785
|
+
wait(signal) { return this.#owner.wait(this.#record, signal); }
|
|
786
|
+
copyResult(destination) { return this.#owner.copyResult(this.#record, destination); }
|
|
787
|
+
release() { this.exit(); const owner = this.#owner; this.#owner = undefined; owner?.release(this.#record); }
|
|
788
|
+
}
|
|
789
|
+
for (const owner of [VolatileExecutions, VolatileExecutionAttempt]) {
|
|
790
|
+
Object.freeze(owner.prototype);
|
|
791
|
+
Object.freeze(owner);
|
|
792
|
+
}
|