@floegence/flowersec-core 6.0.0 → 7.0.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 +101 -170
- package/THIRD_PARTY_NOTICES.md +5 -3070
- package/dist/browser/connectSessionV3.d.ts +44 -0
- package/dist/browser/connectSessionV3.js +261 -0
- package/dist/browser/directWebSocketProfileV1.d.ts +14 -0
- package/dist/browser/directWebSocketProfileV1.js +71 -0
- package/dist/browser/httpDirectV1.d.ts +30 -0
- package/dist/browser/httpDirectV1.js +52 -0
- package/dist/browser/index.d.ts +10 -15
- package/dist/browser/index.js +4 -5
- package/dist/browser/privateLoopbackV1.d.ts +30 -0
- package/dist/browser/privateLoopbackV1.js +70 -0
- package/dist/cli.d.ts +1 -24
- package/dist/cli.js +129 -91
- package/dist/cliSpendMarker.js +8 -0
- package/dist/defaults.d.ts +23 -1
- package/dist/defaults.js +23 -1
- package/dist/facade.d.ts +21 -104
- package/dist/facade.js +8 -45
- package/dist/framing/jsonframe.d.ts +21 -0
- package/dist/framing/jsonframe.js +107 -0
- package/dist/node/acceptor.d.ts +1 -0
- package/dist/node/acceptor.js +1 -0
- package/dist/node/acceptorV3.d.ts +70 -0
- package/dist/node/acceptorV3.js +295 -0
- package/dist/node/byteStreamDuplex.d.ts +4 -0
- package/dist/node/byteStreamDuplex.js +69 -0
- package/dist/node/connectSessionV3.d.ts +33 -0
- package/dist/node/connectSessionV3.js +93 -0
- package/dist/node/connectionPath.d.ts +28 -0
- package/dist/node/connectionPath.js +169 -0
- package/dist/node/index.d.ts +18 -52
- package/dist/node/index.js +7 -24
- package/dist/node/listenerIngress.d.ts +5 -0
- package/dist/node/listenerIngress.js +12 -0
- package/dist/node/nativeTransportAddon.d.ts +142 -0
- package/dist/node/nativeTransportAddon.js +235 -0
- package/dist/node/proxyServer.d.ts +4 -30
- package/dist/node/proxyServer.js +169 -600
- package/dist/node/rawQuicAdapterV3.d.ts +11 -0
- package/dist/node/rawQuicAdapterV3.js +83 -0
- package/dist/node/rawQuicServerV3.d.ts +34 -0
- package/dist/node/rawQuicServerV3.js +60 -0
- package/dist/node/runtimeAuthorizationV3.d.ts +41 -0
- package/dist/node/runtimeAuthorizationV3.js +156 -0
- package/dist/node/tunnelRuntimeV3.d.ts +60 -0
- package/dist/node/tunnelRuntimeV3.js +837 -0
- package/dist/node/webSocketServerV3.d.ts +28 -0
- package/dist/node/webSocketServerV3.js +220 -0
- package/dist/proxy/fetch.d.ts +2 -3
- package/dist/proxy/fetch.js +29 -96
- package/dist/proxy/index.d.ts +1 -5
- package/dist/proxy/index.js +0 -2
- package/dist/proxy/integration.d.ts +8 -12
- package/dist/proxy/integration.js +16 -23
- package/dist/proxy/policy.d.ts +0 -5
- package/dist/proxy/policy.js +22 -60
- package/dist/proxy/runtime.d.ts +1 -3
- package/dist/proxy/runtime.js +186 -404
- package/dist/proxy/scope.js +2 -2
- package/dist/proxy/serviceWorker.d.ts +0 -3
- package/dist/proxy/serviceWorker.js +176 -634
- package/dist/proxy/serviceWorkerRuntime.js +1 -26
- package/dist/proxy/stream.d.ts +6 -17
- package/dist/proxy/stream.js +40 -9
- package/dist/proxy/types.d.ts +11 -50
- package/dist/proxy/windowBridge.d.ts +3 -11
- package/dist/proxy/windowBridge.js +37 -76
- package/dist/proxy/wsPatch.js +26 -34
- package/dist/public/contract.d.ts +74 -1
- package/dist/public/contract.js +8 -0
- package/dist/public/sessionHandlers.d.ts +47 -0
- package/dist/public/sessionHandlers.js +151 -0
- package/dist/public/streamHandlers.d.ts +20 -0
- package/dist/public/streamHandlers.js +127 -0
- package/dist/public/streamMetadata.d.ts +2 -34
- package/dist/public/streamMetadata.js +13 -206
- package/dist/rpc/client.d.ts +34 -0
- package/dist/rpc/client.js +244 -0
- package/dist/rpc/server.d.ts +59 -0
- package/dist/rpc/server.js +255 -0
- package/dist/rpc/validate.d.ts +4 -0
- package/dist/{application/rpcJSON.js → rpc/validate.js} +1 -1
- package/dist/rpc/wire.d.ts +15 -0
- package/dist/v3/admissionError.d.ts +4 -0
- package/dist/v3/admissionError.js +8 -0
- package/dist/v3/artifact.d.ts +145 -0
- package/dist/v3/artifact.js +1180 -0
- package/dist/v3/artifactLease.d.ts +19 -0
- package/dist/v3/artifactLease.js +128 -0
- package/dist/v3/browserRuntime.d.ts +37 -0
- package/dist/v3/browserRuntime.js +197 -0
- package/dist/v3/browserSessionRuntime.d.ts +2 -0
- package/dist/v3/browserSessionRuntime.js +21 -0
- package/dist/v3/capability.d.ts +32 -0
- package/dist/v3/capability.js +345 -0
- package/dist/v3/carrier.d.ts +86 -0
- package/dist/v3/carrier.js +414 -0
- package/dist/v3/connectionController.d.ts +101 -0
- package/dist/v3/connectionController.js +888 -0
- package/dist/v3/contract.d.ts +70 -0
- package/dist/v3/contract.js +3 -0
- package/dist/v3/controller.d.ts +45 -0
- package/dist/v3/controller.js +316 -0
- package/dist/v3/handshake.d.ts +81 -0
- package/dist/v3/handshake.js +471 -0
- package/dist/v3/jcs.d.ts +6 -0
- package/dist/v3/jcs.js +69 -0
- package/dist/v3/jsonPreflight.d.ts +1 -0
- package/dist/v3/jsonPreflight.js +251 -0
- package/dist/v3/nodeRuntime.d.ts +43 -0
- package/dist/v3/nodeRuntime.js +437 -0
- package/dist/v3/nodeSessionRuntime.d.ts +2 -0
- package/dist/v3/nodeSessionRuntime.js +13 -0
- package/dist/v3/protocol.d.ts +100 -0
- package/dist/v3/protocol.js +715 -0
- package/dist/v3/publicApi.d.ts +12 -0
- package/dist/v3/publicApi.js +46 -0
- package/dist/v3/publicSession.js +316 -0
- package/dist/v3/runtimeAdapters.d.ts +9 -0
- package/dist/v3/runtimeAdapters.js +109 -0
- package/dist/v3/security.d.ts +36 -0
- package/dist/v3/security.js +113 -0
- package/dist/v3/serverAdmission.d.ts +42 -0
- package/dist/v3/serverAdmission.js +242 -0
- package/dist/v3/session.d.ts +339 -0
- package/dist/v3/session.js +2399 -0
- package/dist/v3/sessionConnector.d.ts +46 -0
- package/dist/v3/sessionConnector.js +534 -0
- package/dist/v3/streamLifetimeLedger.d.ts +32 -0
- package/dist/v3/streamLifetimeLedger.js +146 -0
- package/dist/v3/streamMetadata.js +7 -0
- package/dist/v3/transportConstants.d.ts +56 -0
- package/dist/v3/transportConstants.js +59 -0
- package/dist/v3/tunnelIngress.d.ts +8 -0
- package/dist/v3/tunnelIngress.js +21 -0
- package/dist/v3/unreliableMessage.d.ts +44 -0
- package/dist/v3/unreliableMessage.js +287 -0
- package/dist/v3/webSocketCarrier.d.ts +33 -0
- package/dist/v3/webSocketCarrier.js +380 -0
- package/dist/v3/webTransportCarrier.d.ts +27 -0
- package/dist/v3/webTransportCarrier.js +580 -0
- package/dist/ws-client/binaryTransport.d.ts +65 -0
- package/dist/ws-client/binaryTransport.js +348 -0
- package/dist/yamux/byteReader.d.ts +13 -0
- package/dist/yamux/byteReader.js +81 -0
- package/dist/yamux/constants.d.ts +10 -0
- package/dist/yamux/constants.js +14 -0
- package/dist/yamux/errors.d.ts +15 -0
- package/dist/yamux/errors.js +34 -0
- package/dist/yamux/header.d.ts +20 -0
- package/dist/yamux/header.js +30 -0
- package/dist/yamux/session.d.ts +81 -0
- package/dist/yamux/session.js +401 -0
- package/dist/yamux/stream.d.ts +42 -0
- package/dist/yamux/stream.js +307 -0
- package/package.json +16 -15
- package/sbom/cyclonedx.json +38 -756
- package/sbom/spdx.json +38 -555
- package/dist/application/rpcJSON.d.ts +0 -15
- package/dist/browser/clientV4.d.ts +0 -61
- package/dist/browser/clientV4.js +0 -179
- package/dist/browser/indexedDBPoolV4.d.ts +0 -101
- package/dist/browser/indexedDBPoolV4.js +0 -634
- package/dist/browser/liveHTTPSV4.d.ts +0 -35
- package/dist/browser/liveHTTPSV4.js +0 -162
- package/dist/browser/localBrowserBridge.d.ts +0 -20
- package/dist/browser/localBrowserBridge.js +0 -82
- package/dist/browser/poolServerAllow.d.ts +0 -21
- package/dist/browser/poolServerAllow.js +0 -151
- package/dist/browser/webTransportPositionsV4.d.ts +0 -16
- package/dist/browser/webTransportPositionsV4.js +0 -75
- package/dist/browser/webTransportStreamV4.d.ts +0 -36
- package/dist/browser/webTransportStreamV4.js +0 -370
- package/dist/browser/webTransportV4.d.ts +0 -126
- package/dist/browser/webTransportV4.js +0 -627
- package/dist/browser/wssV4.d.ts +0 -69
- package/dist/browser/wssV4.js +0 -339
- package/dist/generated/brotliWorker.d.ts +0 -1
- package/dist/generated/brotliWorker.js +0 -3
- package/dist/generated/idna151.d.ts +0 -2
- package/dist/generated/idna151.js +0 -38
- package/dist/generated/normalization151.d.ts +0 -5
- package/dist/generated/normalization151.js +0 -878
- package/dist/generated/sqliteWorkers.d.ts +0 -2
- package/dist/generated/sqliteWorkers.js +0 -3
- package/dist/generated/transportV4APIResults.d.ts +0 -145
- package/dist/generated/transportV4APIResults.js +0 -52
- package/dist/generated/transportV4Registry.d.ts +0 -3758
- package/dist/generated/transportV4Registry.js +0 -29
- package/dist/interop/browserRunner.d.ts +0 -72
- package/dist/interop/browserRunner.js +0 -354
- package/dist/interop/currentContracts.d.ts +0 -6
- package/dist/interop/currentContracts.js +0 -14
- package/dist/interop/currentNativeTunnel.d.ts +0 -30
- package/dist/interop/currentNativeTunnel.js +0 -149
- package/dist/interop/currentParity.d.ts +0 -68
- package/dist/interop/currentParity.js +0 -392
- package/dist/interop/currentPeer.d.ts +0 -241
- package/dist/interop/currentPeer.js +0 -630
- package/dist/interop/currentRegisteredTunnelPeer.d.ts +0 -37
- package/dist/interop/currentRegisteredTunnelPeer.js +0 -93
- package/dist/interop/currentRelayPeer.d.ts +0 -118
- package/dist/interop/currentRelayPeer.js +0 -251
- package/dist/interop/currentServer.d.ts +0 -44
- package/dist/interop/currentServer.js +0 -293
- package/dist/interop/currentTLSPin.d.ts +0 -9
- package/dist/interop/currentTLSPin.js +0 -44
- package/dist/interop/currentTunnelMaterial.d.ts +0 -34
- package/dist/interop/currentTunnelMaterial.js +0 -100
- package/dist/interop/httpApplicationPeer.d.ts +0 -15
- package/dist/interop/httpApplicationPeer.js +0 -167
- package/dist/interop/invalidProofPeer.d.ts +0 -8
- package/dist/interop/invalidProofPeer.js +0 -106
- package/dist/interop/proxyServerPeer.js +0 -49
- package/dist/interop/serverParityPeer.d.ts +0 -101
- package/dist/interop/serverParityPeer.js +0 -609
- package/dist/node/acceptorCurrent.d.ts +0 -55
- package/dist/node/acceptorCurrent.js +0 -286
- package/dist/node/admissionRecord.d.ts +0 -23
- package/dist/node/admissionRecord.js +0 -178
- package/dist/node/clientV4.d.ts +0 -59
- package/dist/node/clientV4.js +0 -197
- package/dist/node/endpointDialer.d.ts +0 -70
- package/dist/node/endpointDialer.js +0 -231
- package/dist/node/endpointListener.d.ts +0 -48
- package/dist/node/endpointListener.js +0 -403
- package/dist/node/endpointTransport.d.ts +0 -7
- package/dist/node/endpointTransport.js +0 -18
- package/dist/node/grantIssuerCurrent.d.ts +0 -64
- package/dist/node/grantIssuerCurrent.js +0 -355
- package/dist/node/liveHTTPSV4.d.ts +0 -26
- package/dist/node/liveHTTPSV4.js +0 -283
- package/dist/node/liveTunnelAuthorityCurrent.d.ts +0 -153
- package/dist/node/liveTunnelAuthorityCurrent.js +0 -590
- package/dist/node/nativeDuplexBridgeV4.d.ts +0 -41
- package/dist/node/nativeDuplexBridgeV4.js +0 -494
- package/dist/node/nativeTransportCurrent.d.ts +0 -196
- package/dist/node/nativeTransportCurrent.js +0 -37
- package/dist/node/poolServerAllow.d.ts +0 -33
- package/dist/node/poolServerAllow.js +0 -277
- package/dist/node/proxyCredentials.d.ts +0 -67
- package/dist/node/proxyCredentials.js +0 -364
- package/dist/node/proxyNetwork.d.ts +0 -18
- package/dist/node/proxyNetwork.js +0 -213
- package/dist/node/rawQUICCurrent.d.ts +0 -139
- package/dist/node/rawQUICCurrent.js +0 -1177
- package/dist/node/registeredLiveTunnelControl.d.ts +0 -74
- package/dist/node/registeredLiveTunnelControl.js +0 -865
- package/dist/node/registeredPoolTunnelAuthority.d.ts +0 -41
- package/dist/node/registeredPoolTunnelAuthority.js +0 -297
- package/dist/node/registeredTunnelControl.d.ts +0 -189
- package/dist/node/registeredTunnelControl.js +0 -1007
- package/dist/node/registeredWinnerContinuation.d.ts +0 -26
- package/dist/node/registeredWinnerContinuation.js +0 -83
- package/dist/node/relayNativePair.d.ts +0 -62
- package/dist/node/relayNativePair.js +0 -737
- package/dist/node/relayRecord.d.ts +0 -57
- package/dist/node/relayRecord.js +0 -275
- package/dist/node/serveRawQUIC.d.ts +0 -58
- package/dist/node/serveRawQUIC.js +0 -331
- package/dist/node/serveWSS.d.ts +0 -58
- package/dist/node/serveWSS.js +0 -309
- package/dist/node/sqliteAdmission.d.ts +0 -100
- package/dist/node/sqliteAdmission.js +0 -1185
- package/dist/node/sqliteExecutionContentV4.d.ts +0 -63
- package/dist/node/sqliteExecutionContentV4.js +0 -251
- package/dist/node/sqliteExecutionV4.d.ts +0 -114
- package/dist/node/sqliteExecutionV4.js +0 -1052
- package/dist/node/sqliteFormat.d.ts +0 -20
- package/dist/node/sqliteFormat.js +0 -72
- package/dist/node/sqliteInspectionV4.d.ts +0 -7
- package/dist/node/sqliteInspectionV4.js +0 -47
- package/dist/node/sqliteNativeV4.d.ts +0 -3
- package/dist/node/sqliteNativeV4.js +0 -16
- package/dist/node/sqlitePoolV4.d.ts +0 -41
- package/dist/node/sqlitePoolV4.js +0 -282
- package/dist/node/sqlitePoolWorkerProgramV4.js +0 -411
- package/dist/node/sqlitePoolWorkerV4.d.ts +0 -67
- package/dist/node/sqlitePoolWorkerV4.js +0 -206
- package/dist/node/sqliteV4.d.ts +0 -82
- package/dist/node/sqliteV4.js +0 -166
- package/dist/node/sqliteWorkerProgramV4.js +0 -175
- package/dist/node/sqliteWorkerV4.d.ts +0 -47
- package/dist/node/sqliteWorkerV4.js +0 -142
- package/dist/node/streamDuplexV4.d.ts +0 -33
- package/dist/node/streamDuplexV4.js +0 -359
- package/dist/node/tunnelListenerPreparation.d.ts +0 -37
- package/dist/node/tunnelListenerPreparation.js +0 -162
- package/dist/node/tunnelRuntime.d.ts +0 -124
- package/dist/node/tunnelRuntime.js +0 -1205
- package/dist/node/webTransportCurrent.d.ts +0 -24
- package/dist/node/webTransportCurrent.js +0 -12
- package/dist/node/wssV4.d.ts +0 -96
- package/dist/node/wssV4.js +0 -822
- package/dist/proxy/admission.d.ts +0 -21
- package/dist/proxy/admission.js +0 -126
- package/dist/proxy/brotliBody.d.ts +0 -10
- package/dist/proxy/brotliBody.js +0 -85
- package/dist/proxy/credentialControl.d.ts +0 -30
- package/dist/proxy/credentialControl.js +0 -86
- package/dist/proxy/currentStream.d.ts +0 -24
- package/dist/proxy/currentStream.js +0 -158
- package/dist/proxy/headers.d.ts +0 -8
- package/dist/proxy/headers.js +0 -63
- package/dist/proxy/publicationOwner.d.ts +0 -10
- package/dist/proxy/publicationOwner.js +0 -130
- package/dist/proxy/requestAssociation.d.ts +0 -11
- package/dist/proxy/requestAssociation.js +0 -8
- package/dist/proxy/surface.d.ts +0 -45
- package/dist/proxy/surface.js +0 -384
- package/dist/proxy/wire.d.ts +0 -11
- package/dist/proxy/wire.js +0 -214
- package/dist/public/streamKind.d.ts +0 -3
- package/dist/public/streamKind.js +0 -19
- package/dist/testSupport/tlsFixture.d.ts +0 -2
- package/dist/testSupport/tlsFixture.js +0 -8
- package/dist/v4/admissionOffer.d.ts +0 -8
- package/dist/v4/admissionOffer.js +0 -1
- package/dist/v4/checkpoint.d.ts +0 -23
- package/dist/v4/checkpoint.js +0 -16
- package/dist/v4/clientServices.d.ts +0 -35
- package/dist/v4/clientServices.js +0 -11
- package/dist/v4/connectionDiagnostic.d.ts +0 -42
- package/dist/v4/connectionDiagnostic.js +0 -45
- package/dist/v4/connectionRequirements.d.ts +0 -5
- package/dist/v4/connectionRequirements.js +0 -34
- package/dist/v4/controller.d.ts +0 -122
- package/dist/v4/controller.js +0 -1161
- package/dist/v4/controllerNotifications.d.ts +0 -81
- package/dist/v4/controllerNotifications.js +0 -610
- package/dist/v4/diagnostics.d.ts +0 -44
- package/dist/v4/diagnostics.js +0 -9
- package/dist/v4/drain.d.ts +0 -39
- package/dist/v4/drain.js +0 -80
- package/dist/v4/duplexBridge.d.ts +0 -53
- package/dist/v4/duplexBridge.js +0 -446
- package/dist/v4/entrypoints.d.ts +0 -20
- package/dist/v4/entrypoints.js +0 -50
- package/dist/v4/eventSource.d.ts +0 -34
- package/dist/v4/eventSource.js +0 -28
- package/dist/v4/handlerPlan.d.ts +0 -53
- package/dist/v4/handlerPlan.js +0 -129
- package/dist/v4/liveness.d.ts +0 -20
- package/dist/v4/liveness.js +0 -10
- package/dist/v4/localReport.d.ts +0 -17
- package/dist/v4/localReport.js +0 -10
- package/dist/v4/messageDefinition.d.ts +0 -66
- package/dist/v4/messageDefinition.js +0 -109
- package/dist/v4/messageStream.d.ts +0 -89
- package/dist/v4/messageStream.js +0 -1375
- package/dist/v4/notificationOperation.d.ts +0 -30
- package/dist/v4/notificationOperation.js +0 -31
- package/dist/v4/notificationSubscription.d.ts +0 -47
- package/dist/v4/notificationSubscription.js +0 -24
- package/dist/v4/operationReference.d.ts +0 -28
- package/dist/v4/operationReference.js +0 -61
- package/dist/v4/operationReferenceCodec.d.ts +0 -20
- package/dist/v4/operationReferenceCodec.js +0 -129
- package/dist/v4/operationReferenceStore.d.ts +0 -90
- package/dist/v4/operationReferenceStore.js +0 -272
- package/dist/v4/operationResultRead.d.ts +0 -26
- package/dist/v4/operationResultRead.js +0 -24
- package/dist/v4/poolControl.d.ts +0 -11
- package/dist/v4/poolControl.js +0 -50
- package/dist/v4/poolSource.d.ts +0 -93
- package/dist/v4/poolSource.js +0 -900
- package/dist/v4/profileDHReference.d.ts +0 -2
- package/dist/v4/profileDHReference.js +0 -42
- package/dist/v4/public.d.ts +0 -232
- package/dist/v4/public.js +0 -632
- package/dist/v4/responsePublication.d.ts +0 -48
- package/dist/v4/responsePublication.js +0 -227
- package/dist/v4/resume.d.ts +0 -17
- package/dist/v4/resume.js +0 -15
- package/dist/v4/runtime/applicationExecutor.d.ts +0 -190
- package/dist/v4/runtime/applicationExecutor.js +0 -759
- package/dist/v4/runtime/applicationHeader.d.ts +0 -61
- package/dist/v4/runtime/applicationHeader.js +0 -222
- package/dist/v4/runtime/canonicalText.d.ts +0 -8
- package/dist/v4/runtime/canonicalText.js +0 -142
- package/dist/v4/runtime/cbor.d.ts +0 -92
- package/dist/v4/runtime/cbor.js +0 -728
- package/dist/v4/runtime/cborWriter.d.ts +0 -18
- package/dist/v4/runtime/cborWriter.js +0 -59
- package/dist/v4/runtime/checkpointToken.d.ts +0 -41
- package/dist/v4/runtime/checkpointToken.js +0 -61
- package/dist/v4/runtime/clientAdmission.d.ts +0 -40
- package/dist/v4/runtime/clientAdmission.js +0 -378
- package/dist/v4/runtime/clientSessionSpec.d.ts +0 -45
- package/dist/v4/runtime/clientSessionSpec.js +0 -91
- package/dist/v4/runtime/clock.d.ts +0 -80
- package/dist/v4/runtime/clock.js +0 -284
- package/dist/v4/runtime/connectionFacts.d.ts +0 -23
- package/dist/v4/runtime/connectionFacts.js +0 -106
- package/dist/v4/runtime/contractAcceptance.d.ts +0 -20
- package/dist/v4/runtime/contractAcceptance.js +0 -91
- package/dist/v4/runtime/contractQuery.d.ts +0 -57
- package/dist/v4/runtime/contractQuery.js +0 -265
- package/dist/v4/runtime/contractQueryAccess.d.ts +0 -25
- package/dist/v4/runtime/contractQueryAccess.js +0 -117
- package/dist/v4/runtime/contractQueryAcquisition.d.ts +0 -83
- package/dist/v4/runtime/contractQueryAcquisition.js +0 -572
- package/dist/v4/runtime/contractQueryClient.d.ts +0 -70
- package/dist/v4/runtime/contractQueryClient.js +0 -411
- package/dist/v4/runtime/contractQueryCodecs.d.ts +0 -20
- package/dist/v4/runtime/contractQueryCodecs.js +0 -71
- package/dist/v4/runtime/contractQueryExchange.d.ts +0 -36
- package/dist/v4/runtime/contractQueryExchange.js +0 -160
- package/dist/v4/runtime/contractQueryService.d.ts +0 -42
- package/dist/v4/runtime/contractQueryService.js +0 -572
- package/dist/v4/runtime/contractQuerySession.d.ts +0 -38
- package/dist/v4/runtime/contractQuerySession.js +0 -158
- package/dist/v4/runtime/contractRoutes.d.ts +0 -87
- package/dist/v4/runtime/contractRoutes.js +0 -396
- package/dist/v4/runtime/contractSnapshotReader.d.ts +0 -59
- package/dist/v4/runtime/contractSnapshotReader.js +0 -418
- package/dist/v4/runtime/contractSnapshotWriter.d.ts +0 -32
- package/dist/v4/runtime/contractSnapshotWriter.js +0 -208
- package/dist/v4/runtime/controllerServiceSource.d.ts +0 -23
- package/dist/v4/runtime/controllerServiceSource.js +0 -109
- package/dist/v4/runtime/controllerUnaryRoute.d.ts +0 -28
- package/dist/v4/runtime/controllerUnaryRoute.js +0 -1
- package/dist/v4/runtime/credentialNamespace.d.ts +0 -143
- package/dist/v4/runtime/credentialNamespace.js +0 -1286
- package/dist/v4/runtime/credentialSupport.d.ts +0 -60
- package/dist/v4/runtime/credentialSupport.js +0 -294
- package/dist/v4/runtime/credentialVerifier.d.ts +0 -404
- package/dist/v4/runtime/credentialVerifier.js +0 -1443
- package/dist/v4/runtime/cryptoUsage.d.ts +0 -135
- package/dist/v4/runtime/cryptoUsage.js +0 -552
- package/dist/v4/runtime/deadline.d.ts +0 -31
- package/dist/v4/runtime/deadline.js +0 -188
- package/dist/v4/runtime/diagnosticCounters.d.ts +0 -15
- package/dist/v4/runtime/diagnosticCounters.js +0 -78
- package/dist/v4/runtime/diagnosticObservation.d.ts +0 -25
- package/dist/v4/runtime/diagnosticObservation.js +0 -67
- package/dist/v4/runtime/diagnosticSink.d.ts +0 -16
- package/dist/v4/runtime/diagnosticSink.js +0 -320
- package/dist/v4/runtime/ed25519.d.ts +0 -1
- package/dist/v4/runtime/ed25519.js +0 -34
- package/dist/v4/runtime/endpointHop.d.ts +0 -12
- package/dist/v4/runtime/endpointHop.js +0 -26
- package/dist/v4/runtime/envelope.d.ts +0 -66
- package/dist/v4/runtime/envelope.js +0 -275
- package/dist/v4/runtime/environment.d.ts +0 -277
- package/dist/v4/runtime/environment.js +0 -1911
- package/dist/v4/runtime/executionManagementChannel.d.ts +0 -27
- package/dist/v4/runtime/executionManagementChannel.js +0 -733
- package/dist/v4/runtime/executionManagementCodec.d.ts +0 -84
- package/dist/v4/runtime/executionManagementCodec.js +0 -127
- package/dist/v4/runtime/executionStorage.d.ts +0 -71
- package/dist/v4/runtime/executionStorage.js +0 -10
- package/dist/v4/runtime/fixedDiagnosticExecutor.d.ts +0 -34
- package/dist/v4/runtime/fixedDiagnosticExecutor.js +0 -149
- package/dist/v4/runtime/fixedManagementExecutor.d.ts +0 -21
- package/dist/v4/runtime/fixedManagementExecutor.js +0 -153
- package/dist/v4/runtime/fixedQueryExecutor.d.ts +0 -46
- package/dist/v4/runtime/fixedQueryExecutor.js +0 -311
- package/dist/v4/runtime/grantDigest.d.ts +0 -9
- package/dist/v4/runtime/grantDigest.js +0 -31
- package/dist/v4/runtime/hopAuthentication.d.ts +0 -51
- package/dist/v4/runtime/hopAuthentication.js +0 -392
- package/dist/v4/runtime/host.d.ts +0 -15
- package/dist/v4/runtime/host.js +0 -332
- package/dist/v4/runtime/initializerWorkload.d.ts +0 -38
- package/dist/v4/runtime/initializerWorkload.js +0 -164
- package/dist/v4/runtime/lifecycle.d.ts +0 -5
- package/dist/v4/runtime/lifecycle.js +0 -17
- package/dist/v4/runtime/liveAuthorization.d.ts +0 -42
- package/dist/v4/runtime/liveAuthorization.js +0 -133
- package/dist/v4/runtime/liveAuthorizationWire.d.ts +0 -8
- package/dist/v4/runtime/liveAuthorizationWire.js +0 -31
- package/dist/v4/runtime/liveCarrierPreparation.d.ts +0 -9
- package/dist/v4/runtime/liveCarrierPreparation.js +0 -27
- package/dist/v4/runtime/liveness.d.ts +0 -37
- package/dist/v4/runtime/liveness.js +0 -319
- package/dist/v4/runtime/maintenancePositions.d.ts +0 -29
- package/dist/v4/runtime/maintenancePositions.js +0 -152
- package/dist/v4/runtime/messageCodec.d.ts +0 -20
- package/dist/v4/runtime/messageCodec.js +0 -192
- package/dist/v4/runtime/namespaceContinuity.d.ts +0 -20
- package/dist/v4/runtime/namespaceContinuity.js +0 -176
- package/dist/v4/runtime/nativeCandidates.d.ts +0 -18
- package/dist/v4/runtime/nativeCandidates.js +0 -109
- package/dist/v4/runtime/nativeFailure.d.ts +0 -10
- package/dist/v4/runtime/nativeFailure.js +0 -32
- package/dist/v4/runtime/nativeFrame.d.ts +0 -47
- package/dist/v4/runtime/nativeFrame.js +0 -318
- package/dist/v4/runtime/nativeIngress.d.ts +0 -30
- package/dist/v4/runtime/nativeIngress.js +0 -177
- package/dist/v4/runtime/nativePositions.d.ts +0 -24
- package/dist/v4/runtime/nativePositions.js +0 -131
- package/dist/v4/runtime/nativeProviderPositions.d.ts +0 -16
- package/dist/v4/runtime/nativeProviderPositions.js +0 -75
- package/dist/v4/runtime/nativeSend.d.ts +0 -15
- package/dist/v4/runtime/nativeSend.js +0 -57
- package/dist/v4/runtime/noiseHandshake.d.ts +0 -70
- package/dist/v4/runtime/noiseHandshake.js +0 -373
- package/dist/v4/runtime/noiseWasmBinary.d.ts +0 -2
- package/dist/v4/runtime/noiseWasmBinary.js +0 -3
- package/dist/v4/runtime/notifyChannel.d.ts +0 -37
- package/dist/v4/runtime/notifyChannel.js +0 -277
- package/dist/v4/runtime/notifyDispatch.d.ts +0 -108
- package/dist/v4/runtime/notifyDispatch.js +0 -717
- package/dist/v4/runtime/notifyExecution.d.ts +0 -18
- package/dist/v4/runtime/notifyExecution.js +0 -59
- package/dist/v4/runtime/notifyPreparation.d.ts +0 -70
- package/dist/v4/runtime/notifyPreparation.js +0 -465
- package/dist/v4/runtime/openAdmission.d.ts +0 -125
- package/dist/v4/runtime/openAdmission.js +0 -810
- package/dist/v4/runtime/peerOpenPreparation.d.ts +0 -18
- package/dist/v4/runtime/peerOpenPreparation.js +0 -61
- package/dist/v4/runtime/poolJournal.d.ts +0 -18
- package/dist/v4/runtime/poolJournal.js +0 -14
- package/dist/v4/runtime/poolJournalStorage.d.ts +0 -4
- package/dist/v4/runtime/poolJournalStorage.js +0 -172
- package/dist/v4/runtime/poolRecord.d.ts +0 -9
- package/dist/v4/runtime/poolRecord.js +0 -23
- package/dist/v4/runtime/poolRecordStorage.d.ts +0 -10
- package/dist/v4/runtime/poolRecordStorage.js +0 -216
- package/dist/v4/runtime/poolServerAllow.d.ts +0 -49
- package/dist/v4/runtime/poolServerAllow.js +0 -38
- package/dist/v4/runtime/poolSpend.d.ts +0 -20
- package/dist/v4/runtime/poolSpend.js +0 -4
- package/dist/v4/runtime/queryRenewalPosition.d.ts +0 -59
- package/dist/v4/runtime/queryRenewalPosition.js +0 -220
- package/dist/v4/runtime/random.d.ts +0 -15
- package/dist/v4/runtime/random.js +0 -71
- package/dist/v4/runtime/rawStreamPreparation.d.ts +0 -40
- package/dist/v4/runtime/rawStreamPreparation.js +0 -125
- package/dist/v4/runtime/receiveDirection.d.ts +0 -135
- package/dist/v4/runtime/receiveDirection.js +0 -957
- package/dist/v4/runtime/receiveWorkspace.d.ts +0 -19
- package/dist/v4/runtime/receiveWorkspace.js +0 -82
- package/dist/v4/runtime/record.d.ts +0 -7
- package/dist/v4/runtime/record.js +0 -173
- package/dist/v4/runtime/recordCrypto.d.ts +0 -121
- package/dist/v4/runtime/recordCrypto.js +0 -633
- package/dist/v4/runtime/recordWorkspace.d.ts +0 -17
- package/dist/v4/runtime/recordWorkspace.js +0 -69
- package/dist/v4/runtime/registeredCarrierPreparation.d.ts +0 -17
- package/dist/v4/runtime/registeredCarrierPreparation.js +0 -191
- package/dist/v4/runtime/rekey.d.ts +0 -40
- package/dist/v4/runtime/rekey.js +0 -362
- package/dist/v4/runtime/relayCredentials.d.ts +0 -126
- package/dist/v4/runtime/relayCredentials.js +0 -349
- package/dist/v4/runtime/replayWindow.d.ts +0 -6
- package/dist/v4/runtime/replayWindow.js +0 -59
- package/dist/v4/runtime/resources.d.ts +0 -200
- package/dist/v4/runtime/resources.js +0 -1236
- package/dist/v4/runtime/resumeCodec.d.ts +0 -44
- package/dist/v4/runtime/resumeCodec.js +0 -192
- package/dist/v4/runtime/resumeStream.d.ts +0 -23
- package/dist/v4/runtime/resumeStream.js +0 -23
- package/dist/v4/runtime/rpcApplication.d.ts +0 -234
- package/dist/v4/runtime/rpcApplication.js +0 -2170
- package/dist/v4/runtime/rpcApplicationServices.d.ts +0 -18
- package/dist/v4/runtime/rpcApplicationServices.js +0 -62
- package/dist/v4/runtime/rpcCallCapacity.d.ts +0 -62
- package/dist/v4/runtime/rpcCallCapacity.js +0 -289
- package/dist/v4/runtime/rpcChannel.d.ts +0 -58
- package/dist/v4/runtime/rpcChannel.js +0 -334
- package/dist/v4/runtime/rpcCompletion.d.ts +0 -42
- package/dist/v4/runtime/rpcCompletion.js +0 -152
- package/dist/v4/runtime/rpcEventSource.d.ts +0 -27
- package/dist/v4/runtime/rpcEventSource.js +0 -201
- package/dist/v4/runtime/rpcFragment.d.ts +0 -42
- package/dist/v4/runtime/rpcFragment.js +0 -227
- package/dist/v4/runtime/rpcInput.d.ts +0 -41
- package/dist/v4/runtime/rpcInput.js +0 -137
- package/dist/v4/runtime/rpcNetwork.d.ts +0 -143
- package/dist/v4/runtime/rpcNetwork.js +0 -652
- package/dist/v4/runtime/rpcOutputInterest.d.ts +0 -20
- package/dist/v4/runtime/rpcOutputInterest.js +0 -106
- package/dist/v4/runtime/rpcPayload.d.ts +0 -24
- package/dist/v4/runtime/rpcPayload.js +0 -82
- package/dist/v4/runtime/rpcPreacceptedStreams.d.ts +0 -46
- package/dist/v4/runtime/rpcPreacceptedStreams.js +0 -406
- package/dist/v4/runtime/rpcPublisher.d.ts +0 -49
- package/dist/v4/runtime/rpcPublisher.js +0 -406
- package/dist/v4/runtime/rpcReceiver.d.ts +0 -40
- package/dist/v4/runtime/rpcReceiver.js +0 -255
- package/dist/v4/runtime/rpcResumeDispatch.d.ts +0 -46
- package/dist/v4/runtime/rpcResumeDispatch.js +0 -266
- package/dist/v4/runtime/rpcStream.d.ts +0 -14
- package/dist/v4/runtime/rpcStream.js +0 -12
- package/dist/v4/runtime/rpcStreamMessages.d.ts +0 -53
- package/dist/v4/runtime/rpcStreamMessages.js +0 -428
- package/dist/v4/runtime/rpcStreamPreparation.d.ts +0 -21
- package/dist/v4/runtime/rpcStreamPreparation.js +0 -110
- package/dist/v4/runtime/rpcStreamingDispatch.d.ts +0 -26
- package/dist/v4/runtime/rpcStreamingDispatch.js +0 -607
- package/dist/v4/runtime/rpcStreamingExchange.d.ts +0 -91
- package/dist/v4/runtime/rpcStreamingExchange.js +0 -812
- package/dist/v4/runtime/rpcUnaryCall.d.ts +0 -16
- package/dist/v4/runtime/rpcUnaryCall.js +0 -152
- package/dist/v4/runtime/rpcUnaryDispatch.d.ts +0 -34
- package/dist/v4/runtime/rpcUnaryDispatch.js +0 -569
- package/dist/v4/runtime/rpcUnaryExchange.d.ts +0 -127
- package/dist/v4/runtime/rpcUnaryExchange.js +0 -1042
- package/dist/v4/runtime/rpcUnaryPreparation.d.ts +0 -102
- package/dist/v4/runtime/rpcUnaryPreparation.js +0 -736
- package/dist/v4/runtime/rpcUnaryRegistration.d.ts +0 -33
- package/dist/v4/runtime/rpcUnaryRegistration.js +0 -113
- package/dist/v4/runtime/rpcUnaryResultRecipient.d.ts +0 -21
- package/dist/v4/runtime/rpcUnaryResultRecipient.js +0 -57
- package/dist/v4/runtime/schema.d.ts +0 -26
- package/dist/v4/runtime/schema.js +0 -668
- package/dist/v4/runtime/schemaRegistry.d.ts +0 -128
- package/dist/v4/runtime/schemaRegistry.js +0 -74
- package/dist/v4/runtime/sendBudget.d.ts +0 -10
- package/dist/v4/runtime/sendBudget.js +0 -46
- package/dist/v4/runtime/serveGroup.d.ts +0 -73
- package/dist/v4/runtime/serveGroup.js +0 -589
- package/dist/v4/runtime/serverAdmission.d.ts +0 -33
- package/dist/v4/runtime/serverAdmission.js +0 -342
- package/dist/v4/runtime/serverAdmissionAuthority.d.ts +0 -23
- package/dist/v4/runtime/serverAdmissionAuthority.js +0 -5
- package/dist/v4/runtime/serverSessionSpec.d.ts +0 -9
- package/dist/v4/runtime/serverSessionSpec.js +0 -12
- package/dist/v4/runtime/serviceBinding.d.ts +0 -128
- package/dist/v4/runtime/serviceBinding.js +0 -1435
- package/dist/v4/runtime/serviceBindingConfig.d.ts +0 -72
- package/dist/v4/runtime/serviceBindingConfig.js +0 -85
- package/dist/v4/runtime/serviceBindingPool.d.ts +0 -58
- package/dist/v4/runtime/serviceBindingPool.js +0 -327
- package/dist/v4/runtime/serviceContract.d.ts +0 -111
- package/dist/v4/runtime/serviceContract.js +0 -588
- package/dist/v4/runtime/serviceInputs.d.ts +0 -30
- package/dist/v4/runtime/serviceInputs.js +0 -201
- package/dist/v4/runtime/serviceOfferPlan.d.ts +0 -81
- package/dist/v4/runtime/serviceOfferPlan.js +0 -335
- package/dist/v4/runtime/serviceOfferScheduler.d.ts +0 -12
- package/dist/v4/runtime/serviceOfferScheduler.js +0 -201
- package/dist/v4/runtime/serviceOfferWork.d.ts +0 -25
- package/dist/v4/runtime/serviceOfferWork.js +0 -1
- package/dist/v4/runtime/session.d.ts +0 -411
- package/dist/v4/runtime/session.js +0 -6369
- package/dist/v4/runtime/sessionActivity.d.ts +0 -19
- package/dist/v4/runtime/sessionActivity.js +0 -97
- package/dist/v4/runtime/sessionAdmission.d.ts +0 -93
- package/dist/v4/runtime/sessionAdmission.js +0 -498
- package/dist/v4/runtime/sessionCleanup.d.ts +0 -47
- package/dist/v4/runtime/sessionCleanup.js +0 -268
- package/dist/v4/runtime/sessionKeyPreparation.d.ts +0 -19
- package/dist/v4/runtime/sessionKeyPreparation.js +0 -50
- package/dist/v4/runtime/signedMap.d.ts +0 -68
- package/dist/v4/runtime/signedMap.js +0 -425
- package/dist/v4/runtime/streamAdapter.d.ts +0 -113
- package/dist/v4/runtime/streamAdapter.js +0 -62
- package/dist/v4/runtime/streamData.d.ts +0 -11
- package/dist/v4/runtime/streamData.js +0 -50
- package/dist/v4/runtime/streamOpenPreparation.d.ts +0 -23
- package/dist/v4/runtime/streamOpenPreparation.js +0 -77
- package/dist/v4/runtime/streamRegistration.d.ts +0 -87
- package/dist/v4/runtime/streamRegistration.js +0 -296
- package/dist/v4/runtime/taskObservation.d.ts +0 -1
- package/dist/v4/runtime/taskObservation.js +0 -48
- package/dist/v4/runtime/timeArithmetic.d.ts +0 -29
- package/dist/v4/runtime/timeArithmetic.js +0 -107
- package/dist/v4/runtime/unreliable.d.ts +0 -76
- package/dist/v4/runtime/unreliable.js +0 -473
- package/dist/v4/runtime/volatileExecutions.d.ts +0 -128
- package/dist/v4/runtime/volatileExecutions.js +0 -792
- package/dist/v4/runtime/wireRegistry.d.ts +0 -52
- package/dist/v4/runtime/wireRegistry.js +0 -29
- package/dist/v4/runtime/writeRequest.d.ts +0 -42
- package/dist/v4/runtime/writeRequest.js +0 -237
- package/dist/v4/serve.d.ts +0 -107
- package/dist/v4/serve.js +0 -80
- package/dist/v4/serviceClient.d.ts +0 -92
- package/dist/v4/serviceClient.js +0 -323
- package/dist/v4/serviceDefinition.d.ts +0 -138
- package/dist/v4/serviceDefinition.js +0 -150
- package/dist/v4/serviceDependencies.d.ts +0 -66
- package/dist/v4/serviceDependencies.js +0 -250
- package/dist/v4/serviceFactory.d.ts +0 -31
- package/dist/v4/serviceFactory.js +0 -157
- package/dist/v4/serviceHandlers.d.ts +0 -55
- package/dist/v4/serviceHandlers.js +0 -15
- package/dist/v4/serviceMembers.d.ts +0 -4
- package/dist/v4/serviceMembers.js +0 -12
- package/dist/v4/staticServiceContracts.d.ts +0 -43
- package/dist/v4/staticServiceContracts.js +0 -161
- package/dist/v4/storageFormat.d.ts +0 -16
- package/dist/v4/storageFormat.js +0 -5
- package/dist/v4/streamContent.d.ts +0 -30
- package/dist/v4/streamContent.js +0 -29
- package/dist/v4/streamHandlers.d.ts +0 -61
- package/dist/v4/streamHandlers.js +0 -16
- package/dist/v4/streamingOperation.d.ts +0 -64
- package/dist/v4/streamingOperation.js +0 -141
- package/dist/v4/strictEd25519Reference.d.ts +0 -2
- package/dist/v4/strictEd25519Reference.js +0 -37
- package/dist/v4/testSupport/cbor.d.ts +0 -124
- package/dist/v4/testSupport/cbor.js +0 -230
- package/dist/v4/testSupport/credentials.d.ts +0 -55
- package/dist/v4/testSupport/credentials.js +0 -111
- package/dist/v4/testSupport/unicode.d.ts +0 -19
- package/dist/v4/testSupport/unicode.js +0 -112
- package/dist/v4/unaryOperation.d.ts +0 -59
- package/dist/v4/unaryOperation.js +0 -80
- package/dist/v4/unreliable.d.ts +0 -26
- package/dist/v4/unreliable.js +0 -10
- package/dist/v4/webStreams.d.ts +0 -30
- package/dist/v4/webStreams.js +0 -377
- /package/dist/{interop/proxyServerPeer.d.ts → rpc/wire.js} +0 -0
- /package/dist/{node/sqlitePoolWorkerProgramV4.d.ts → v3/publicSession.d.ts} +0 -0
- /package/dist/{node/sqliteWorkerProgramV4.d.ts → v3/streamMetadata.d.ts} +0 -0
|
@@ -1,957 +0,0 @@
|
|
|
1
|
-
import { V4ReadMethodError } from "../public.js";
|
|
2
|
-
import { CBORDecoder, CBORWireError, cborDecoderCharge, byteSlice } from "./cbor.js";
|
|
3
|
-
import { timerChunk } from "./deadline.js";
|
|
4
|
-
import { ResourceError, ResourceVector } from "./resources.js";
|
|
5
|
-
import { SchemaValidationError } from "./schema.js";
|
|
6
|
-
import { TimeError } from "./timeArithmetic.js";
|
|
7
|
-
import { wire } from "./wireRegistry.js";
|
|
8
|
-
import { ReceiveWorkspace } from "./receiveWorkspace.js";
|
|
9
|
-
const token = Symbol("receive direction owner");
|
|
10
|
-
const empty = new Uint8Array();
|
|
11
|
-
const copy = Uint8Array.prototype.set;
|
|
12
|
-
const reverse = Uint8Array.prototype.reverse;
|
|
13
|
-
const NativeBytes = Uint8Array;
|
|
14
|
-
const NativePromise = Promise;
|
|
15
|
-
const enqueueReadJob = queueMicrotask;
|
|
16
|
-
const uint64Max = (1n << 64n) - 1n;
|
|
17
|
-
const complete = Object.freeze({ status: "complete", core_cleanup: "complete", pending_callbacks: 0n });
|
|
18
|
-
const pending = Object.freeze({ status: "pending", core_cleanup: "pending", pending_callbacks: 0n });
|
|
19
|
-
export class ReceiveError extends Error {
|
|
20
|
-
code;
|
|
21
|
-
constructor(code) {
|
|
22
|
-
super(code);
|
|
23
|
-
this.code = code;
|
|
24
|
-
this.name = "ReceiveError";
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function fail(code) { throw new ReceiveError(code); }
|
|
28
|
-
function quantity(n) {
|
|
29
|
-
if (typeof n !== "bigint" || n < 0n || n > uint64Max)
|
|
30
|
-
fail("configuration_capacity");
|
|
31
|
-
return n;
|
|
32
|
-
}
|
|
33
|
-
function size(n) {
|
|
34
|
-
if (!Number.isSafeInteger(n) || n < 1 || n > 0x7fffffff)
|
|
35
|
-
fail("configuration_capacity");
|
|
36
|
-
return n;
|
|
37
|
-
}
|
|
38
|
-
function vector(bytes, items = 1n, work = 1n, tasks = 0n) {
|
|
39
|
-
return new ResourceVector([bytes, 0n, 0n, items, work, tasks, 0n, 0n, 0n, 0n, 0n]);
|
|
40
|
-
}
|
|
41
|
-
export function receiveDeliveryCharge(runtimeBytes) {
|
|
42
|
-
if (quantity(runtimeBytes) === 0n)
|
|
43
|
-
fail("configuration_capacity");
|
|
44
|
-
return new ResourceVector([runtimeBytes, 0n, 0n, 1n, 1n, 1n, 1n, 0n, 0n, 0n, 0n]);
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* Original result authorization, separate from normal Session I/O shutdown.
|
|
48
|
-
* The admission/security owner supplies the captured trusted deadline and closes
|
|
49
|
-
* this gate on revocation, authorization termination or Environment.Close.
|
|
50
|
-
* Its reservation must belong to that safety lifetime, not a short I/O scope.
|
|
51
|
-
*/
|
|
52
|
-
export class ReceiveDeliveryGate {
|
|
53
|
-
#deadline;
|
|
54
|
-
#reservation;
|
|
55
|
-
#reason;
|
|
56
|
-
#authorization;
|
|
57
|
-
#authorizationRelease;
|
|
58
|
-
#authorizationRemaining;
|
|
59
|
-
#authorizationObserver;
|
|
60
|
-
#timer;
|
|
61
|
-
#retiring = false;
|
|
62
|
-
#closing = false;
|
|
63
|
-
#cleaned;
|
|
64
|
-
#leases = new Set();
|
|
65
|
-
constructor(deadline, runtimeBytes, reservation) {
|
|
66
|
-
deadline.check();
|
|
67
|
-
this.#deadline = deadline;
|
|
68
|
-
this.#reservation = reservation.take(receiveDeliveryCharge(runtimeBytes));
|
|
69
|
-
Object.freeze(this);
|
|
70
|
-
}
|
|
71
|
-
constrainAuthorization(check, original, release, remainingMS, observe) {
|
|
72
|
-
this.check(token);
|
|
73
|
-
if (this.#authorization !== undefined || !this.#reservation.sameEnvironment(original))
|
|
74
|
-
fail("receive_owner");
|
|
75
|
-
check();
|
|
76
|
-
this.#authorization = check;
|
|
77
|
-
this.#authorizationRelease = release;
|
|
78
|
-
this.#authorizationRemaining = remainingMS;
|
|
79
|
-
this.#authorizationObserver = observe?.(() => {
|
|
80
|
-
if (!this.#retiring || this.#reason !== undefined)
|
|
81
|
-
return;
|
|
82
|
-
if (this.#timer !== undefined)
|
|
83
|
-
clearTimeout(this.#timer);
|
|
84
|
-
this.#timer = undefined;
|
|
85
|
-
this.#armAuthorization();
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
retain(directionReservation, closed) {
|
|
89
|
-
this.check(token);
|
|
90
|
-
if (this.#retiring)
|
|
91
|
-
throw new V4ReadMethodError("closed");
|
|
92
|
-
if (!this.#reservation.sameEnvironment(directionReservation))
|
|
93
|
-
fail("receive_owner");
|
|
94
|
-
const reservation = this.#reservation.borrow();
|
|
95
|
-
const lease = new ReceiveDeliveryLease(token, this, reservation, closed);
|
|
96
|
-
this.#leases.add(lease);
|
|
97
|
-
return lease;
|
|
98
|
-
}
|
|
99
|
-
check(capability) {
|
|
100
|
-
if (capability !== token)
|
|
101
|
-
fail("receive_owner");
|
|
102
|
-
if (this.#reason !== undefined)
|
|
103
|
-
throw new V4ReadMethodError(this.#reason);
|
|
104
|
-
try {
|
|
105
|
-
this.#reservation.check();
|
|
106
|
-
}
|
|
107
|
-
catch {
|
|
108
|
-
this.close();
|
|
109
|
-
throw new V4ReadMethodError("closed");
|
|
110
|
-
}
|
|
111
|
-
try {
|
|
112
|
-
this.#deadline.check();
|
|
113
|
-
this.#authorization?.();
|
|
114
|
-
}
|
|
115
|
-
catch (error) {
|
|
116
|
-
if (error instanceof TimeError && ["time_unavailable", "time_pending", "time_continuity"].includes(error.code)) {
|
|
117
|
-
throw new V4ReadMethodError(error.code === "time_pending" ? "time_pending" : "time_unavailable");
|
|
118
|
-
}
|
|
119
|
-
this.close("authorization_denied");
|
|
120
|
-
throw new V4ReadMethodError("authorization_denied");
|
|
121
|
-
}
|
|
122
|
-
if (this.#reason !== undefined)
|
|
123
|
-
throw new V4ReadMethodError(this.#reason);
|
|
124
|
-
}
|
|
125
|
-
release(capability, lease) {
|
|
126
|
-
if (capability !== token || !this.#leases.delete(lease))
|
|
127
|
-
fail("receive_owner");
|
|
128
|
-
if (this.#retiring && this.#leases.size === 0)
|
|
129
|
-
this.close();
|
|
130
|
-
this.#notifyCleanup();
|
|
131
|
-
}
|
|
132
|
-
onCleanup(callback) { if (this.#cleaned !== undefined)
|
|
133
|
-
fail("receive_owner"); this.#cleaned = callback; this.#notifyCleanup(); }
|
|
134
|
-
#notifyCleanup() {
|
|
135
|
-
if (this.#closing || this.#reason === undefined || this.#leases.size !== 0)
|
|
136
|
-
return;
|
|
137
|
-
const callback = this.#cleaned;
|
|
138
|
-
this.#cleaned = undefined;
|
|
139
|
-
callback?.();
|
|
140
|
-
}
|
|
141
|
-
/** Normal I/O shutdown leaves existing complete candidates authorized. */
|
|
142
|
-
retire() {
|
|
143
|
-
if (this.#retiring || this.#reason !== undefined)
|
|
144
|
-
return;
|
|
145
|
-
this.#retiring = true;
|
|
146
|
-
if (this.#leases.size === 0)
|
|
147
|
-
this.close();
|
|
148
|
-
else
|
|
149
|
-
this.#armAuthorization();
|
|
150
|
-
}
|
|
151
|
-
#armAuthorization() {
|
|
152
|
-
if (this.#reason !== undefined)
|
|
153
|
-
return;
|
|
154
|
-
let remaining;
|
|
155
|
-
try {
|
|
156
|
-
this.check(token);
|
|
157
|
-
const session = this.#deadline.remainingMS(), authorization = this.#authorizationRemaining?.() ?? session;
|
|
158
|
-
remaining = authorization < session ? authorization : session;
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
if (this.#reason !== undefined)
|
|
162
|
-
return;
|
|
163
|
-
// Loss of a usable clock suspends delivery. A wake retries the original
|
|
164
|
-
// deadlines; it neither expires a result speculatively nor renews it.
|
|
165
|
-
if (error instanceof V4ReadMethodError && ["time_pending", "time_unavailable"].includes(error.reason) ||
|
|
166
|
-
error instanceof TimeError && ["time_pending", "time_unavailable", "time_continuity"].includes(error.code))
|
|
167
|
-
remaining = 1000n;
|
|
168
|
-
else {
|
|
169
|
-
this.close("authorization_denied");
|
|
170
|
-
return;
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
if (this.#reason === undefined)
|
|
174
|
-
this.#timer = setTimeout(() => { this.#timer = undefined; this.#armAuthorization(); }, timerChunk(remaining));
|
|
175
|
-
}
|
|
176
|
-
close(reason = "closed") {
|
|
177
|
-
if (this.#reason !== undefined)
|
|
178
|
-
return;
|
|
179
|
-
this.#reason = reason;
|
|
180
|
-
this.#closing = true;
|
|
181
|
-
if (this.#timer !== undefined)
|
|
182
|
-
clearTimeout(this.#timer);
|
|
183
|
-
this.#timer = undefined;
|
|
184
|
-
this.#reservation?.seal();
|
|
185
|
-
for (const lease of this.#leases)
|
|
186
|
-
lease.notifyClosed();
|
|
187
|
-
this.#reservation?.release();
|
|
188
|
-
this.#reservation = undefined;
|
|
189
|
-
this.#deadline = undefined;
|
|
190
|
-
this.#authorization = undefined;
|
|
191
|
-
this.#authorizationRemaining = undefined;
|
|
192
|
-
this.#authorizationObserver?.();
|
|
193
|
-
this.#authorizationObserver = undefined;
|
|
194
|
-
const release = this.#authorizationRelease;
|
|
195
|
-
this.#authorizationRelease = undefined;
|
|
196
|
-
release?.();
|
|
197
|
-
this.#closing = false;
|
|
198
|
-
this.#notifyCleanup();
|
|
199
|
-
}
|
|
200
|
-
cleanupStatus() { return !this.#closing && this.#reason !== undefined && this.#leases.size === 0 ? complete : pending; }
|
|
201
|
-
}
|
|
202
|
-
class ReceiveDeliveryLease {
|
|
203
|
-
#gate;
|
|
204
|
-
#reservation;
|
|
205
|
-
#closed;
|
|
206
|
-
constructor(capability, gate, reservation, closed) {
|
|
207
|
-
if (capability !== token)
|
|
208
|
-
fail("receive_owner");
|
|
209
|
-
this.#gate = gate;
|
|
210
|
-
this.#reservation = reservation;
|
|
211
|
-
this.#closed = closed;
|
|
212
|
-
}
|
|
213
|
-
check() {
|
|
214
|
-
if (this.#gate === undefined)
|
|
215
|
-
throw new V4ReadMethodError("closed");
|
|
216
|
-
this.#reservation.checkRetained();
|
|
217
|
-
this.#gate.check(token);
|
|
218
|
-
}
|
|
219
|
-
notifyClosed() { this.#closed?.(); }
|
|
220
|
-
release() {
|
|
221
|
-
if (this.#gate === undefined)
|
|
222
|
-
return;
|
|
223
|
-
this.#reservation.release();
|
|
224
|
-
this.#gate.release(token, this);
|
|
225
|
-
this.#gate = undefined;
|
|
226
|
-
this.#reservation = undefined;
|
|
227
|
-
this.#closed = undefined;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
function capture(c) {
|
|
231
|
-
const maxDataBytes = size(c.maxDataBytes), queueBytes = size(c.queueBytes), maxCursorBytes = size(c.maxCursorBytes);
|
|
232
|
-
const receiveLimit = quantity(c.receiveLimit), runtimeBytes = quantity(c.runtimeBytes);
|
|
233
|
-
const cursorRuntimeBytes = quantity(c.cursorRuntimeBytes), decoderRuntimeBytes = quantity(c.decoderRuntimeBytes);
|
|
234
|
-
if (maxDataBytes > wire.resource_caps.max_payload_length - 100 || receiveLimit > BigInt(queueBytes) ||
|
|
235
|
-
runtimeBytes === 0n || cursorRuntimeBytes === 0n || decoderRuntimeBytes === 0n)
|
|
236
|
-
fail("configuration_capacity");
|
|
237
|
-
const workspace = c.workspace;
|
|
238
|
-
if (workspace !== undefined && !(workspace instanceof ReceiveWorkspace))
|
|
239
|
-
fail("configuration_capacity");
|
|
240
|
-
return Object.freeze({ maxDataBytes, queueBytes, maxCursorBytes, receiveLimit, runtimeBytes,
|
|
241
|
-
cursorRuntimeBytes, decoderRuntimeBytes, plaintextBytes: workspace?.maxPlainBytes ?? maxDataBytes + 64,
|
|
242
|
-
...(workspace === undefined ? {} : { workspace }) });
|
|
243
|
-
}
|
|
244
|
-
function decoderConfig(c) {
|
|
245
|
-
return { bytes: c.plaintextBytes, nodes: 15, textBytes: 0, arrayItems: 1, runtimeBytes: c.decoderRuntimeBytes };
|
|
246
|
-
}
|
|
247
|
-
export function receiveDirectionCharge(config) {
|
|
248
|
-
const c = capture(config);
|
|
249
|
-
return vector(BigInt(c.queueBytes + (c.workspace === undefined ? c.plaintextBytes : 0)) + c.runtimeBytes, 1n, 1n, 1n);
|
|
250
|
-
}
|
|
251
|
-
export function receiveCursorCharge(config) {
|
|
252
|
-
const c = capture(config);
|
|
253
|
-
return vector(BigInt(c.maxCursorBytes) + c.cursorRuntimeBytes, 1n, 1n, 1n);
|
|
254
|
-
}
|
|
255
|
-
export function receiveDecoderCharge(config) {
|
|
256
|
-
const c = capture(config);
|
|
257
|
-
return c.workspace === undefined ? cborDecoderCharge(decoderConfig(c)) : vector(64n + c.decoderRuntimeBytes, 1n, 0n);
|
|
258
|
-
}
|
|
259
|
-
/**
|
|
260
|
-
* One real authenticated receive queue. Ordinary reads and public ReaderCursor
|
|
261
|
-
* share its direction claim, bytes, resource root and result authorization.
|
|
262
|
-
* This component does not establish OPEN/READY or publish maintenance credit.
|
|
263
|
-
* The configured limit is fixed until that Session machinery supplies a real
|
|
264
|
-
* authenticated credit publication path; consumed bytes are never self-granted.
|
|
265
|
-
*/
|
|
266
|
-
export class ReliableReceiveDirection {
|
|
267
|
-
released;
|
|
268
|
-
settled;
|
|
269
|
-
#config;
|
|
270
|
-
#cipher;
|
|
271
|
-
#binding;
|
|
272
|
-
#reservation;
|
|
273
|
-
#cursorReservation;
|
|
274
|
-
#borrowedCursor = false;
|
|
275
|
-
#decoder;
|
|
276
|
-
#workspaceReference;
|
|
277
|
-
#workspaceRelease;
|
|
278
|
-
#delivery;
|
|
279
|
-
#ring = empty;
|
|
280
|
-
#queueReference;
|
|
281
|
-
#bodyQueue;
|
|
282
|
-
#scratch = empty;
|
|
283
|
-
#head = 0;
|
|
284
|
-
#queued = 0;
|
|
285
|
-
#ack = 0n;
|
|
286
|
-
#receiveLimit = 0n;
|
|
287
|
-
#released = 0n;
|
|
288
|
-
#creditPaused = false;
|
|
289
|
-
#fin;
|
|
290
|
-
#terminal;
|
|
291
|
-
#active;
|
|
292
|
-
#wait;
|
|
293
|
-
#working = false;
|
|
294
|
-
#pumpQueued = false;
|
|
295
|
-
#abandoned = false;
|
|
296
|
-
#closed = false;
|
|
297
|
-
#nativeClaims = [];
|
|
298
|
-
constructor(config, cipher, delivery, reservations, released, settled) {
|
|
299
|
-
this.released = released;
|
|
300
|
-
this.settled = settled;
|
|
301
|
-
const c = capture(config);
|
|
302
|
-
const { root, direction, decoder, cursor } = reservations;
|
|
303
|
-
if (!direction.sameEnvironment(decoder) || !direction.sameEnvironment(cursor))
|
|
304
|
-
fail("receive_owner");
|
|
305
|
-
this.#binding = cipher.receiveBinding(direction);
|
|
306
|
-
this.#config = c;
|
|
307
|
-
this.#receiveLimit = c.receiveLimit;
|
|
308
|
-
this.#cipher = cipher;
|
|
309
|
-
this.#reservation = direction.take(receiveDirectionCharge(c));
|
|
310
|
-
try {
|
|
311
|
-
this.#delivery = delivery.retain(this.#reservation, () => this.close());
|
|
312
|
-
if (reservations.cursorPosition === undefined)
|
|
313
|
-
this.#cursorReservation = root.protect(cursor, receiveCursorCharge(c));
|
|
314
|
-
else {
|
|
315
|
-
if (!reservations.cursorPosition.sameEnvironment(cursor))
|
|
316
|
-
fail("receive_owner");
|
|
317
|
-
this.#cursorReservation = reservations.cursorPosition;
|
|
318
|
-
this.#borrowedCursor = true;
|
|
319
|
-
cursor.release();
|
|
320
|
-
}
|
|
321
|
-
if (c.workspace === undefined) {
|
|
322
|
-
this.#decoder = new CBORDecoder(decoderConfig(c), decoder);
|
|
323
|
-
this.#scratch = new Uint8Array(c.plaintextBytes);
|
|
324
|
-
}
|
|
325
|
-
else {
|
|
326
|
-
this.#workspaceReference = decoder.take(receiveDecoderCharge(c));
|
|
327
|
-
this.#workspaceRelease = c.workspace.retain(this.#workspaceReference);
|
|
328
|
-
}
|
|
329
|
-
this.#ring = new Uint8Array(c.queueBytes);
|
|
330
|
-
}
|
|
331
|
-
catch (error) {
|
|
332
|
-
this.close();
|
|
333
|
-
throw error;
|
|
334
|
-
}
|
|
335
|
-
Object.freeze(this);
|
|
336
|
-
}
|
|
337
|
-
progress() {
|
|
338
|
-
return Object.freeze({ ack_offset: this.#ack, released_offset: this.#released,
|
|
339
|
-
receive_limit: this.#receiveLimit, queued_bytes: BigInt(this.#queued),
|
|
340
|
-
...(this.#fin === undefined ? {} : { fin_offset: this.#fin }) });
|
|
341
|
-
}
|
|
342
|
-
claimNative(bytes, payloadClaim, prefetch = false) {
|
|
343
|
-
this.#checkIngress();
|
|
344
|
-
if (this.#nativeClaims.length >= 2 || !prefetch && this.#nativeClaims.some(value => !value.validated) ||
|
|
345
|
-
this.#fin !== undefined || !Number.isSafeInteger(bytes) || bytes < 0 || payloadClaim < BigInt(bytes))
|
|
346
|
-
fail("receive_credit");
|
|
347
|
-
let start = this.#ack;
|
|
348
|
-
for (const state of this.#nativeClaims)
|
|
349
|
-
if (!state.validated && state.end > start)
|
|
350
|
-
start = state.end;
|
|
351
|
-
// Conservative gaps left by a preceding claim stay in the original paid
|
|
352
|
-
// ring. Lack of space disables overlap; it never rejects a legal next frame.
|
|
353
|
-
if (start > this.#receiveLimit || payloadClaim > this.#receiveLimit - start) {
|
|
354
|
-
if (prefetch)
|
|
355
|
-
return undefined;
|
|
356
|
-
fail("receive_credit");
|
|
357
|
-
}
|
|
358
|
-
const body = this.#bodyQueue;
|
|
359
|
-
let segments;
|
|
360
|
-
if (body !== undefined) {
|
|
361
|
-
const offset = start - body.start;
|
|
362
|
-
if (offset < 0n || BigInt(bytes) > body.end - start)
|
|
363
|
-
fail("receive_credit");
|
|
364
|
-
segments = [byteSlice(body.bytes, Number(offset), Number(offset) + bytes)];
|
|
365
|
-
}
|
|
366
|
-
else {
|
|
367
|
-
if (start < this.#released || start - this.#released + BigInt(bytes) > BigInt(this.#ring.length))
|
|
368
|
-
fail("receive_credit");
|
|
369
|
-
const at = this.#ring.length === 0 ? 0 : (this.#head + Number(start - this.#released)) % this.#ring.length;
|
|
370
|
-
const first = Math.min(bytes, this.#ring.length - at);
|
|
371
|
-
segments = [byteSlice(this.#ring, at, at + first), byteSlice(this.#ring, 0, bytes - first)];
|
|
372
|
-
}
|
|
373
|
-
// The direction already owns this exact backing reference before granting
|
|
374
|
-
// credit, including the retained alias of a transferred message body. Lend
|
|
375
|
-
// that owner to its bounded native claims; do not allocate a fresh
|
|
376
|
-
// root alias under memory pressure after the promise has been published.
|
|
377
|
-
const reference = body?.reference ?? this.#queueReference ?? this.#reservation;
|
|
378
|
-
reference.checkRetained();
|
|
379
|
-
let released = false;
|
|
380
|
-
const claim = {
|
|
381
|
-
get segments() { if (released)
|
|
382
|
-
fail("receive_owner"); return segments; },
|
|
383
|
-
check: () => { if (released || !this.#nativeClaims.includes(state))
|
|
384
|
-
fail("receive_owner"); reference.checkRetained(); this.#checkIngress(); },
|
|
385
|
-
release: () => {
|
|
386
|
-
if (released)
|
|
387
|
-
return;
|
|
388
|
-
released = true;
|
|
389
|
-
if (!state.validated)
|
|
390
|
-
state.clear();
|
|
391
|
-
segments = [];
|
|
392
|
-
const at = this.#nativeClaims.indexOf(state);
|
|
393
|
-
if (at < 0)
|
|
394
|
-
fail("receive_owner");
|
|
395
|
-
this.#nativeClaims.splice(at, 1);
|
|
396
|
-
if (state.detached && !this.#nativeClaims.some(value => value.reference === reference))
|
|
397
|
-
reference.release();
|
|
398
|
-
this.#cleanup();
|
|
399
|
-
},
|
|
400
|
-
};
|
|
401
|
-
const state = { claim, reference, end: start + payloadClaim, logicalBytes: payloadClaim,
|
|
402
|
-
detached: false, validated: false, clear: () => { for (const part of segments)
|
|
403
|
-
part.fill(0); } };
|
|
404
|
-
this.#nativeClaims.push(state);
|
|
405
|
-
return claim;
|
|
406
|
-
}
|
|
407
|
-
nativePrefetchFits(claim, remaining) {
|
|
408
|
-
this.#checkIngress();
|
|
409
|
-
if (!this.#nativeClaims.some(state => state.claim === claim))
|
|
410
|
-
fail("receive_owner");
|
|
411
|
-
return this.#nativeClaims.reduce((total, state) => total + (state.validated ? 0n : state.logicalBytes), 0n) <= remaining;
|
|
412
|
-
}
|
|
413
|
-
#validateNative(length) {
|
|
414
|
-
const state = this.#nativeClaims.find(value => !value.validated);
|
|
415
|
-
if (state === undefined)
|
|
416
|
-
return;
|
|
417
|
-
if (BigInt(length) > state.logicalBytes)
|
|
418
|
-
fail("receive_credit");
|
|
419
|
-
// Coalescing and schema validation have ended their ciphertext borrow.
|
|
420
|
-
// Keep the original claim/reference until its actual candidate exits, but
|
|
421
|
-
// allow this exact storage to receive the authenticated plaintext below.
|
|
422
|
-
state.clear();
|
|
423
|
-
state.validated = true;
|
|
424
|
-
}
|
|
425
|
-
#releaseBacking(reference) {
|
|
426
|
-
let retained = false;
|
|
427
|
-
for (const state of this.#nativeClaims)
|
|
428
|
-
if (state.reference === reference) {
|
|
429
|
-
state.detached = true;
|
|
430
|
-
retained = true;
|
|
431
|
-
}
|
|
432
|
-
if (!retained)
|
|
433
|
-
reference.release();
|
|
434
|
-
}
|
|
435
|
-
/** Original fixed queue capacity backs the new absolute promise. Publication
|
|
436
|
-
* calls commitCredit in the same record ticket gate, never after completion. */
|
|
437
|
-
nextCredit() {
|
|
438
|
-
if (this.#abandoned || this.#fin !== undefined || this.#creditPaused)
|
|
439
|
-
return this.#receiveLimit;
|
|
440
|
-
if (this.#bodyQueue !== undefined) {
|
|
441
|
-
const end = this.#bodyQueue.end, window = this.#released + BigInt(this.#config.queueBytes);
|
|
442
|
-
return window < end ? window : end;
|
|
443
|
-
}
|
|
444
|
-
if (this.#ring.length === 0)
|
|
445
|
-
return this.#receiveLimit;
|
|
446
|
-
const remaining = uint64Max - this.#released;
|
|
447
|
-
return this.#released + (remaining < BigInt(this.#config.queueBytes) ? remaining : BigInt(this.#config.queueBytes));
|
|
448
|
-
}
|
|
449
|
-
commitCredit(limit) {
|
|
450
|
-
this.#checkIngress();
|
|
451
|
-
if (limit < this.#receiveLimit || limit > this.nextCredit())
|
|
452
|
-
fail("receive_credit");
|
|
453
|
-
this.#receiveLimit = limit;
|
|
454
|
-
}
|
|
455
|
-
state() {
|
|
456
|
-
return this.#terminal ?? Object.freeze({ stream_status: this.#fin !== undefined && this.#queued === 0 ? "eof" : "open" });
|
|
457
|
-
}
|
|
458
|
-
checkAdapterClaim() {
|
|
459
|
-
if (this.#active !== undefined || this.#closed)
|
|
460
|
-
throw new V4ReadMethodError("read_in_progress");
|
|
461
|
-
this.#delivery.check();
|
|
462
|
-
}
|
|
463
|
-
setAdapterCreditPaused(paused) {
|
|
464
|
-
this.#creditPaused = paused;
|
|
465
|
-
if (!paused && !this.#closed)
|
|
466
|
-
this.released?.();
|
|
467
|
-
}
|
|
468
|
-
/** A single authenticated message interval can take the queue's real
|
|
469
|
-
* backing. Cross-boundary promises keep their ring and full overlap charge. */
|
|
470
|
-
admitMessageBody(length, structure, reserve) {
|
|
471
|
-
if (!Number.isSafeInteger(length) || length < 0 || BigInt(length) > uint64Max - this.#released ||
|
|
472
|
-
this.#closed || this.#working || this.#wait !== undefined || this.#bodyQueue !== undefined)
|
|
473
|
-
fail("receive_owner");
|
|
474
|
-
this.#delivery.check();
|
|
475
|
-
const direct = this.#nativeClaims.length === 0 && length > 0 && this.#ring.length > 0 && this.#receiveLimit - this.#released <= BigInt(length) && this.#queued <= length;
|
|
476
|
-
const reuse = direct && length <= this.#ring.length;
|
|
477
|
-
const charge = structure.add(vector(reuse ? 0n : BigInt(length), 0n, 0n));
|
|
478
|
-
const reference = reserve("v4_message_body", charge);
|
|
479
|
-
let retained;
|
|
480
|
-
try {
|
|
481
|
-
// Take the actual I/O alias before changing any backing or accounting.
|
|
482
|
-
// A canceled message cannot refund storage still held by this direction.
|
|
483
|
-
if (direct)
|
|
484
|
-
retained = reference.borrow();
|
|
485
|
-
const bytes = reuse ? byteSlice(this.#ring, 0, length) : new NativeBytes(length);
|
|
486
|
-
if (!direct)
|
|
487
|
-
return { bytes, reference };
|
|
488
|
-
const capacity = this.#ring.length, original = this.#queueReference ?? this.#reservation;
|
|
489
|
-
// New allocation overlaps the old ring until its bytes are copied and
|
|
490
|
-
// all aliases below have exited. Reuse performs an in-place rotation.
|
|
491
|
-
if (!reuse) {
|
|
492
|
-
const first = Math.min(this.#queued, capacity - this.#head);
|
|
493
|
-
copy.call(bytes, byteSlice(this.#ring, this.#head, this.#head + first));
|
|
494
|
-
if (first < this.#queued)
|
|
495
|
-
copy.call(bytes, byteSlice(this.#ring, 0, this.#queued - first), first);
|
|
496
|
-
}
|
|
497
|
-
original.moveBytesTo(reference, BigInt(capacity));
|
|
498
|
-
if (reuse && this.#head !== 0) {
|
|
499
|
-
reverse.call(byteSlice(this.#ring, 0, this.#head));
|
|
500
|
-
reverse.call(byteSlice(this.#ring, this.#head, capacity));
|
|
501
|
-
reverse.call(this.#ring);
|
|
502
|
-
}
|
|
503
|
-
if (!reuse)
|
|
504
|
-
this.#ring.fill(0);
|
|
505
|
-
this.#bodyQueue = { start: this.#released, end: this.#released + BigInt(length), bytes, reference: retained };
|
|
506
|
-
this.#ring = empty;
|
|
507
|
-
this.#head = 0;
|
|
508
|
-
this.#queueReference?.release();
|
|
509
|
-
this.#queueReference = undefined;
|
|
510
|
-
if (!reuse)
|
|
511
|
-
reference.shrink(charge, [retained]);
|
|
512
|
-
return { bytes, reference };
|
|
513
|
-
}
|
|
514
|
-
catch (error) {
|
|
515
|
-
retained?.release();
|
|
516
|
-
reference.release();
|
|
517
|
-
throw error;
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
/** A consumed message still owns its backing. New credit needs a different
|
|
521
|
-
* paid queue; restoring it cannot reuse the private result's memory. */
|
|
522
|
-
ensureMessageQueue(reserve) {
|
|
523
|
-
if (this.#closed || this.#working || this.#wait !== undefined)
|
|
524
|
-
fail("receive_owner");
|
|
525
|
-
if (this.#ring.length !== 0 || this.#fin !== undefined && this.#queued === 0)
|
|
526
|
-
return;
|
|
527
|
-
if (this.#bodyQueue !== undefined && this.#released !== this.#bodyQueue.end)
|
|
528
|
-
fail("receive_owner");
|
|
529
|
-
const reference = reserve("v4_message_queue", vector(BigInt(this.#config.queueBytes), 0n, 0n));
|
|
530
|
-
try {
|
|
531
|
-
const bytes = new NativeBytes(this.#config.queueBytes);
|
|
532
|
-
this.#delivery.check();
|
|
533
|
-
const previous = this.#bodyQueue;
|
|
534
|
-
this.#bodyQueue = undefined;
|
|
535
|
-
if (previous !== undefined)
|
|
536
|
-
this.#releaseBacking(previous.reference);
|
|
537
|
-
this.#ring = bytes;
|
|
538
|
-
this.#head = 0;
|
|
539
|
-
this.#queueReference = reference;
|
|
540
|
-
}
|
|
541
|
-
catch (error) {
|
|
542
|
-
reference.release();
|
|
543
|
-
throw error;
|
|
544
|
-
}
|
|
545
|
-
this.released?.();
|
|
546
|
-
}
|
|
547
|
-
/** Consumes this exact key's packet on success or authenticated input failure. */
|
|
548
|
-
accept(packet, finalOffset) {
|
|
549
|
-
this.#checkIngress();
|
|
550
|
-
// A packet from another queue is an integration error, not a peer input
|
|
551
|
-
// violation. Do not consume it or damage either direction on that path.
|
|
552
|
-
const info = this.#cipher.inspectIncoming(packet);
|
|
553
|
-
if (info.frameType !== wire.frame_types.STREAM_DATA)
|
|
554
|
-
fail("receive_owner");
|
|
555
|
-
this.#working = true;
|
|
556
|
-
let document;
|
|
557
|
-
let scratch = this.#scratch, decoder = this.#decoder, shared = false, scratchUsed = 0;
|
|
558
|
-
try {
|
|
559
|
-
if (this.#config.workspace !== undefined) {
|
|
560
|
-
const position = this.#config.workspace.acquire(this);
|
|
561
|
-
scratch = position.scratch;
|
|
562
|
-
decoder = position.decoder;
|
|
563
|
-
shared = true;
|
|
564
|
-
}
|
|
565
|
-
if (info.plaintextBytes > scratch.length)
|
|
566
|
-
fail("receive_data");
|
|
567
|
-
scratchUsed = info.plaintextBytes;
|
|
568
|
-
const count = packet.copyBytes(scratch);
|
|
569
|
-
document = decoder.decodeMap(byteSlice(scratch, 0, count), "STREAM_DATA", { limits: {
|
|
570
|
-
max_data_payload_bytes: shared ? Math.min(this.#config.queueBytes, this.#config.plaintextBytes) : this.#config.maxDataBytes,
|
|
571
|
-
} });
|
|
572
|
-
if (document.uint(document.field(0, 0)) !== info.scope || document.uint(document.field(0, 1)) !== BigInt(info.direction) ||
|
|
573
|
-
document.uint(document.field(0, 2)) !== BigInt(info.epoch) || document.uint(document.field(0, 3)) !== info.sequence)
|
|
574
|
-
fail("receive_data");
|
|
575
|
-
const offset = document.uint(document.field(0, 4)), fin = document.boolean(document.field(0, 5));
|
|
576
|
-
const node = document.field(0, 6), length = document.size(node);
|
|
577
|
-
if (offset !== this.#ack || this.#fin !== undefined || BigInt(length) > uint64Max - offset)
|
|
578
|
-
fail("receive_sequence");
|
|
579
|
-
if (finalOffset !== undefined && (finalOffset < this.#ack || finalOffset > this.#receiveLimit || offset + BigInt(length) > finalOffset))
|
|
580
|
-
fail("receive_credit");
|
|
581
|
-
const body = this.#bodyQueue;
|
|
582
|
-
if (offset + BigInt(length) > this.#receiveLimit ||
|
|
583
|
-
(body === undefined ? length > this.#ring.length - this.#queued : offset < body.start || offset + BigInt(length) > body.end))
|
|
584
|
-
fail("receive_credit");
|
|
585
|
-
this.#delivery.check();
|
|
586
|
-
if (this.#closed)
|
|
587
|
-
fail("receive_closed");
|
|
588
|
-
this.#validateNative(length);
|
|
589
|
-
// All storage is prepaid. The hidden tail is not visible to readers until
|
|
590
|
-
// both full schema/association validation and crypto commit succeed.
|
|
591
|
-
if (!this.#abandoned && body !== undefined) {
|
|
592
|
-
document.copyRange(node, 0, byteSlice(body.bytes, Number(offset - body.start), Number(offset - body.start) + length), true);
|
|
593
|
-
}
|
|
594
|
-
else if (!this.#abandoned && length > 0) {
|
|
595
|
-
const tail = (this.#head + this.#queued) % this.#ring.length;
|
|
596
|
-
const first = Math.min(length, this.#ring.length - tail);
|
|
597
|
-
document.copyRange(node, 0, byteSlice(this.#ring, tail, tail + first), true);
|
|
598
|
-
if (first < length)
|
|
599
|
-
document.copyRange(node, first, byteSlice(this.#ring, 0, length - first), true);
|
|
600
|
-
}
|
|
601
|
-
packet.commitValidated();
|
|
602
|
-
if (!this.#abandoned)
|
|
603
|
-
this.#queued += length;
|
|
604
|
-
this.#ack += BigInt(length);
|
|
605
|
-
if (fin)
|
|
606
|
-
this.#fin = this.#ack;
|
|
607
|
-
}
|
|
608
|
-
catch (error) {
|
|
609
|
-
if (!this.#closed) {
|
|
610
|
-
if (error instanceof SchemaValidationError || error instanceof CBORWireError || error instanceof ReceiveError &&
|
|
611
|
-
["receive_data", "receive_sequence", "receive_credit"].includes(error.code)) {
|
|
612
|
-
this.#terminate({ stream_status: "error", error: { code: "stream_data_invalid", scope: "stream", retry_disposition: "preserve_facts" } });
|
|
613
|
-
}
|
|
614
|
-
else if (error instanceof ResourceError && error.code === "resource_exhausted") {
|
|
615
|
-
this.#terminate({ stream_status: "error", error: { code: "resource_exhausted", scope: "stream", retry_disposition: "preserve_facts" } });
|
|
616
|
-
}
|
|
617
|
-
else
|
|
618
|
-
this.close();
|
|
619
|
-
}
|
|
620
|
-
throw error;
|
|
621
|
-
}
|
|
622
|
-
finally {
|
|
623
|
-
document?.release();
|
|
624
|
-
packet.release();
|
|
625
|
-
if (shared)
|
|
626
|
-
this.#config.workspace.release(this, scratchUsed);
|
|
627
|
-
else
|
|
628
|
-
scratch.fill(0, 0, scratchUsed);
|
|
629
|
-
this.#working = false;
|
|
630
|
-
this.#pump();
|
|
631
|
-
this.#cleanup();
|
|
632
|
-
}
|
|
633
|
-
}
|
|
634
|
-
/** Called by the original rekey owner before retiring its old receive key. */
|
|
635
|
-
replaceCipher(next) {
|
|
636
|
-
this.#checkIngress();
|
|
637
|
-
const binding = next.receiveBinding(this.#reservation);
|
|
638
|
-
if (!next.sharesReceiveDirection(this.#cipher) || binding.epoch !== this.#binding.epoch + 1)
|
|
639
|
-
fail("receive_owner");
|
|
640
|
-
this.#cipher = next;
|
|
641
|
-
this.#binding = binding;
|
|
642
|
-
}
|
|
643
|
-
/** Seal application delivery at the original direction, while retaining the
|
|
644
|
-
* decoder and credit promise needed to authenticate/discard in-flight DATA.
|
|
645
|
-
* Discarded bytes advance only the authenticated frontier, never consumption. */
|
|
646
|
-
abandonDelivery() {
|
|
647
|
-
if (this.#closed || this.#abandoned)
|
|
648
|
-
return;
|
|
649
|
-
this.#abandoned = true;
|
|
650
|
-
this.#terminate({ stream_status: "aborted" });
|
|
651
|
-
this.#pump();
|
|
652
|
-
}
|
|
653
|
-
acquireCursor(target) { return this.#acquire(target); }
|
|
654
|
-
#acquire(target) {
|
|
655
|
-
if (typeof target !== "bigint" || target < 0n || target > BigInt(this.#config.maxCursorBytes) || target > uint64Max - this.#released) {
|
|
656
|
-
throw new V4ReadMethodError("invalid_argument");
|
|
657
|
-
}
|
|
658
|
-
if (this.#closed)
|
|
659
|
-
throw new V4ReadMethodError("closed");
|
|
660
|
-
if (this.#active !== undefined)
|
|
661
|
-
throw new V4ReadMethodError("read_in_progress");
|
|
662
|
-
this.#reservation.check();
|
|
663
|
-
this.#delivery.check();
|
|
664
|
-
if (this.#closed)
|
|
665
|
-
throw new V4ReadMethodError("closed");
|
|
666
|
-
const reservation = this.#cursorReservation.checkout();
|
|
667
|
-
try {
|
|
668
|
-
const owner = new ReceiveCursorOwner(token, this, this.#released, Number(target), reservation);
|
|
669
|
-
this.#active = owner;
|
|
670
|
-
return owner;
|
|
671
|
-
}
|
|
672
|
-
catch (error) {
|
|
673
|
-
reservation.release();
|
|
674
|
-
throw error;
|
|
675
|
-
}
|
|
676
|
-
}
|
|
677
|
-
read(maxBytes, options) {
|
|
678
|
-
let resolve, reject;
|
|
679
|
-
const promise = new NativePromise((yes, no) => { resolve = yes; reject = no; });
|
|
680
|
-
if (typeof maxBytes !== "bigint" || maxBytes <= 0n || maxBytes > BigInt(this.#config.maxCursorBytes)) {
|
|
681
|
-
reject(new V4ReadMethodError("invalid_argument"));
|
|
682
|
-
return promise;
|
|
683
|
-
}
|
|
684
|
-
if (this.#closed && this.state().stream_status === "eof") {
|
|
685
|
-
resolve(readResult(new Uint8Array(), this.#released, "ready", this.state()));
|
|
686
|
-
return promise;
|
|
687
|
-
}
|
|
688
|
-
const signal = options?.signal;
|
|
689
|
-
let owner;
|
|
690
|
-
try {
|
|
691
|
-
owner = this.#acquire(maxBytes);
|
|
692
|
-
}
|
|
693
|
-
catch (error) {
|
|
694
|
-
reject(error);
|
|
695
|
-
return promise;
|
|
696
|
-
}
|
|
697
|
-
const canceled = () => this.#pump();
|
|
698
|
-
const wait = { kind: "raw", owner, maximum: Number(maxBytes), resolve, reject, signal, canceled, armed: false };
|
|
699
|
-
this.#wait = wait;
|
|
700
|
-
signal?.addEventListener("abort", canceled, { once: true });
|
|
701
|
-
this.#pump();
|
|
702
|
-
wait.armed = true;
|
|
703
|
-
return promise;
|
|
704
|
-
}
|
|
705
|
-
cursorRead(capability, owner, maximum, transfer, signal) {
|
|
706
|
-
return new Promise((resolve, reject) => {
|
|
707
|
-
if (capability !== token || this.#active !== owner) {
|
|
708
|
-
reject(new V4ReadMethodError("owner_unavailable"));
|
|
709
|
-
return;
|
|
710
|
-
}
|
|
711
|
-
if (this.#wait !== undefined) {
|
|
712
|
-
reject(new V4ReadMethodError("read_in_progress"));
|
|
713
|
-
return;
|
|
714
|
-
}
|
|
715
|
-
if (!Number.isSafeInteger(maximum) || maximum <= 0 || maximum > owner.storage.length) {
|
|
716
|
-
reject(new V4ReadMethodError("invalid_argument"));
|
|
717
|
-
return;
|
|
718
|
-
}
|
|
719
|
-
const canceled = () => {
|
|
720
|
-
const wait = this.#wait;
|
|
721
|
-
if (wait?.owner !== owner)
|
|
722
|
-
return;
|
|
723
|
-
this.#detach(wait);
|
|
724
|
-
reject(new V4ReadMethodError("prefix_frozen"));
|
|
725
|
-
};
|
|
726
|
-
this.#wait = { kind: "cursor", owner, maximum, transfer, resolve, reject, signal, canceled };
|
|
727
|
-
signal.addEventListener("abort", canceled, { once: true });
|
|
728
|
-
if (signal.aborted)
|
|
729
|
-
canceled();
|
|
730
|
-
this.#pump();
|
|
731
|
-
});
|
|
732
|
-
}
|
|
733
|
-
claimDelivery(capability, owner) {
|
|
734
|
-
if (capability !== token || this.#active !== owner)
|
|
735
|
-
throw new V4ReadMethodError("owner_unavailable");
|
|
736
|
-
// Normal I/O close does not close the independently captured safety gate.
|
|
737
|
-
this.#delivery.check();
|
|
738
|
-
}
|
|
739
|
-
releaseCursor(capability, owner) {
|
|
740
|
-
if (capability !== token || this.#active !== owner || this.#wait?.owner === owner)
|
|
741
|
-
fail("receive_owner");
|
|
742
|
-
this.#active = undefined;
|
|
743
|
-
if (this.#bodyQueue !== undefined && this.#released === this.#bodyQueue.end) {
|
|
744
|
-
const body = this.#bodyQueue;
|
|
745
|
-
this.#bodyQueue = undefined;
|
|
746
|
-
this.#releaseBacking(body.reference);
|
|
747
|
-
}
|
|
748
|
-
this.#cleanup();
|
|
749
|
-
this.settled?.();
|
|
750
|
-
}
|
|
751
|
-
#checkIngress() {
|
|
752
|
-
if (this.#closed || this.#terminal !== undefined && !this.#abandoned)
|
|
753
|
-
fail("receive_closed");
|
|
754
|
-
if (this.#working)
|
|
755
|
-
fail("receive_busy");
|
|
756
|
-
this.#reservation.check();
|
|
757
|
-
this.#delivery.check();
|
|
758
|
-
if (this.#closed)
|
|
759
|
-
fail("receive_closed");
|
|
760
|
-
}
|
|
761
|
-
#detach(wait) {
|
|
762
|
-
if (this.#wait === wait)
|
|
763
|
-
this.#wait = undefined;
|
|
764
|
-
wait.signal?.removeEventListener("abort", wait.canceled);
|
|
765
|
-
}
|
|
766
|
-
#pump() {
|
|
767
|
-
if (this.#pumpQueued || this.#wait === undefined || this.#working)
|
|
768
|
-
return;
|
|
769
|
-
this.#pumpQueued = true;
|
|
770
|
-
enqueueReadJob(() => { this.#pumpQueued = false; this.#runPump(); });
|
|
771
|
-
}
|
|
772
|
-
#runPump() {
|
|
773
|
-
const wait = this.#wait;
|
|
774
|
-
if (wait === undefined || this.#working || wait.kind === "raw" && !wait.armed)
|
|
775
|
-
return;
|
|
776
|
-
if (this.#queued === 0 && this.state().stream_status === "open" && !(wait.kind === "raw" && wait.signal?.aborted))
|
|
777
|
-
return;
|
|
778
|
-
this.#detach(wait);
|
|
779
|
-
let handoff = false;
|
|
780
|
-
try {
|
|
781
|
-
if (wait.kind === "raw") {
|
|
782
|
-
if (wait.signal?.aborted && this.state().stream_status === "open") {
|
|
783
|
-
const result = readResult(new Uint8Array(), this.#released, "wait_canceled", this.state());
|
|
784
|
-
wait.resolve(result);
|
|
785
|
-
wait.owner.release();
|
|
786
|
-
return;
|
|
787
|
-
}
|
|
788
|
-
}
|
|
789
|
-
else if (this.#queued > 0) {
|
|
790
|
-
this.#delivery.check();
|
|
791
|
-
}
|
|
792
|
-
const body = this.#bodyQueue;
|
|
793
|
-
const maximum = Math.min(wait.maximum, this.#queued, body === undefined ? this.#ring.length - this.#head : Number(body.end - this.#released), this.#config.maxDataBytes);
|
|
794
|
-
let count = 0;
|
|
795
|
-
if (maximum > 0) {
|
|
796
|
-
const bytes = body === undefined ? byteSlice(this.#ring, this.#head, this.#head + maximum) :
|
|
797
|
-
byteSlice(body.bytes, Number(this.#released - body.start), Number(this.#released - body.start) + maximum);
|
|
798
|
-
if (wait.kind === "raw") {
|
|
799
|
-
copy.call(wait.owner.storage, bytes);
|
|
800
|
-
count = maximum;
|
|
801
|
-
}
|
|
802
|
-
else
|
|
803
|
-
count = wait.transfer(bytes);
|
|
804
|
-
if (!Number.isSafeInteger(count) || count < 0 || count > maximum)
|
|
805
|
-
fail("receive_owner");
|
|
806
|
-
}
|
|
807
|
-
let result;
|
|
808
|
-
if (wait.kind === "raw") {
|
|
809
|
-
const state = this.#terminal ?? { stream_status: this.#fin !== undefined && this.#queued === count ? "eof" : "open" };
|
|
810
|
-
result = readResult(byteSlice(wait.owner.storage, 0, count), this.#released + BigInt(count), "ready", state);
|
|
811
|
-
// All backing, result shape and the final capability exist before the
|
|
812
|
-
// irreversible claim. Retain the reservation through resolver exit.
|
|
813
|
-
wait.owner.claimDelivery();
|
|
814
|
-
handoff = true;
|
|
815
|
-
}
|
|
816
|
-
if (count > 0) {
|
|
817
|
-
if (body === undefined) {
|
|
818
|
-
this.#ring.fill(0, this.#head, this.#head + count);
|
|
819
|
-
this.#head = (this.#head + count) % this.#ring.length;
|
|
820
|
-
}
|
|
821
|
-
this.#queued -= count;
|
|
822
|
-
this.#released += BigInt(count);
|
|
823
|
-
}
|
|
824
|
-
if (wait.kind === "cursor")
|
|
825
|
-
wait.resolve();
|
|
826
|
-
else {
|
|
827
|
-
wait.resolve(result);
|
|
828
|
-
wait.owner.release();
|
|
829
|
-
}
|
|
830
|
-
// The original final resolver remains the caller's capability. Credit
|
|
831
|
-
// publication observes the committed transfer without chaining payload
|
|
832
|
-
// through a private intermediate promise or invoking host code in it.
|
|
833
|
-
if (count > 0)
|
|
834
|
-
this.released?.();
|
|
835
|
-
}
|
|
836
|
-
catch (error) {
|
|
837
|
-
if (handoff)
|
|
838
|
-
return;
|
|
839
|
-
if (wait.kind === "raw")
|
|
840
|
-
wait.owner.release();
|
|
841
|
-
wait.reject(error);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
#terminate(state) {
|
|
845
|
-
this.#terminal ??= Object.freeze({ ...state, ...(state.error === undefined ? {} : { error: Object.freeze({ ...state.error }) }) });
|
|
846
|
-
if (this.#nativeClaims.length === 0)
|
|
847
|
-
this.#ring.fill(0);
|
|
848
|
-
else {
|
|
849
|
-
// An intentional delivery stop cannot corrupt an in-flight ciphertext
|
|
850
|
-
// which still belongs to the original authentication/termination path.
|
|
851
|
-
const first = Math.min(this.#queued, this.#ring.length - this.#head);
|
|
852
|
-
this.#ring.fill(0, this.#head, this.#head + first);
|
|
853
|
-
this.#ring.fill(0, 0, this.#queued - first);
|
|
854
|
-
}
|
|
855
|
-
this.#queued = 0;
|
|
856
|
-
}
|
|
857
|
-
close() {
|
|
858
|
-
if (this.#closed)
|
|
859
|
-
return;
|
|
860
|
-
this.#closed = true;
|
|
861
|
-
if (this.state().stream_status === "open")
|
|
862
|
-
this.#terminate({ stream_status: "aborted" });
|
|
863
|
-
if (!this.#borrowedCursor)
|
|
864
|
-
this.#cursorReservation?.closeAfterUse();
|
|
865
|
-
this.#pump();
|
|
866
|
-
this.#cleanup();
|
|
867
|
-
}
|
|
868
|
-
#cleanup() {
|
|
869
|
-
if (this.#closed && !this.#working) {
|
|
870
|
-
// Retained cursors/claims need their real bytes and safety gate, but no
|
|
871
|
-
// future parser access. They do not retain the shared full workspace.
|
|
872
|
-
this.#workspaceRelease?.();
|
|
873
|
-
this.#workspaceRelease = undefined;
|
|
874
|
-
this.#workspaceReference?.release();
|
|
875
|
-
this.#workspaceReference = undefined;
|
|
876
|
-
}
|
|
877
|
-
if (!this.#closed || this.#working || this.#nativeClaims.length !== 0 || this.#active !== undefined || this.#wait !== undefined)
|
|
878
|
-
return;
|
|
879
|
-
this.#ring.fill(0);
|
|
880
|
-
this.#scratch.fill(0);
|
|
881
|
-
this.#ring = empty;
|
|
882
|
-
this.#scratch = empty;
|
|
883
|
-
// The independent message owner clears or delivers its body. This I/O
|
|
884
|
-
// alias neither zeros a completed result nor refunds its transferred charge.
|
|
885
|
-
const body = this.#bodyQueue;
|
|
886
|
-
this.#bodyQueue = undefined;
|
|
887
|
-
body?.reference.release();
|
|
888
|
-
this.#queueReference?.release();
|
|
889
|
-
this.#queueReference = undefined;
|
|
890
|
-
this.#decoder?.close();
|
|
891
|
-
this.#decoder = undefined;
|
|
892
|
-
this.#cipher = undefined;
|
|
893
|
-
this.#delivery?.release();
|
|
894
|
-
this.#delivery = undefined;
|
|
895
|
-
this.#reservation?.release();
|
|
896
|
-
this.#reservation = undefined;
|
|
897
|
-
}
|
|
898
|
-
cleanupStatus() {
|
|
899
|
-
return this.#closed && this.#reservation === undefined && (this.#borrowedCursor || this.#cursorReservation?.cleanupComplete() !== false) ? complete : pending;
|
|
900
|
-
}
|
|
901
|
-
}
|
|
902
|
-
class ReceiveCursorOwner {
|
|
903
|
-
#direction;
|
|
904
|
-
#reservation;
|
|
905
|
-
#storage;
|
|
906
|
-
#claimed = false;
|
|
907
|
-
#state = { stream_status: "open" };
|
|
908
|
-
startOffset;
|
|
909
|
-
constructor(capability, direction, offset, size, reservation) {
|
|
910
|
-
if (capability !== token)
|
|
911
|
-
fail("receive_owner");
|
|
912
|
-
this.#direction = direction;
|
|
913
|
-
this.#reservation = reservation;
|
|
914
|
-
this.startOffset = offset;
|
|
915
|
-
this.#storage = new Uint8Array(size);
|
|
916
|
-
}
|
|
917
|
-
get storage() { return this.#storage; }
|
|
918
|
-
state() { return this.#direction?.state() ?? this.#state; }
|
|
919
|
-
read(maximum, transfer, signal) {
|
|
920
|
-
if (this.#direction === undefined)
|
|
921
|
-
return Promise.reject(new V4ReadMethodError("closed"));
|
|
922
|
-
return this.#direction.cursorRead(token, this, maximum, transfer, signal);
|
|
923
|
-
}
|
|
924
|
-
claimDelivery() {
|
|
925
|
-
if (this.#claimed)
|
|
926
|
-
throw new V4ReadMethodError("already_delivered");
|
|
927
|
-
if (this.#direction === undefined)
|
|
928
|
-
throw new V4ReadMethodError("closed");
|
|
929
|
-
this.#reservation.checkRetained();
|
|
930
|
-
this.#direction.claimDelivery(token, this);
|
|
931
|
-
this.#claimed = true;
|
|
932
|
-
}
|
|
933
|
-
release() {
|
|
934
|
-
if (this.#direction === undefined)
|
|
935
|
-
return;
|
|
936
|
-
const direction = this.#direction;
|
|
937
|
-
this.#state = direction.state();
|
|
938
|
-
this.#direction = undefined;
|
|
939
|
-
if (!this.#claimed)
|
|
940
|
-
this.#storage.fill(0);
|
|
941
|
-
this.#storage = empty;
|
|
942
|
-
this.#reservation.release();
|
|
943
|
-
this.#reservation = undefined;
|
|
944
|
-
direction.releaseCursor(token, this);
|
|
945
|
-
}
|
|
946
|
-
}
|
|
947
|
-
function readResult(data, offset, waitStatus, state) {
|
|
948
|
-
const error = state.error;
|
|
949
|
-
const result = { data, progress: Object.freeze({ offset, filled: BigInt(data.length) }), wait_status: waitStatus,
|
|
950
|
-
stream_status: state.stream_status, ...(error === undefined ? {} : { error }) };
|
|
951
|
-
Object.defineProperty(result, "then", { value: undefined });
|
|
952
|
-
return Object.freeze(result);
|
|
953
|
-
}
|
|
954
|
-
for (const owner of [ReceiveDeliveryGate, ReliableReceiveDirection, ReceiveCursorOwner]) {
|
|
955
|
-
Object.freeze(owner.prototype);
|
|
956
|
-
Object.freeze(owner);
|
|
957
|
-
}
|