@floegence/flowersec-core 6.1.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/README.md +101 -170
- package/THIRD_PARTY_NOTICES.md +7 -3072
- 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 +0 -2
- package/dist/node/connectionPath.js +0 -18
- package/dist/node/index.d.ts +16 -52
- package/dist/node/index.js +6 -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 +31 -70
- 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 +20 -19
- package/sbom/cyclonedx.json +43 -761
- package/sbom/spdx.json +49 -566
- 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/currentClock.d.ts +0 -3
- package/dist/interop/currentClock.js +0 -39
- package/dist/interop/currentContracts.d.ts +0 -6
- package/dist/interop/currentContracts.js +0 -14
- package/dist/interop/currentNativeTunnel.d.ts +0 -31
- package/dist/interop/currentNativeTunnel.js +0 -185
- package/dist/interop/currentParity.d.ts +0 -68
- package/dist/interop/currentParity.js +0 -392
- package/dist/interop/currentPeer.d.ts +0 -252
- package/dist/interop/currentPeer.js +0 -677
- package/dist/interop/currentRegisteredTunnelPeer.d.ts +0 -37
- package/dist/interop/currentRegisteredTunnelPeer.js +0 -93
- package/dist/interop/currentRelayPeer.d.ts +0 -131
- package/dist/interop/currentRelayPeer.js +0 -263
- package/dist/interop/currentServer.d.ts +0 -44
- package/dist/interop/currentServer.js +0 -299
- 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 -28
- package/dist/node/liveHTTPSV4.js +0 -298
- 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 -50
- package/dist/node/registeredPoolTunnelAuthority.js +0 -305
- 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 -99
- package/dist/node/wssV4.js +0 -846
- 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 -1913
- 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
package/dist/v4/poolSource.js
DELETED
|
@@ -1,900 +0,0 @@
|
|
|
1
|
-
import { sha256 } from "@noble/hashes/sha2.js";
|
|
2
|
-
import { V4ConnectionMaterial } from "./public.js";
|
|
3
|
-
import { topUpErrorProjection } from "../generated/transportV4APIResults.js";
|
|
4
|
-
import { CredentialWork, credentialWorkCharge, credentialOwner, credentialDigest, equalCredential } from "./runtime/credentialSupport.js";
|
|
5
|
-
import { FixedCBORWriter, canonicalHeadBytes } from "./runtime/cborWriter.js";
|
|
6
|
-
import { TrustedDeadline, timerChunk } from "./runtime/deadline.js";
|
|
7
|
-
import { ResourceVector } from "./runtime/resources.js";
|
|
8
|
-
import { originalPoolJournal } from "./runtime/poolJournal.js";
|
|
9
|
-
import { bindCredentialSourceFacade } from "./runtime/environment.js";
|
|
10
|
-
const claims = new WeakMap();
|
|
11
|
-
const sourceToken = Symbol("original durable pool source");
|
|
12
|
-
const handleToken = Symbol("pool TopUp observation"), handles = new WeakMap();
|
|
13
|
-
function operationCleanup(original) {
|
|
14
|
-
return Object.freeze({ status: original.active === 0 ? "complete" : "pending", core_cleanup: original.active === 0 ? "complete" : "pending", pending_callbacks: BigInt(original.active) });
|
|
15
|
-
}
|
|
16
|
-
function operationSettled(original) {
|
|
17
|
-
if (original.active === 0)
|
|
18
|
-
for (const observe of [...original.waiters])
|
|
19
|
-
observe();
|
|
20
|
-
}
|
|
21
|
-
function operationResult(original, error) {
|
|
22
|
-
const callError = error ?? original.error;
|
|
23
|
-
return Object.freeze({ state: original.state, handle: original.handle,
|
|
24
|
-
adoptedOptions: Object.freeze({ desiredCount: original.desired, maxItemBytes: original.maximum }),
|
|
25
|
-
...(callError === undefined ? {} : { callError }), cleanupStatus: operationCleanup(original) });
|
|
26
|
-
}
|
|
27
|
-
export class V4TopUpHandle {
|
|
28
|
-
constructor(token, original) {
|
|
29
|
-
if (token !== handleToken)
|
|
30
|
-
throw new Error("owner_unavailable");
|
|
31
|
-
handles.set(this, original);
|
|
32
|
-
Object.freeze(this);
|
|
33
|
-
}
|
|
34
|
-
status(options) { return handles.get(this).source.topUpStatus(this, options); }
|
|
35
|
-
cleanupStatus() { return operationCleanup(handles.get(this)); }
|
|
36
|
-
waitCleanup(options = {}) {
|
|
37
|
-
const original = handles.get(this);
|
|
38
|
-
options.signal?.throwIfAborted();
|
|
39
|
-
if (original.active === 0)
|
|
40
|
-
return Promise.resolve(operationCleanup(original));
|
|
41
|
-
if (original.waiters.size >= 8)
|
|
42
|
-
return Promise.reject(new Error("capacity_exhausted"));
|
|
43
|
-
return new Promise((resolve, reject) => {
|
|
44
|
-
const finish = () => { original.waiters.delete(finish); options.signal?.removeEventListener("abort", cancel); resolve(operationCleanup(original)); };
|
|
45
|
-
const cancel = () => { original.waiters.delete(finish); options.signal?.removeEventListener("abort", cancel); reject(new Error("canceled")); };
|
|
46
|
-
original.waiters.add(finish);
|
|
47
|
-
options.signal?.addEventListener("abort", cancel, { once: true });
|
|
48
|
-
if (options.signal?.aborted)
|
|
49
|
-
cancel();
|
|
50
|
-
else if (original.active === 0)
|
|
51
|
-
finish();
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
toJSON() { return {}; }
|
|
55
|
-
toString() { return "Flowersec.TopUpHandle"; }
|
|
56
|
-
}
|
|
57
|
-
function failure(code) { throw new Error(code); }
|
|
58
|
-
function fixed(bytes, length) {
|
|
59
|
-
if (!(bytes instanceof Uint8Array) || bytes.length !== length || !bytes.some(byte => byte !== 0))
|
|
60
|
-
failure("source_contract_invalid");
|
|
61
|
-
return new Uint8Array(bytes);
|
|
62
|
-
}
|
|
63
|
-
function bytes(doc, node, length) {
|
|
64
|
-
if (node < 0 || doc.kind(node) !== "bytes" || length !== undefined && doc.size(node) !== length)
|
|
65
|
-
failure("source_contract_invalid");
|
|
66
|
-
const value = new Uint8Array(doc.size(node));
|
|
67
|
-
doc.copyPayload(node, value);
|
|
68
|
-
return value;
|
|
69
|
-
}
|
|
70
|
-
const stateNames = ["pending", "installed", "acked", "terminal"];
|
|
71
|
-
function snapshot(buffer, tenant, incarnation, journal) {
|
|
72
|
-
const writer = new FixedCBORWriter(buffer).map(journal.pending === undefined ? 9 : 10);
|
|
73
|
-
writer.uint(0).uint(2).uint(1).data(new TextEncoder().encode(tenant), true).uint(2).data(incarnation)
|
|
74
|
-
.uint(3).uint(journal.next).uint(4).uint(journal.retired).uint(5).uint(journal.frontier);
|
|
75
|
-
const pending = journal.pending;
|
|
76
|
-
if (pending !== undefined) {
|
|
77
|
-
const optional = [pending.responseDigest, pending.highest, pending.gap, pending.retired, pending.error, pending.applied].filter(value => value !== undefined).length;
|
|
78
|
-
writer.uint(6).map(12 + optional).uint(0).data(pending.id).uint(1).uint(stateNames.indexOf(pending.state)).uint(2).uint(pending.desired)
|
|
79
|
-
.uint(3).uint(pending.maximum).uint(4).data(pending.pool).uint(5).uint(pending.generation).uint(6).uint(pending.deadline)
|
|
80
|
-
.uint(7).data(pending.certificate).uint(8).data(pending.identity).uint(9).data(pending.requestDigest);
|
|
81
|
-
if (pending.responseDigest !== undefined)
|
|
82
|
-
writer.uint(10).data(pending.responseDigest);
|
|
83
|
-
if (pending.highest !== undefined)
|
|
84
|
-
writer.uint(11).uint(pending.highest);
|
|
85
|
-
if (pending.gap !== undefined)
|
|
86
|
-
writer.uint(12).bool(pending.gap);
|
|
87
|
-
if (pending.retired !== undefined)
|
|
88
|
-
writer.uint(13).uint(pending.retired);
|
|
89
|
-
if (pending.error !== undefined)
|
|
90
|
-
writer.uint(14).data(new TextEncoder().encode(pending.error), true);
|
|
91
|
-
if (pending.applied !== undefined) {
|
|
92
|
-
writer.uint(15).array(pending.applied.length);
|
|
93
|
-
for (const entry of pending.applied)
|
|
94
|
-
writer.map(5).uint(0).uint(entry.sequence).uint(1).uint(entry.generation).uint(2).uint(entry.expiry)
|
|
95
|
-
.uint(3).data(entry.digest).uint(4).data(entry.identity);
|
|
96
|
-
}
|
|
97
|
-
writer.uint(16).uint(pending.frontier).uint(17).uint(pending.attemptGeneration);
|
|
98
|
-
}
|
|
99
|
-
writer.uint(7).array(journal.materials.length);
|
|
100
|
-
for (const material of journal.materials)
|
|
101
|
-
writer.map(6).uint(0).uint(material.sequence).uint(1).uint(material.generation).uint(2).uint(material.expiry)
|
|
102
|
-
.uint(3).data(material.bytes).uint(4).data(material.digest).uint(5).data(material.identity);
|
|
103
|
-
writer.uint(8).bool(journal.fenced).uint(9).array(journal.applied.length);
|
|
104
|
-
for (const entry of journal.applied)
|
|
105
|
-
writer.map(5).uint(0).uint(entry.sequence).uint(1).uint(entry.generation).uint(2).uint(entry.expiry)
|
|
106
|
-
.uint(3).data(entry.digest).uint(4).data(entry.identity);
|
|
107
|
-
return writer.result();
|
|
108
|
-
}
|
|
109
|
-
/** Public acquisition and TopUp share one original durable pool owner. The
|
|
110
|
-
* observation handle contains only immutable ID; it cannot send or reinstall. */
|
|
111
|
-
export class V4PreauthorizedPoolSource {
|
|
112
|
-
#environment;
|
|
113
|
-
#policy;
|
|
114
|
-
#store;
|
|
115
|
-
#configuration;
|
|
116
|
-
#keys;
|
|
117
|
-
#dependency;
|
|
118
|
-
#identityDigest;
|
|
119
|
-
#source;
|
|
120
|
-
#journal;
|
|
121
|
-
#encoded;
|
|
122
|
-
#closed = false;
|
|
123
|
-
#working;
|
|
124
|
-
#active = 0;
|
|
125
|
-
#mutation = false;
|
|
126
|
-
#claim;
|
|
127
|
-
#abort = new AbortController();
|
|
128
|
-
#cleanupWaiters = new Set();
|
|
129
|
-
#observations = new Map();
|
|
130
|
-
#runningObservation;
|
|
131
|
-
/** @internal */
|
|
132
|
-
constructor(token, environment, policy, store, configuration, keys) {
|
|
133
|
-
if (token !== sourceToken)
|
|
134
|
-
failure("source_contract_invalid");
|
|
135
|
-
this.#environment = environment;
|
|
136
|
-
this.#policy = Object.freeze({ ...policy, cryptoProfiles: Object.freeze([...policy.cryptoProfiles]), authorities: Object.freeze([...policy.authorities]) });
|
|
137
|
-
this.#store = store;
|
|
138
|
-
this.#keys = Object.freeze({ signingPublicKey: new Uint8Array(keys.signingPublicKey), noisePublicKey: new Uint8Array(keys.noisePublicKey), check: keys.check });
|
|
139
|
-
this.#configuration = Object.freeze({ ...configuration, control: Object.freeze({ exchange: configuration.control.exchange.bind(configuration.control) }), sourceIncarnation: fixed(configuration.sourceIncarnation, 16), poolDigest: fixed(configuration.poolDigest, 32),
|
|
140
|
-
identityCertificate: new Uint8Array(configuration.identityCertificate), fenceAuthorityKeyID: fixed(configuration.fenceAuthorityKeyID, 16), fenceAuthorityPublicKey: fixed(configuration.fenceAuthorityPublicKey, 32) });
|
|
141
|
-
if (configuration.identityCertificate.length < 1 || configuration.identityCertificate.length > 8192 || configuration.operationLifetimeMS < 1n || configuration.callTimeoutMS < 1n ||
|
|
142
|
-
configuration.operationLifetimeMS > 86400000n || configuration.callTimeoutMS > 120000n ||
|
|
143
|
-
typeof configuration.providerRuntimeBytes !== "bigint" || configuration.providerRuntimeBytes < 1n ||
|
|
144
|
-
!Number.isSafeInteger(configuration.maximumMaterials ?? 8) || (configuration.maximumMaterials ?? 8) < 4 || (configuration.maximumMaterials ?? 8) > 16)
|
|
145
|
-
failure("configuration_capacity");
|
|
146
|
-
originalPoolJournal(store, environment);
|
|
147
|
-
keys.check();
|
|
148
|
-
this.#dependency = environment.admitDependency("durable_pool_source", new ResourceVector([4194304n + environment.resources.runtimeBytes, configuration.providerRuntimeBytes, 0n, 4n, 1n, 1n, 0n, 0n, 0n, 0n, 0n]));
|
|
149
|
-
this.#dependency.onClose(() => this.close());
|
|
150
|
-
try {
|
|
151
|
-
this.#identityDigest = credentialDigest("certificate_digest", this.#configuration.identityCertificate);
|
|
152
|
-
this.#parse("IdentityCertificate", this.#configuration.identityCertificate, certificate => {
|
|
153
|
-
if (certificate.text("tenant_id") !== policy.tenant || certificate.text("subject_id") !== policy.clientSubject || certificate.uint("role") !== 0n ||
|
|
154
|
-
certificate.text("audience") !== policy.audience || !equalCredential(certificate.bytes("ed25519_public_key"), keys.signingPublicKey) ||
|
|
155
|
-
!equalCredential(certificate.bytes("public_key_bytes", certificate.field("noise_static_public_key"), "NoiseStaticPublicKey"), keys.noisePublicKey))
|
|
156
|
-
failure("source_contract_invalid");
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
|
-
catch (error) {
|
|
160
|
-
this.#dependency.close();
|
|
161
|
-
this.#dependency.release();
|
|
162
|
-
throw error;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
#check() {
|
|
166
|
-
if (this.#closed)
|
|
167
|
-
failure("source_unavailable");
|
|
168
|
-
this.#dependency.check();
|
|
169
|
-
this.#keys.check();
|
|
170
|
-
originalPoolJournal(this.#store, this.#environment);
|
|
171
|
-
}
|
|
172
|
-
#parse(schema, encoded, read) {
|
|
173
|
-
const resources = this.#environment.resources, cap = Math.max(8192, encoded.length);
|
|
174
|
-
const ref = resources.root.reserve({ owner: credentialOwner(resources, "pool_codec"), accounts: resources.accounts, charge: credentialWorkCharge(cap, resources.runtimeBytes) });
|
|
175
|
-
const work = new CredentialWork(resources, cap, ref);
|
|
176
|
-
ref.release();
|
|
177
|
-
let map;
|
|
178
|
-
try {
|
|
179
|
-
map = schema === undefined ? work.parseRecord(encoded, cap, 8192) : work.parse(encoded, schema, cap, 8192, {});
|
|
180
|
-
return read(map, work);
|
|
181
|
-
}
|
|
182
|
-
finally {
|
|
183
|
-
map?.close();
|
|
184
|
-
work.close();
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
#decode(encoded) {
|
|
188
|
-
return this.#parse(undefined, encoded, ({ doc }) => {
|
|
189
|
-
const field = (id, node = 0) => { const result = doc.field(node, id); if (result < 0)
|
|
190
|
-
failure("source_state_unknown"); return result; };
|
|
191
|
-
if (doc.uint(field(0)) !== 2n || doc.text(field(1)) !== this.#policy.tenant || !equalCredential(bytes(doc, field(2), 16), this.#configuration.sourceIncarnation) || doc.size(0) < 9 || doc.size(0) > 10)
|
|
192
|
-
failure("source_state_unknown");
|
|
193
|
-
const result = { next: doc.uint(field(3)), retired: doc.uint(field(4)), frontier: doc.uint(field(5)), applied: [], materials: [], fenced: doc.boolean(field(8)) };
|
|
194
|
-
if (result.next < 1n || result.retired >= result.next)
|
|
195
|
-
failure("source_state_unknown");
|
|
196
|
-
const appliedRoot = field(9);
|
|
197
|
-
if (doc.kind(appliedRoot) !== "array" || doc.size(appliedRoot) > 64)
|
|
198
|
-
failure("source_state_unknown");
|
|
199
|
-
let previousApplied = 0n;
|
|
200
|
-
for (let item = doc.firstChild(appliedRoot); item >= 0; item = doc.nextSibling(item)) {
|
|
201
|
-
if (doc.size(item) !== 5)
|
|
202
|
-
failure("source_state_unknown");
|
|
203
|
-
const entry = { sequence: doc.uint(field(0, item)), generation: doc.uint(field(1, item)), expiry: doc.uint(field(2, item)), digest: bytes(doc, field(3, item), 32), identity: bytes(doc, field(4, item), 32) };
|
|
204
|
-
if (entry.sequence <= previousApplied || entry.sequence > result.frontier || entry.generation === 0n || entry.generation > originalPoolJournal(this.#store, this.#environment).generation() || entry.expiry === 0n || !entry.digest.some(byte => byte !== 0) || !entry.identity.some(byte => byte !== 0))
|
|
205
|
-
failure("source_state_unknown");
|
|
206
|
-
previousApplied = entry.sequence;
|
|
207
|
-
result.applied.push(entry);
|
|
208
|
-
}
|
|
209
|
-
if (result.frontier !== 0n && (result.applied.length === 0 || result.applied.at(-1)?.sequence !== result.frontier))
|
|
210
|
-
failure("source_state_unknown");
|
|
211
|
-
const pendingNode = doc.field(0, 6);
|
|
212
|
-
if (doc.size(0) >= 10 && pendingNode < 0)
|
|
213
|
-
failure("source_state_unknown");
|
|
214
|
-
if (pendingNode >= 0) {
|
|
215
|
-
const state = stateNames[Number(doc.uint(field(1, pendingNode)))];
|
|
216
|
-
if (state === undefined)
|
|
217
|
-
failure("source_state_unknown");
|
|
218
|
-
const pending = { id: bytes(doc, field(0, pendingNode), 16), state, desired: Number(doc.uint(field(2, pendingNode))), maximum: Number(doc.uint(field(3, pendingNode))),
|
|
219
|
-
pool: bytes(doc, field(4, pendingNode), 32), generation: doc.uint(field(5, pendingNode)), deadline: doc.uint(field(6, pendingNode)), attemptGeneration: doc.uint(field(17, pendingNode)), frontier: doc.uint(field(16, pendingNode)),
|
|
220
|
-
certificate: bytes(doc, field(7, pendingNode)), identity: bytes(doc, field(8, pendingNode), 32), requestDigest: bytes(doc, field(9, pendingNode), 32) };
|
|
221
|
-
if (pending.desired < 1 || pending.desired > 4 || pending.maximum < 1 || pending.maximum > 65536 || pending.certificate.length > 8192 || pending.generation === 0n || pending.generation > pending.attemptGeneration || pending.attemptGeneration > originalPoolJournal(this.#store, this.#environment).generation() || pending.frontier > result.frontier ||
|
|
222
|
-
!equalCredential(credentialDigest("certificate_digest", pending.certificate), pending.identity))
|
|
223
|
-
failure("source_state_unknown");
|
|
224
|
-
const digestNode = doc.field(pendingNode, 10), highestNode = doc.field(pendingNode, 11), gapNode = doc.field(pendingNode, 12), retiredNode = doc.field(pendingNode, 13), errorNode = doc.field(pendingNode, 14);
|
|
225
|
-
if (digestNode >= 0)
|
|
226
|
-
pending.responseDigest = bytes(doc, digestNode, 32);
|
|
227
|
-
if (highestNode >= 0)
|
|
228
|
-
pending.highest = doc.uint(highestNode);
|
|
229
|
-
if (gapNode >= 0)
|
|
230
|
-
pending.gap = doc.boolean(gapNode);
|
|
231
|
-
if (retiredNode >= 0)
|
|
232
|
-
pending.retired = doc.uint(retiredNode);
|
|
233
|
-
if (errorNode >= 0) {
|
|
234
|
-
const code = doc.text(errorNode);
|
|
235
|
-
if (topUpErrorProjection(code, "terminal") === undefined)
|
|
236
|
-
failure("source_state_unknown");
|
|
237
|
-
pending.error = code;
|
|
238
|
-
}
|
|
239
|
-
const appliedNode = doc.field(pendingNode, 15);
|
|
240
|
-
if (appliedNode >= 0) {
|
|
241
|
-
if (doc.kind(appliedNode) !== "array" || doc.size(appliedNode) !== pending.desired)
|
|
242
|
-
failure("source_state_unknown");
|
|
243
|
-
pending.applied = [];
|
|
244
|
-
for (let item = doc.firstChild(appliedNode); item >= 0; item = doc.nextSibling(item)) {
|
|
245
|
-
if (doc.size(item) !== 5)
|
|
246
|
-
failure("source_state_unknown");
|
|
247
|
-
pending.applied.push({ sequence: doc.uint(field(0, item)), generation: doc.uint(field(1, item)), expiry: doc.uint(field(2, item)),
|
|
248
|
-
digest: bytes(doc, field(3, item), 32), identity: bytes(doc, field(4, item), 32) });
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
if ((state === "installed" || state === "acked") && (pending.responseDigest === undefined || pending.highest === undefined || pending.gap === undefined || pending.gap !== (pending.retired !== undefined) || pending.applied === undefined))
|
|
252
|
-
failure("source_state_unknown");
|
|
253
|
-
if (state === "pending" && (pending.frontier !== result.frontier || [pending.responseDigest, pending.highest, pending.gap, pending.retired, pending.error, pending.applied].some(value => value !== undefined)) || state === "terminal" && pending.error === undefined)
|
|
254
|
-
failure("source_state_unknown");
|
|
255
|
-
if (pending.applied !== undefined) {
|
|
256
|
-
if (pending.highest === undefined || pending.highest !== result.frontier || pending.highest < BigInt(pending.desired))
|
|
257
|
-
failure("source_state_unknown");
|
|
258
|
-
let expected = pending.highest - BigInt(pending.desired) + 1n;
|
|
259
|
-
if (pending.retired === undefined ? expected !== pending.frontier + 1n : pending.retired < pending.frontier || expected !== pending.retired + 1n)
|
|
260
|
-
failure("source_state_unknown");
|
|
261
|
-
let appliedGeneration = 0n;
|
|
262
|
-
for (const entry of pending.applied) {
|
|
263
|
-
if (entry.sequence !== expected++ || entry.sequence > result.frontier || entry.generation < pending.generation ||
|
|
264
|
-
entry.generation > pending.attemptGeneration || entry.expiry === 0n ||
|
|
265
|
-
!entry.digest.some(byte => byte !== 0) || !equalCredential(entry.identity, pending.identity))
|
|
266
|
-
failure("source_state_unknown");
|
|
267
|
-
if (appliedGeneration === 0n)
|
|
268
|
-
appliedGeneration = entry.generation;
|
|
269
|
-
else if (appliedGeneration !== entry.generation)
|
|
270
|
-
failure("source_state_unknown");
|
|
271
|
-
const receipt = result.applied.find(original => original.sequence === entry.sequence);
|
|
272
|
-
if (receipt === undefined || receipt.generation !== entry.generation || receipt.expiry !== entry.expiry ||
|
|
273
|
-
!equalCredential(receipt.digest, entry.digest) || !equalCredential(receipt.identity, entry.identity))
|
|
274
|
-
failure("source_state_unknown");
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
const sequence = new DataView(pending.id.buffer, pending.id.byteOffset, 8).getBigUint64(0);
|
|
278
|
-
if (sequence + 1n !== result.next || sequence <= result.retired && state !== "acked" && state !== "terminal")
|
|
279
|
-
failure("source_state_unknown");
|
|
280
|
-
const intent = new Uint8Array(16384), requestDigest = sha256(this.#intent(pending, new FixedCBORWriter(intent)));
|
|
281
|
-
intent.fill(0);
|
|
282
|
-
if (!equalCredential(requestDigest, pending.requestDigest) || doc.size(pendingNode) !== 12 +
|
|
283
|
-
[pending.responseDigest, pending.highest, pending.gap, pending.retired, pending.error, pending.applied].filter(value => value !== undefined).length)
|
|
284
|
-
failure("source_state_unknown");
|
|
285
|
-
result.pending = pending;
|
|
286
|
-
}
|
|
287
|
-
const array = field(7);
|
|
288
|
-
if (doc.kind(array) !== "array" || doc.size(array) > (this.#configuration.maximumMaterials ?? 8))
|
|
289
|
-
failure("source_state_unknown");
|
|
290
|
-
let previous = 0n;
|
|
291
|
-
for (let item = doc.firstChild(array); item >= 0; item = doc.nextSibling(item)) {
|
|
292
|
-
const material = { sequence: doc.uint(field(0, item)), generation: doc.uint(field(1, item)), expiry: doc.uint(field(2, item)),
|
|
293
|
-
bytes: bytes(doc, field(3, item)), digest: bytes(doc, field(4, item), 32), identity: bytes(doc, field(5, item), 32) };
|
|
294
|
-
if (doc.size(item) !== 6 || material.sequence <= previous || material.sequence > result.frontier || material.bytes.length > 65536 || !equalCredential(sha256(material.bytes), material.digest))
|
|
295
|
-
failure("source_state_unknown");
|
|
296
|
-
const receipt = result.applied.find(entry => entry.sequence === material.sequence);
|
|
297
|
-
if (receipt === undefined || (receipt.generation !== material.generation || receipt.expiry !== material.expiry ||
|
|
298
|
-
!equalCredential(receipt.digest, material.digest) || !equalCredential(receipt.identity, material.identity)))
|
|
299
|
-
failure("source_state_unknown");
|
|
300
|
-
previous = material.sequence;
|
|
301
|
-
result.materials.push(material);
|
|
302
|
-
}
|
|
303
|
-
return result;
|
|
304
|
-
});
|
|
305
|
-
}
|
|
306
|
-
/** @internal */
|
|
307
|
-
async initialize() {
|
|
308
|
-
this.#check();
|
|
309
|
-
this.#active++;
|
|
310
|
-
const claim = Array.from(this.#configuration.sourceIncarnation, byte => byte.toString(16).padStart(2, "0")).join("");
|
|
311
|
-
let original = claims.get(this.#store);
|
|
312
|
-
if (original === undefined) {
|
|
313
|
-
original = new Map();
|
|
314
|
-
claims.set(this.#store, original);
|
|
315
|
-
}
|
|
316
|
-
if (original.has(claim)) {
|
|
317
|
-
this.#active--;
|
|
318
|
-
this.close();
|
|
319
|
-
failure("operation_conflict");
|
|
320
|
-
}
|
|
321
|
-
original.set(claim, this);
|
|
322
|
-
this.#claim = claim;
|
|
323
|
-
try {
|
|
324
|
-
const value = await this.#store.readPoolJournal(this.#configuration.sourceIncarnation, () => this.#check());
|
|
325
|
-
if (this.#configuration.create) {
|
|
326
|
-
if (value !== undefined)
|
|
327
|
-
failure("source_state_unknown");
|
|
328
|
-
this.#journal = { next: 1n, retired: 0n, frontier: 0n, applied: [], materials: [], fenced: false };
|
|
329
|
-
await this.#commit(this.#journal);
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
if (value === undefined)
|
|
333
|
-
failure("source_state_unknown");
|
|
334
|
-
this.#encoded = value;
|
|
335
|
-
this.#journal = this.#decode(value);
|
|
336
|
-
}
|
|
337
|
-
this.#source = this.#environment.registerSource(this.#policy, "preauthorized_pool", (request, buffers) => this.#acquireInstalled(request.signal, buffers));
|
|
338
|
-
bindCredentialSourceFacade(this.#source, this);
|
|
339
|
-
Object.freeze(this);
|
|
340
|
-
return this;
|
|
341
|
-
}
|
|
342
|
-
catch (error) {
|
|
343
|
-
this.close();
|
|
344
|
-
throw error;
|
|
345
|
-
}
|
|
346
|
-
finally {
|
|
347
|
-
this.#active--;
|
|
348
|
-
this.#collect();
|
|
349
|
-
}
|
|
350
|
-
}
|
|
351
|
-
async #commit(next, check) {
|
|
352
|
-
this.#check();
|
|
353
|
-
if (this.#mutation)
|
|
354
|
-
failure("operation_conflict");
|
|
355
|
-
this.#mutation = true;
|
|
356
|
-
const buffer = new Uint8Array(1048576);
|
|
357
|
-
try {
|
|
358
|
-
const encoded = snapshot(buffer, this.#policy.tenant, this.#configuration.sourceIncarnation, next);
|
|
359
|
-
await this.#store.comparePoolJournal(this.#configuration.sourceIncarnation, this.#encoded, encoded, () => { this.#check(); check?.(); });
|
|
360
|
-
this.#encoded?.fill(0);
|
|
361
|
-
this.#encoded = new Uint8Array(encoded);
|
|
362
|
-
this.#journal = next;
|
|
363
|
-
if (next.pending !== undefined) {
|
|
364
|
-
const id = Array.from(next.pending.id, byte => byte.toString(16).padStart(2, "0")).join("");
|
|
365
|
-
if (this.#observations.has(id))
|
|
366
|
-
this.#operation(next.pending);
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
catch (error) {
|
|
370
|
-
if (error.writeState === "unknown" || error.writeState === "committed")
|
|
371
|
-
this.close();
|
|
372
|
-
throw error;
|
|
373
|
-
}
|
|
374
|
-
finally {
|
|
375
|
-
buffer.fill(0);
|
|
376
|
-
this.#mutation = false;
|
|
377
|
-
}
|
|
378
|
-
}
|
|
379
|
-
acquire(requirements, options) {
|
|
380
|
-
this.#check();
|
|
381
|
-
return this.#source.acquire(requirements, options).then(owner => new V4ConnectionMaterial(owner));
|
|
382
|
-
}
|
|
383
|
-
async #acquireInstalled(signal, buffers) {
|
|
384
|
-
this.#active++;
|
|
385
|
-
let removed;
|
|
386
|
-
try {
|
|
387
|
-
this.#check();
|
|
388
|
-
if (this.#journal.fenced)
|
|
389
|
-
failure("source_state_unknown");
|
|
390
|
-
signal.throwIfAborted();
|
|
391
|
-
if (this.#mutation)
|
|
392
|
-
failure("source_unavailable");
|
|
393
|
-
const now = this.#environment.clock.sample().requireInterval();
|
|
394
|
-
const material = this.#journal.materials.find(entry => entry.expiry > now.upperMS && equalCredential(entry.identity, this.#identityDigest));
|
|
395
|
-
if (material === undefined)
|
|
396
|
-
failure("source_exhausted");
|
|
397
|
-
const decoded = this.#configuration.decodeMaterial(material.bytes);
|
|
398
|
-
if (!equalCredential(decoded.clientCertificate, this.#configuration.identityCertificate))
|
|
399
|
-
failure("relink_required");
|
|
400
|
-
// Remove availability durably before exposing bytes. Uncertain storage never
|
|
401
|
-
// makes this artifact available again, including after process recovery.
|
|
402
|
-
await this.#commit({ ...this.#journal, materials: this.#journal.materials.filter(entry => entry !== material) });
|
|
403
|
-
removed = material;
|
|
404
|
-
signal.throwIfAborted();
|
|
405
|
-
const lengths = { artifact: decoded.artifact.length, clientCertificate: decoded.clientCertificate.length,
|
|
406
|
-
...(decoded.poolServerAllow === undefined ? {} : { poolServerAllow: decoded.poolServerAllow }),
|
|
407
|
-
serverCertificate: decoded.serverCertificate.length, activation: decoded.activation?.length ?? 0, candidateIndex: decoded.candidateIndex };
|
|
408
|
-
for (const name of ["artifact", "clientCertificate", "serverCertificate", "activation"]) {
|
|
409
|
-
const value = decoded[name];
|
|
410
|
-
if (value !== undefined) {
|
|
411
|
-
if (value.length > buffers[name].length)
|
|
412
|
-
failure("source_contract_invalid");
|
|
413
|
-
buffers[name].set(value);
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
if (decoded.tunnel !== undefined) {
|
|
417
|
-
const grant = decoded.tunnel.grant ?? new Uint8Array(), certificate = decoded.tunnel.relayCertificate;
|
|
418
|
-
if (grant.length > buffers.tunnelGrant.length || certificate.length > buffers.relayCertificate.length)
|
|
419
|
-
failure("source_contract_invalid");
|
|
420
|
-
buffers.tunnelGrant.set(grant);
|
|
421
|
-
buffers.relayCertificate.set(certificate);
|
|
422
|
-
const candidates = decoded.tunnel.candidateGrants ?? [];
|
|
423
|
-
if (candidates.length > (buffers.tunnelCandidates?.length ?? 0))
|
|
424
|
-
failure("source_contract_invalid");
|
|
425
|
-
const tunnelCandidates = candidates.map((candidate, index) => {
|
|
426
|
-
const destination = buffers.tunnelCandidates[index];
|
|
427
|
-
if (candidate.grant.length > destination.grant.length || candidate.relayCertificate.length > destination.relayCertificate.length)
|
|
428
|
-
failure("source_contract_invalid");
|
|
429
|
-
destination.grant.set(candidate.grant);
|
|
430
|
-
destination.relayCertificate.set(candidate.relayCertificate);
|
|
431
|
-
return Object.freeze({ candidateIndex: candidate.candidateIndex, grant: candidate.grant.length, relayCertificate: candidate.relayCertificate.length });
|
|
432
|
-
});
|
|
433
|
-
return { ...lengths, tunnelGrant: grant.length, relayCertificate: certificate.length, tunnelCandidates: Object.freeze(tunnelCandidates) };
|
|
434
|
-
}
|
|
435
|
-
return lengths;
|
|
436
|
-
}
|
|
437
|
-
finally {
|
|
438
|
-
removed?.bytes.fill(0);
|
|
439
|
-
this.#active--;
|
|
440
|
-
this.#collect();
|
|
441
|
-
}
|
|
442
|
-
}
|
|
443
|
-
cleanupStatus() { return Object.freeze({ status: this.#active === 0 ? "complete" : "pending", core_cleanup: this.#active === 0 ? "complete" : "pending", pending_callbacks: BigInt(this.#active) }); }
|
|
444
|
-
#operation(pending) {
|
|
445
|
-
const key = Array.from(pending.id, byte => byte.toString(16).padStart(2, "0")).join("");
|
|
446
|
-
let original = this.#observations.get(key);
|
|
447
|
-
if (original === undefined) {
|
|
448
|
-
// Completed older owners are retained by their own handles, rather than
|
|
449
|
-
// by an ever-growing source registry. Only active tails stay registered.
|
|
450
|
-
for (const [id, entry] of this.#observations)
|
|
451
|
-
if (entry.active === 0)
|
|
452
|
-
this.#observations.delete(id);
|
|
453
|
-
if (this.#observations.size >= 8 || pending.state === "terminal")
|
|
454
|
-
failure("capacity_exhausted");
|
|
455
|
-
original = { source: this, id: new Uint8Array(pending.id), desired: pending.desired, maximum: pending.maximum,
|
|
456
|
-
state: pending.state, active: 0, handle: undefined, waiters: new Set() };
|
|
457
|
-
original.handle = new V4TopUpHandle(handleToken, original);
|
|
458
|
-
this.#observations.set(key, original);
|
|
459
|
-
}
|
|
460
|
-
original.state = pending.state;
|
|
461
|
-
original.error = pending.error;
|
|
462
|
-
if (pending.responseDigest !== undefined)
|
|
463
|
-
original.responseDigest = new Uint8Array(pending.responseDigest);
|
|
464
|
-
return original;
|
|
465
|
-
}
|
|
466
|
-
#observe(pending, error) {
|
|
467
|
-
if (pending !== undefined)
|
|
468
|
-
return operationResult(this.#operation(pending), error);
|
|
469
|
-
return Object.freeze({ ...(error === undefined ? {} : { callError: error }), cleanupStatus: this.cleanupStatus() });
|
|
470
|
-
}
|
|
471
|
-
async topUp(options = {}, wait = {}) {
|
|
472
|
-
try {
|
|
473
|
-
this.#check();
|
|
474
|
-
wait.signal?.throwIfAborted();
|
|
475
|
-
const desired = options.desiredCount ?? 4, maximum = options.maxItemBytes ?? 65536;
|
|
476
|
-
if (!Number.isSafeInteger(desired) || desired < 1 || desired > 4 || !Number.isSafeInteger(maximum) || maximum < 1 || maximum > 65536)
|
|
477
|
-
failure("configuration_capacity");
|
|
478
|
-
if (this.#working === undefined) {
|
|
479
|
-
this.#active++;
|
|
480
|
-
this.#working = this.#run(desired, maximum).catch(error => this.#observe(this.#journal.pending, this.#error(error))).then(result => {
|
|
481
|
-
const original = this.#runningObservation;
|
|
482
|
-
this.#runningObservation = undefined;
|
|
483
|
-
this.#working = undefined;
|
|
484
|
-
this.#active--;
|
|
485
|
-
if (original !== undefined)
|
|
486
|
-
original.active--;
|
|
487
|
-
this.#collect();
|
|
488
|
-
return Object.freeze({ ...result, cleanupStatus: result.handle?.cleanupStatus() ?? this.cleanupStatus() });
|
|
489
|
-
});
|
|
490
|
-
}
|
|
491
|
-
return await this.#wait(this.#working, wait.signal);
|
|
492
|
-
}
|
|
493
|
-
catch (error) {
|
|
494
|
-
return this.#observe(undefined, this.#error(error));
|
|
495
|
-
}
|
|
496
|
-
}
|
|
497
|
-
async topUpStatus(handle, wait = {}) {
|
|
498
|
-
// Capture the original operation's proven projection before cancellation,
|
|
499
|
-
// source lifecycle or current-journal checks can fail.
|
|
500
|
-
const original = handles.get(handle);
|
|
501
|
-
if (original?.source !== this)
|
|
502
|
-
return this.#observe(undefined, "stale_operation");
|
|
503
|
-
if (this.#active >= 8)
|
|
504
|
-
return operationResult(original, "capacity_exhausted");
|
|
505
|
-
this.#active++;
|
|
506
|
-
original.active++;
|
|
507
|
-
let error;
|
|
508
|
-
try {
|
|
509
|
-
this.#check();
|
|
510
|
-
wait.signal?.throwIfAborted();
|
|
511
|
-
const pending = this.#journal.pending;
|
|
512
|
-
if (pending === undefined || !equalCredential(original.id, pending.id))
|
|
513
|
-
failure("stale_operation");
|
|
514
|
-
original.state = pending.state;
|
|
515
|
-
original.error = pending.error;
|
|
516
|
-
if (pending.responseDigest !== undefined)
|
|
517
|
-
original.responseDigest = new Uint8Array(pending.responseDigest);
|
|
518
|
-
await this.#proof(pending, this.#observationSignal(wait.signal), original);
|
|
519
|
-
wait.signal?.throwIfAborted();
|
|
520
|
-
const current = this.#journal.pending;
|
|
521
|
-
if (current !== undefined && equalCredential(original.id, current.id)) {
|
|
522
|
-
original.state = current.state;
|
|
523
|
-
original.error = current.error;
|
|
524
|
-
if (current.responseDigest !== undefined)
|
|
525
|
-
original.responseDigest = new Uint8Array(current.responseDigest);
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
catch (failure) {
|
|
529
|
-
error = this.#error(failure);
|
|
530
|
-
}
|
|
531
|
-
finally {
|
|
532
|
-
original.active--;
|
|
533
|
-
this.#active--;
|
|
534
|
-
this.#collect();
|
|
535
|
-
operationSettled(original);
|
|
536
|
-
}
|
|
537
|
-
return operationResult(original, error);
|
|
538
|
-
}
|
|
539
|
-
async recoverPendingTopUps(tenant, incarnation, wait = {}) {
|
|
540
|
-
if (this.#active >= 8)
|
|
541
|
-
return Object.freeze({ handles: Object.freeze([]), callError: "capacity_exhausted" });
|
|
542
|
-
this.#active++;
|
|
543
|
-
let observation;
|
|
544
|
-
try {
|
|
545
|
-
this.#check();
|
|
546
|
-
wait.signal?.throwIfAborted();
|
|
547
|
-
if (tenant !== this.#policy.tenant || !equalCredential(incarnation, this.#configuration.sourceIncarnation))
|
|
548
|
-
failure("permission_denied");
|
|
549
|
-
const pending = this.#journal.pending;
|
|
550
|
-
if (pending === undefined || pending.state === "terminal" || pending.state === "acked")
|
|
551
|
-
return Object.freeze({ handles: Object.freeze([]) });
|
|
552
|
-
observation = this.#operation(pending);
|
|
553
|
-
observation.active++;
|
|
554
|
-
await this.#proof(pending, this.#observationSignal(wait.signal), observation);
|
|
555
|
-
wait.signal?.throwIfAborted();
|
|
556
|
-
return Object.freeze({ handles: Object.freeze([observation.handle]) });
|
|
557
|
-
}
|
|
558
|
-
catch (error) {
|
|
559
|
-
return Object.freeze({ handles: Object.freeze([]), callError: this.#error(error) });
|
|
560
|
-
}
|
|
561
|
-
finally {
|
|
562
|
-
if (observation !== undefined)
|
|
563
|
-
observation.active--;
|
|
564
|
-
this.#active--;
|
|
565
|
-
this.#collect();
|
|
566
|
-
if (observation !== undefined)
|
|
567
|
-
operationSettled(observation);
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
#observationSignal(signal) {
|
|
571
|
-
return AbortSignal.any([this.#abort.signal, AbortSignal.timeout(Number(this.#configuration.callTimeoutMS)), ...(signal === undefined ? [] : [signal])]);
|
|
572
|
-
}
|
|
573
|
-
async #proof(pending, signal, observation) {
|
|
574
|
-
this.#check();
|
|
575
|
-
const generation = originalPoolJournal(this.#store, this.#environment).generation();
|
|
576
|
-
signal.throwIfAborted();
|
|
577
|
-
const proofEnd = this.#environment.clock.sample().requireInterval().lowerMS + this.#configuration.callTimeoutMS;
|
|
578
|
-
const proof = await this.#borrow(() => this.#configuration.ownerFenceProof(Object.freeze({ tenant: this.#policy.tenant,
|
|
579
|
-
sourceIncarnation: new Uint8Array(this.#configuration.sourceIncarnation), operationID: new Uint8Array(pending.id),
|
|
580
|
-
requestDigest: new Uint8Array(pending.requestDigest), currentGeneration: generation, deadlineMS: proofEnd }), signal), signal, observation);
|
|
581
|
-
this.#check();
|
|
582
|
-
signal.throwIfAborted();
|
|
583
|
-
if (proof.length > 512 || generation !== originalPoolJournal(this.#store, this.#environment).generation())
|
|
584
|
-
failure("stale_generation");
|
|
585
|
-
this.#parse("OwnerFenceProof", proof, (map, work) => {
|
|
586
|
-
work.verify(map, this.#configuration.fenceAuthorityPublicKey);
|
|
587
|
-
const now = this.#environment.clock.sample().requireInterval();
|
|
588
|
-
if (map.text("tenant_id") !== this.#policy.tenant || !equalCredential(map.bytes("source_incarnation"), this.#configuration.sourceIncarnation) ||
|
|
589
|
-
!equalCredential(map.bytes("operation_id"), pending.id) || !equalCredential(map.bytes("request_digest"), pending.requestDigest) ||
|
|
590
|
-
map.uint("current_generation") !== generation || !equalCredential(map.bytes("authority_key_id"), this.#configuration.fenceAuthorityKeyID) ||
|
|
591
|
-
map.uint("issued_at_ms") > now.lowerMS || map.uint("expires_at_ms") <= now.upperMS || map.uint("expires_at_ms") > proofEnd)
|
|
592
|
-
failure("permission_denied");
|
|
593
|
-
});
|
|
594
|
-
return { bytes: new Uint8Array(proof), generation };
|
|
595
|
-
}
|
|
596
|
-
#intent(pending, writer) {
|
|
597
|
-
return writer.map(8).uint(0).data(pending.id).uint(1).data(new TextEncoder().encode(this.#policy.tenant), true)
|
|
598
|
-
.uint(2).data(this.#configuration.sourceIncarnation).uint(3).uint(pending.desired).uint(4).uint(pending.maximum)
|
|
599
|
-
.uint(5).data(pending.pool).uint(8).uint(pending.deadline).uint(9).data(pending.identity).result();
|
|
600
|
-
}
|
|
601
|
-
async #run(desired, maximum) {
|
|
602
|
-
this.#check();
|
|
603
|
-
if (this.#journal.fenced)
|
|
604
|
-
failure("source_state_unknown");
|
|
605
|
-
let pending = this.#journal.pending, observation;
|
|
606
|
-
if (pending === undefined || pending.state === "acked" || pending.state === "terminal") {
|
|
607
|
-
if (this.#journal.next === 0xffffffffffffffffn)
|
|
608
|
-
failure("source_reset_required");
|
|
609
|
-
const interval = this.#environment.clock.sample().requireInterval(), id = new Uint8Array(16), generation = originalPoolJournal(this.#store, this.#environment).generation();
|
|
610
|
-
new DataView(id.buffer).setBigUint64(0, this.#journal.next);
|
|
611
|
-
crypto.getRandomValues(id.subarray(8));
|
|
612
|
-
pending = { id, state: "pending", desired, maximum, pool: new Uint8Array(this.#configuration.poolDigest),
|
|
613
|
-
generation, attemptGeneration: generation, frontier: this.#journal.frontier, deadline: interval.lowerMS + this.#configuration.operationLifetimeMS,
|
|
614
|
-
certificate: new Uint8Array(this.#configuration.identityCertificate), identity: new Uint8Array(this.#identityDigest), requestDigest: new Uint8Array(32) };
|
|
615
|
-
const intent = new Uint8Array(16384);
|
|
616
|
-
pending.requestDigest = sha256(this.#intent(pending, new FixedCBORWriter(intent)));
|
|
617
|
-
intent.fill(0);
|
|
618
|
-
observation = this.#operation(pending);
|
|
619
|
-
observation.active++;
|
|
620
|
-
this.#runningObservation = observation;
|
|
621
|
-
await this.#commit({ ...this.#journal, next: this.#journal.next + 1n, pending });
|
|
622
|
-
}
|
|
623
|
-
else {
|
|
624
|
-
observation = this.#operation(pending);
|
|
625
|
-
observation.active++;
|
|
626
|
-
this.#runningObservation = observation;
|
|
627
|
-
}
|
|
628
|
-
// The original append authority remains pending.deadline in the persisted
|
|
629
|
-
// intent and wire request. A separate bounded call window lets the same ID
|
|
630
|
-
// read a committed replay or authoritative terminal after a lost response,
|
|
631
|
-
// without renewing that append deadline or allocating another operation.
|
|
632
|
-
// Installed recovery uses only Applied facts and current fence authority.
|
|
633
|
-
const now = this.#environment.clock.sample().requireInterval();
|
|
634
|
-
const callEnd = now.lowerMS + this.#configuration.callTimeoutMS;
|
|
635
|
-
const deadline = new TrustedDeadline(this.#environment.clock, callEnd);
|
|
636
|
-
deadline.check();
|
|
637
|
-
const stop = new AbortController(), onClose = () => stop.abort();
|
|
638
|
-
this.#abort.signal.addEventListener("abort", onClose, { once: true });
|
|
639
|
-
let timer;
|
|
640
|
-
const tick = () => { try {
|
|
641
|
-
deadline.check();
|
|
642
|
-
timer = setTimeout(tick, timerChunk(deadline.remainingMS()));
|
|
643
|
-
}
|
|
644
|
-
catch {
|
|
645
|
-
stop.abort();
|
|
646
|
-
} };
|
|
647
|
-
tick();
|
|
648
|
-
let proof;
|
|
649
|
-
const buffer = new Uint8Array(524288);
|
|
650
|
-
try {
|
|
651
|
-
proof = await this.#proof(pending, stop.signal, observation);
|
|
652
|
-
deadline.check();
|
|
653
|
-
if (pending.state === "pending") {
|
|
654
|
-
if (!equalCredential(pending.certificate, this.#configuration.identityCertificate) || !equalCredential(pending.identity, this.#identityDigest))
|
|
655
|
-
failure("relink_required");
|
|
656
|
-
const writer = new FixedCBORWriter(buffer).map(10);
|
|
657
|
-
writer.uint(0).data(pending.id).uint(1).data(new TextEncoder().encode(this.#policy.tenant), true).uint(2).data(this.#configuration.sourceIncarnation)
|
|
658
|
-
.uint(3).uint(pending.desired).uint(4).uint(pending.maximum).uint(5).data(pending.pool).uint(6).uint(proof.generation)
|
|
659
|
-
.uint(7).data(proof.bytes).uint(8).uint(pending.deadline).uint(9).data(pending.identity);
|
|
660
|
-
pending = await this.#persistAttempt(pending, proof.generation);
|
|
661
|
-
deadline.check();
|
|
662
|
-
const response = await this.#exchange(41006, writer.result(), stop.signal, observation);
|
|
663
|
-
this.#check();
|
|
664
|
-
deadline.check();
|
|
665
|
-
if (response.kind === "error")
|
|
666
|
-
return await this.#wireError(pending, response.error);
|
|
667
|
-
if (response.kind !== "success" && response.kind !== "replay")
|
|
668
|
-
failure("source_contract_invalid");
|
|
669
|
-
pending = await this.#apply(pending, response.response);
|
|
670
|
-
buffer.fill(0);
|
|
671
|
-
}
|
|
672
|
-
proof.bytes.fill(0);
|
|
673
|
-
proof = await this.#proof(pending, stop.signal, observation);
|
|
674
|
-
const currentProof = proof, writer = new FixedCBORWriter(buffer).reset().map(pending.retired === undefined ? 9 : 10);
|
|
675
|
-
writer.uint(0).data(pending.id).uint(1).data(pending.pool).uint(2).data(pending.responseDigest).uint(3).uint(pending.highest).uint(4).bool(pending.gap);
|
|
676
|
-
if (pending.retired !== undefined)
|
|
677
|
-
writer.uint(5).uint(pending.retired);
|
|
678
|
-
writer.uint(6).bool(true).uint(7).data(pending.requestDigest).uint(8).uint(currentProof.generation).uint(9).data(currentProof.bytes);
|
|
679
|
-
pending = await this.#persistAttempt(pending, currentProof.generation);
|
|
680
|
-
deadline.check();
|
|
681
|
-
const ack = await this.#exchange(41007, writer.result(), stop.signal, observation);
|
|
682
|
-
this.#check();
|
|
683
|
-
deadline.check();
|
|
684
|
-
if (ack.kind === "error")
|
|
685
|
-
return await this.#wireError(pending, ack.error);
|
|
686
|
-
if (ack.kind !== "acknowledged")
|
|
687
|
-
failure("source_contract_invalid");
|
|
688
|
-
pending = { ...pending, state: "acked" };
|
|
689
|
-
const sequence = new DataView(pending.id.buffer, pending.id.byteOffset, 8).getBigUint64(0);
|
|
690
|
-
await this.#commit({ ...this.#journal, pending, retired: sequence });
|
|
691
|
-
return this.#observe(pending);
|
|
692
|
-
}
|
|
693
|
-
finally {
|
|
694
|
-
if (timer !== undefined)
|
|
695
|
-
clearTimeout(timer);
|
|
696
|
-
this.#abort.signal.removeEventListener("abort", onClose);
|
|
697
|
-
buffer.fill(0);
|
|
698
|
-
proof?.bytes.fill(0);
|
|
699
|
-
}
|
|
700
|
-
}
|
|
701
|
-
async #persistAttempt(pending, generation) {
|
|
702
|
-
// One durable high-water fence bounds all possible sends of this intent.
|
|
703
|
-
// A commit refusal sends nothing; an unknown commit closes this owner and
|
|
704
|
-
// leaves its persisted Pending facts for explicit recovery after restart.
|
|
705
|
-
const check = () => {
|
|
706
|
-
if (generation < pending.attemptGeneration || generation !== originalPoolJournal(this.#store, this.#environment).generation())
|
|
707
|
-
failure("stale_generation");
|
|
708
|
-
};
|
|
709
|
-
check();
|
|
710
|
-
if (this.#journal.pending !== pending)
|
|
711
|
-
failure("operation_conflict");
|
|
712
|
-
const attempt = { ...pending, attemptGeneration: generation };
|
|
713
|
-
await this.#commit({ ...this.#journal, pending: attempt }, check);
|
|
714
|
-
check();
|
|
715
|
-
return attempt;
|
|
716
|
-
}
|
|
717
|
-
async #wireError(pending, error) {
|
|
718
|
-
const projection = topUpErrorProjection(error.code, error.write_action);
|
|
719
|
-
if (projection === undefined || projection.scope !== error.scope)
|
|
720
|
-
failure("source_contract_invalid");
|
|
721
|
-
if (error.write_action === "terminal") {
|
|
722
|
-
const terminal = { ...pending, state: "terminal", error: error.code };
|
|
723
|
-
const { pending: removed, ...journal } = this.#journal;
|
|
724
|
-
void removed;
|
|
725
|
-
await this.#commit({ ...journal, retired: new DataView(pending.id.buffer, pending.id.byteOffset, 8).getBigUint64(0) });
|
|
726
|
-
return this.#observe(terminal, error.code);
|
|
727
|
-
}
|
|
728
|
-
return this.#observe(pending, error.code);
|
|
729
|
-
}
|
|
730
|
-
async #apply(pending, encoded) {
|
|
731
|
-
if (encoded.length > 524288 || pending.attemptGeneration < pending.generation || pending.attemptGeneration > originalPoolJournal(this.#store, this.#environment).generation())
|
|
732
|
-
failure("source_contract_invalid");
|
|
733
|
-
const applied = this.#parse("TopUpResponse", encoded, map => {
|
|
734
|
-
const bindingGeneration = map.uint("binding_generation");
|
|
735
|
-
// Authenticated replay can name any server commit generation between
|
|
736
|
-
// local intent creation and the highest durably committed attempt. A G1
|
|
737
|
-
// intent may first commit at G2 and replay under G3. Preserve creation
|
|
738
|
-
// generation while pinning the response generation in Applied/material
|
|
739
|
-
// facts; every entry must match that same response generation.
|
|
740
|
-
if (bindingGeneration < pending.generation || bindingGeneration > pending.attemptGeneration ||
|
|
741
|
-
!equalCredential(map.bytes("operation_id"), pending.id) || map.text("tenant_id") !== this.#policy.tenant ||
|
|
742
|
-
!equalCredential(map.bytes("source_incarnation"), this.#configuration.sourceIncarnation) || !map.doc.boolean(map.field("server_committed")))
|
|
743
|
-
failure("source_contract_invalid");
|
|
744
|
-
const projection = new Uint8Array(encoded.length), size = map.doc.copyWithoutField(9, projection), digest = sha256(projection.subarray(0, size));
|
|
745
|
-
projection.fill(0);
|
|
746
|
-
if (!equalCredential(digest, map.bytes("response_digest")))
|
|
747
|
-
failure("source_contract_invalid");
|
|
748
|
-
const materials = [], gap = map.doc.boolean(map.field("gap_authorized")), retiredNode = map.optional("retired_artifact_through");
|
|
749
|
-
const retired = retiredNode < 0 ? undefined : map.doc.uint(retiredNode), highest = map.uint("server_highest_artifact_sequence");
|
|
750
|
-
if (this.#journal.frontier !== pending.frontier || gap !== (retired !== undefined) || retired !== undefined && retired < pending.frontier)
|
|
751
|
-
failure("sequence_gap");
|
|
752
|
-
let expected = gap ? retired + 1n : pending.frontier + 1n;
|
|
753
|
-
for (const node of map.items("entries")) {
|
|
754
|
-
const bytes = map.bytes("material", node, "TopUpEntry");
|
|
755
|
-
const entry = { bytes, sequence: map.uint("artifact_sequence", node, "TopUpEntry"), generation: map.uint("binding_generation", node, "TopUpEntry"),
|
|
756
|
-
expiry: map.uint("expiry_ms", node, "TopUpEntry"), digest: map.bytes("material_digest", node, "TopUpEntry"), identity: map.bytes("client_identity_digest", node, "TopUpEntry") };
|
|
757
|
-
if (entry.sequence !== expected++ || entry.generation !== bindingGeneration || entry.bytes.length + canonicalHeadBytes(BigInt(entry.bytes.length)) > pending.maximum ||
|
|
758
|
-
!equalCredential(sha256(entry.bytes), entry.digest) || !equalCredential(entry.identity, pending.identity))
|
|
759
|
-
failure("source_contract_invalid");
|
|
760
|
-
materials.push(entry);
|
|
761
|
-
}
|
|
762
|
-
if (materials.length !== pending.desired || expected - 1n !== highest || this.#journal.materials.length + materials.length > (this.#configuration.maximumMaterials ?? 8))
|
|
763
|
-
failure("capacity_exhausted");
|
|
764
|
-
return { materials, pending: { ...pending, state: "installed", responseDigest: digest, highest, gap,
|
|
765
|
-
applied: materials.map(({ sequence, generation, expiry, digest, identity }) => ({ sequence, generation, expiry, digest: new Uint8Array(digest), identity: new Uint8Array(identity) })), ...(retired === undefined ? {} : { retired }) } };
|
|
766
|
-
});
|
|
767
|
-
// Nothing is published to Acquire before all signed entries verify and the
|
|
768
|
-
// same original durable transaction installs material plus Applied facts.
|
|
769
|
-
for (const entry of applied.materials) {
|
|
770
|
-
this.#check();
|
|
771
|
-
const now = this.#environment.clock.sample().requireInterval();
|
|
772
|
-
if (entry.expiry <= now.upperMS)
|
|
773
|
-
failure("relink_required");
|
|
774
|
-
const input = this.#configuration.decodeMaterial(entry.bytes);
|
|
775
|
-
if (!equalCredential(input.clientCertificate, pending.certificate))
|
|
776
|
-
failure("source_contract_invalid");
|
|
777
|
-
const material = this.#environment.verify(this.#policy, { ...input, source: "preauthorized_pool" });
|
|
778
|
-
try {
|
|
779
|
-
this.#environment.checkOriginalPoolMaterialExpiry(material, entry.expiry, originalPoolJournal(this.#store, this.#environment).reference());
|
|
780
|
-
}
|
|
781
|
-
finally {
|
|
782
|
-
await material.closeMaterial();
|
|
783
|
-
}
|
|
784
|
-
}
|
|
785
|
-
if (this.#journal.pending?.state !== "pending" || !equalCredential(this.#journal.pending.id, pending.id))
|
|
786
|
-
failure("operation_conflict");
|
|
787
|
-
await this.#commit({ ...this.#journal, pending: applied.pending, frontier: applied.pending.highest, applied: [...this.#journal.applied, ...(applied.pending.applied ?? [])].filter((entry, index, entries) => entries.length - index <= 48 || this.#journal.materials.some(material => material.sequence === entry.sequence)), materials: [...this.#journal.materials, ...applied.materials] });
|
|
788
|
-
return applied.pending;
|
|
789
|
-
}
|
|
790
|
-
async #borrow(provider, signal, observation, cleanup) {
|
|
791
|
-
signal.throwIfAborted();
|
|
792
|
-
if (this.#active >= 8)
|
|
793
|
-
failure("capacity_exhausted");
|
|
794
|
-
this.#active++;
|
|
795
|
-
observation.active++;
|
|
796
|
-
const physical = Promise.resolve().then(provider).finally(() => {
|
|
797
|
-
try {
|
|
798
|
-
cleanup?.();
|
|
799
|
-
}
|
|
800
|
-
finally {
|
|
801
|
-
observation.active--;
|
|
802
|
-
this.#active--;
|
|
803
|
-
this.#collect();
|
|
804
|
-
operationSettled(observation);
|
|
805
|
-
}
|
|
806
|
-
});
|
|
807
|
-
let cancel;
|
|
808
|
-
try {
|
|
809
|
-
return await Promise.race([physical, new Promise((_, reject) => {
|
|
810
|
-
cancel = () => reject(new Error("canceled"));
|
|
811
|
-
signal.addEventListener("abort", cancel, { once: true });
|
|
812
|
-
if (signal.aborted)
|
|
813
|
-
cancel();
|
|
814
|
-
})]);
|
|
815
|
-
}
|
|
816
|
-
finally {
|
|
817
|
-
if (cancel !== undefined)
|
|
818
|
-
signal.removeEventListener("abort", cancel);
|
|
819
|
-
}
|
|
820
|
-
}
|
|
821
|
-
async #exchange(method, request, signal, observation) {
|
|
822
|
-
signal.throwIfAborted();
|
|
823
|
-
if (this.#active >= 8)
|
|
824
|
-
failure("capacity_exhausted");
|
|
825
|
-
const owned = new Uint8Array(request);
|
|
826
|
-
return await this.#borrow(() => this.#configuration.control.exchange(method, owned, signal), signal, observation, () => owned.fill(0));
|
|
827
|
-
}
|
|
828
|
-
#error(error) {
|
|
829
|
-
if (error instanceof Error && topUpErrorProjection(error.message, "none") !== undefined)
|
|
830
|
-
return error.message;
|
|
831
|
-
if (error instanceof Error && (error.name === "AbortError" || error.message === "canceled"))
|
|
832
|
-
return "canceled";
|
|
833
|
-
if (error instanceof Error && ["time_expired", "time_deadline_unrepresentable"].includes(error.message))
|
|
834
|
-
return "deadline_exceeded";
|
|
835
|
-
return "source_unavailable";
|
|
836
|
-
}
|
|
837
|
-
async #wait(work, signal) {
|
|
838
|
-
if (signal === undefined)
|
|
839
|
-
return await work;
|
|
840
|
-
let stop;
|
|
841
|
-
try {
|
|
842
|
-
return await Promise.race([work, new Promise(resolve => {
|
|
843
|
-
stop = () => {
|
|
844
|
-
const pending = this.#journal.pending, original = this.#runningObservation;
|
|
845
|
-
resolve(this.#observe(this.#working === work && original !== undefined && pending !== undefined && equalCredential(original.id, pending.id) ? pending : undefined, "canceled"));
|
|
846
|
-
};
|
|
847
|
-
signal.addEventListener("abort", stop, { once: true });
|
|
848
|
-
if (signal.aborted)
|
|
849
|
-
stop();
|
|
850
|
-
})]);
|
|
851
|
-
}
|
|
852
|
-
finally {
|
|
853
|
-
if (stop !== undefined)
|
|
854
|
-
signal.removeEventListener("abort", stop);
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
waitCleanup(options = {}) {
|
|
858
|
-
options.signal?.throwIfAborted();
|
|
859
|
-
if (this.#active === 0)
|
|
860
|
-
return Promise.resolve(this.cleanupStatus());
|
|
861
|
-
if (this.#cleanupWaiters.size >= 8)
|
|
862
|
-
return Promise.reject(new Error("capacity_exhausted"));
|
|
863
|
-
return new Promise((resolve, reject) => {
|
|
864
|
-
const finish = () => { this.#cleanupWaiters.delete(finish); options.signal?.removeEventListener("abort", cancel); resolve(this.cleanupStatus()); };
|
|
865
|
-
const cancel = () => { this.#cleanupWaiters.delete(finish); options.signal?.removeEventListener("abort", cancel); reject(new Error("canceled")); };
|
|
866
|
-
this.#cleanupWaiters.add(finish);
|
|
867
|
-
options.signal?.addEventListener("abort", cancel, { once: true });
|
|
868
|
-
if (options.signal?.aborted)
|
|
869
|
-
cancel();
|
|
870
|
-
else if (this.#active === 0)
|
|
871
|
-
finish();
|
|
872
|
-
});
|
|
873
|
-
}
|
|
874
|
-
close() { if (this.#closed)
|
|
875
|
-
return; this.#closed = true; this.#abort.abort(); this.#source?.close(); this.#dependency.close(); this.#collect(); }
|
|
876
|
-
#collect() {
|
|
877
|
-
if (this.#closed && this.#active === 0) {
|
|
878
|
-
this.#encoded?.fill(0);
|
|
879
|
-
this.#encoded = undefined;
|
|
880
|
-
this.#configuration.identityCertificate.fill(0);
|
|
881
|
-
this.#keys.signingPublicKey.fill(0);
|
|
882
|
-
this.#keys.noisePublicKey.fill(0);
|
|
883
|
-
for (const material of this.#journal?.materials ?? [])
|
|
884
|
-
material.bytes.fill(0);
|
|
885
|
-
if (this.#claim !== undefined)
|
|
886
|
-
claims.get(this.#store)?.delete(this.#claim);
|
|
887
|
-
this.#dependency.release();
|
|
888
|
-
}
|
|
889
|
-
for (const original of this.#observations.values())
|
|
890
|
-
operationSettled(original);
|
|
891
|
-
if (this.#active === 0)
|
|
892
|
-
for (const observe of [...this.#cleanupWaiters])
|
|
893
|
-
observe();
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
/** @internal Installed by the actual Node/Browser client with its immutable
|
|
897
|
-
* original Ed25519 and static DH handles, never caller-supplied fake key facts. */
|
|
898
|
-
export async function createOriginalPoolSource(environment, policy, store, configuration, keys) {
|
|
899
|
-
return await new V4PreauthorizedPoolSource(sourceToken, environment, policy, store, configuration, keys).initialize();
|
|
900
|
-
}
|