@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.
Files changed (712) hide show
  1. package/README.md +101 -170
  2. package/THIRD_PARTY_NOTICES.md +7 -3072
  3. package/dist/browser/connectSessionV3.d.ts +44 -0
  4. package/dist/browser/connectSessionV3.js +261 -0
  5. package/dist/browser/directWebSocketProfileV1.d.ts +14 -0
  6. package/dist/browser/directWebSocketProfileV1.js +71 -0
  7. package/dist/browser/httpDirectV1.d.ts +30 -0
  8. package/dist/browser/httpDirectV1.js +52 -0
  9. package/dist/browser/index.d.ts +10 -15
  10. package/dist/browser/index.js +4 -5
  11. package/dist/browser/privateLoopbackV1.d.ts +30 -0
  12. package/dist/browser/privateLoopbackV1.js +70 -0
  13. package/dist/cli.d.ts +1 -24
  14. package/dist/cli.js +129 -91
  15. package/dist/cliSpendMarker.js +8 -0
  16. package/dist/defaults.d.ts +23 -1
  17. package/dist/defaults.js +23 -1
  18. package/dist/facade.d.ts +21 -104
  19. package/dist/facade.js +8 -45
  20. package/dist/framing/jsonframe.d.ts +21 -0
  21. package/dist/framing/jsonframe.js +107 -0
  22. package/dist/node/acceptor.d.ts +1 -0
  23. package/dist/node/acceptor.js +1 -0
  24. package/dist/node/acceptorV3.d.ts +70 -0
  25. package/dist/node/acceptorV3.js +295 -0
  26. package/dist/node/byteStreamDuplex.d.ts +4 -0
  27. package/dist/node/byteStreamDuplex.js +69 -0
  28. package/dist/node/connectSessionV3.d.ts +33 -0
  29. package/dist/node/connectSessionV3.js +93 -0
  30. package/dist/node/connectionPath.d.ts +0 -2
  31. package/dist/node/connectionPath.js +0 -18
  32. package/dist/node/index.d.ts +16 -52
  33. package/dist/node/index.js +6 -24
  34. package/dist/node/listenerIngress.d.ts +5 -0
  35. package/dist/node/listenerIngress.js +12 -0
  36. package/dist/node/nativeTransportAddon.d.ts +142 -0
  37. package/dist/node/nativeTransportAddon.js +235 -0
  38. package/dist/node/proxyServer.d.ts +4 -30
  39. package/dist/node/proxyServer.js +169 -600
  40. package/dist/node/rawQuicAdapterV3.d.ts +11 -0
  41. package/dist/node/rawQuicAdapterV3.js +83 -0
  42. package/dist/node/rawQuicServerV3.d.ts +34 -0
  43. package/dist/node/rawQuicServerV3.js +60 -0
  44. package/dist/node/runtimeAuthorizationV3.d.ts +41 -0
  45. package/dist/node/runtimeAuthorizationV3.js +156 -0
  46. package/dist/node/tunnelRuntimeV3.d.ts +60 -0
  47. package/dist/node/tunnelRuntimeV3.js +837 -0
  48. package/dist/node/webSocketServerV3.d.ts +28 -0
  49. package/dist/node/webSocketServerV3.js +220 -0
  50. package/dist/proxy/fetch.d.ts +2 -3
  51. package/dist/proxy/fetch.js +29 -96
  52. package/dist/proxy/index.d.ts +1 -5
  53. package/dist/proxy/index.js +0 -2
  54. package/dist/proxy/integration.d.ts +8 -12
  55. package/dist/proxy/integration.js +16 -23
  56. package/dist/proxy/policy.d.ts +0 -5
  57. package/dist/proxy/policy.js +22 -60
  58. package/dist/proxy/runtime.d.ts +1 -3
  59. package/dist/proxy/runtime.js +186 -404
  60. package/dist/proxy/scope.js +2 -2
  61. package/dist/proxy/serviceWorker.d.ts +0 -3
  62. package/dist/proxy/serviceWorker.js +176 -634
  63. package/dist/proxy/serviceWorkerRuntime.js +1 -26
  64. package/dist/proxy/stream.d.ts +6 -17
  65. package/dist/proxy/stream.js +40 -9
  66. package/dist/proxy/types.d.ts +11 -50
  67. package/dist/proxy/windowBridge.d.ts +3 -11
  68. package/dist/proxy/windowBridge.js +31 -70
  69. package/dist/proxy/wsPatch.js +26 -34
  70. package/dist/public/contract.d.ts +74 -1
  71. package/dist/public/contract.js +8 -0
  72. package/dist/public/sessionHandlers.d.ts +47 -0
  73. package/dist/public/sessionHandlers.js +151 -0
  74. package/dist/public/streamHandlers.d.ts +20 -0
  75. package/dist/public/streamHandlers.js +127 -0
  76. package/dist/public/streamMetadata.d.ts +2 -34
  77. package/dist/public/streamMetadata.js +13 -206
  78. package/dist/rpc/client.d.ts +34 -0
  79. package/dist/rpc/client.js +244 -0
  80. package/dist/rpc/server.d.ts +59 -0
  81. package/dist/rpc/server.js +255 -0
  82. package/dist/rpc/validate.d.ts +4 -0
  83. package/dist/{application/rpcJSON.js → rpc/validate.js} +1 -1
  84. package/dist/rpc/wire.d.ts +15 -0
  85. package/dist/v3/admissionError.d.ts +4 -0
  86. package/dist/v3/admissionError.js +8 -0
  87. package/dist/v3/artifact.d.ts +145 -0
  88. package/dist/v3/artifact.js +1180 -0
  89. package/dist/v3/artifactLease.d.ts +19 -0
  90. package/dist/v3/artifactLease.js +128 -0
  91. package/dist/v3/browserRuntime.d.ts +37 -0
  92. package/dist/v3/browserRuntime.js +197 -0
  93. package/dist/v3/browserSessionRuntime.d.ts +2 -0
  94. package/dist/v3/browserSessionRuntime.js +21 -0
  95. package/dist/v3/capability.d.ts +32 -0
  96. package/dist/v3/capability.js +345 -0
  97. package/dist/v3/carrier.d.ts +86 -0
  98. package/dist/v3/carrier.js +414 -0
  99. package/dist/v3/connectionController.d.ts +101 -0
  100. package/dist/v3/connectionController.js +888 -0
  101. package/dist/v3/contract.d.ts +70 -0
  102. package/dist/v3/contract.js +3 -0
  103. package/dist/v3/controller.d.ts +45 -0
  104. package/dist/v3/controller.js +316 -0
  105. package/dist/v3/handshake.d.ts +81 -0
  106. package/dist/v3/handshake.js +471 -0
  107. package/dist/v3/jcs.d.ts +6 -0
  108. package/dist/v3/jcs.js +69 -0
  109. package/dist/v3/jsonPreflight.d.ts +1 -0
  110. package/dist/v3/jsonPreflight.js +251 -0
  111. package/dist/v3/nodeRuntime.d.ts +43 -0
  112. package/dist/v3/nodeRuntime.js +437 -0
  113. package/dist/v3/nodeSessionRuntime.d.ts +2 -0
  114. package/dist/v3/nodeSessionRuntime.js +13 -0
  115. package/dist/v3/protocol.d.ts +100 -0
  116. package/dist/v3/protocol.js +715 -0
  117. package/dist/v3/publicApi.d.ts +12 -0
  118. package/dist/v3/publicApi.js +46 -0
  119. package/dist/v3/publicSession.js +316 -0
  120. package/dist/v3/runtimeAdapters.d.ts +9 -0
  121. package/dist/v3/runtimeAdapters.js +109 -0
  122. package/dist/v3/security.d.ts +36 -0
  123. package/dist/v3/security.js +113 -0
  124. package/dist/v3/serverAdmission.d.ts +42 -0
  125. package/dist/v3/serverAdmission.js +242 -0
  126. package/dist/v3/session.d.ts +339 -0
  127. package/dist/v3/session.js +2399 -0
  128. package/dist/v3/sessionConnector.d.ts +46 -0
  129. package/dist/v3/sessionConnector.js +534 -0
  130. package/dist/v3/streamLifetimeLedger.d.ts +32 -0
  131. package/dist/v3/streamLifetimeLedger.js +146 -0
  132. package/dist/v3/streamMetadata.js +7 -0
  133. package/dist/v3/transportConstants.d.ts +56 -0
  134. package/dist/v3/transportConstants.js +59 -0
  135. package/dist/v3/tunnelIngress.d.ts +8 -0
  136. package/dist/v3/tunnelIngress.js +21 -0
  137. package/dist/v3/unreliableMessage.d.ts +44 -0
  138. package/dist/v3/unreliableMessage.js +287 -0
  139. package/dist/v3/webSocketCarrier.d.ts +33 -0
  140. package/dist/v3/webSocketCarrier.js +380 -0
  141. package/dist/v3/webTransportCarrier.d.ts +27 -0
  142. package/dist/v3/webTransportCarrier.js +580 -0
  143. package/dist/ws-client/binaryTransport.d.ts +65 -0
  144. package/dist/ws-client/binaryTransport.js +348 -0
  145. package/dist/yamux/byteReader.d.ts +13 -0
  146. package/dist/yamux/byteReader.js +81 -0
  147. package/dist/yamux/constants.d.ts +10 -0
  148. package/dist/yamux/constants.js +14 -0
  149. package/dist/yamux/errors.d.ts +15 -0
  150. package/dist/yamux/errors.js +34 -0
  151. package/dist/yamux/header.d.ts +20 -0
  152. package/dist/yamux/header.js +30 -0
  153. package/dist/yamux/session.d.ts +81 -0
  154. package/dist/yamux/session.js +401 -0
  155. package/dist/yamux/stream.d.ts +42 -0
  156. package/dist/yamux/stream.js +307 -0
  157. package/package.json +20 -19
  158. package/sbom/cyclonedx.json +43 -761
  159. package/sbom/spdx.json +49 -566
  160. package/dist/application/rpcJSON.d.ts +0 -15
  161. package/dist/browser/clientV4.d.ts +0 -61
  162. package/dist/browser/clientV4.js +0 -179
  163. package/dist/browser/indexedDBPoolV4.d.ts +0 -101
  164. package/dist/browser/indexedDBPoolV4.js +0 -634
  165. package/dist/browser/liveHTTPSV4.d.ts +0 -35
  166. package/dist/browser/liveHTTPSV4.js +0 -162
  167. package/dist/browser/localBrowserBridge.d.ts +0 -20
  168. package/dist/browser/localBrowserBridge.js +0 -82
  169. package/dist/browser/poolServerAllow.d.ts +0 -21
  170. package/dist/browser/poolServerAllow.js +0 -151
  171. package/dist/browser/webTransportPositionsV4.d.ts +0 -16
  172. package/dist/browser/webTransportPositionsV4.js +0 -75
  173. package/dist/browser/webTransportStreamV4.d.ts +0 -36
  174. package/dist/browser/webTransportStreamV4.js +0 -370
  175. package/dist/browser/webTransportV4.d.ts +0 -126
  176. package/dist/browser/webTransportV4.js +0 -627
  177. package/dist/browser/wssV4.d.ts +0 -69
  178. package/dist/browser/wssV4.js +0 -339
  179. package/dist/generated/brotliWorker.d.ts +0 -1
  180. package/dist/generated/brotliWorker.js +0 -3
  181. package/dist/generated/idna151.d.ts +0 -2
  182. package/dist/generated/idna151.js +0 -38
  183. package/dist/generated/normalization151.d.ts +0 -5
  184. package/dist/generated/normalization151.js +0 -878
  185. package/dist/generated/sqliteWorkers.d.ts +0 -2
  186. package/dist/generated/sqliteWorkers.js +0 -3
  187. package/dist/generated/transportV4APIResults.d.ts +0 -145
  188. package/dist/generated/transportV4APIResults.js +0 -52
  189. package/dist/generated/transportV4Registry.d.ts +0 -3758
  190. package/dist/generated/transportV4Registry.js +0 -29
  191. package/dist/interop/browserRunner.d.ts +0 -72
  192. package/dist/interop/browserRunner.js +0 -354
  193. package/dist/interop/currentClock.d.ts +0 -3
  194. package/dist/interop/currentClock.js +0 -39
  195. package/dist/interop/currentContracts.d.ts +0 -6
  196. package/dist/interop/currentContracts.js +0 -14
  197. package/dist/interop/currentNativeTunnel.d.ts +0 -31
  198. package/dist/interop/currentNativeTunnel.js +0 -185
  199. package/dist/interop/currentParity.d.ts +0 -68
  200. package/dist/interop/currentParity.js +0 -392
  201. package/dist/interop/currentPeer.d.ts +0 -252
  202. package/dist/interop/currentPeer.js +0 -677
  203. package/dist/interop/currentRegisteredTunnelPeer.d.ts +0 -37
  204. package/dist/interop/currentRegisteredTunnelPeer.js +0 -93
  205. package/dist/interop/currentRelayPeer.d.ts +0 -131
  206. package/dist/interop/currentRelayPeer.js +0 -263
  207. package/dist/interop/currentServer.d.ts +0 -44
  208. package/dist/interop/currentServer.js +0 -299
  209. package/dist/interop/currentTLSPin.d.ts +0 -9
  210. package/dist/interop/currentTLSPin.js +0 -44
  211. package/dist/interop/currentTunnelMaterial.d.ts +0 -34
  212. package/dist/interop/currentTunnelMaterial.js +0 -100
  213. package/dist/interop/httpApplicationPeer.d.ts +0 -15
  214. package/dist/interop/httpApplicationPeer.js +0 -167
  215. package/dist/interop/invalidProofPeer.d.ts +0 -8
  216. package/dist/interop/invalidProofPeer.js +0 -106
  217. package/dist/interop/proxyServerPeer.js +0 -49
  218. package/dist/interop/serverParityPeer.d.ts +0 -101
  219. package/dist/interop/serverParityPeer.js +0 -609
  220. package/dist/node/acceptorCurrent.d.ts +0 -55
  221. package/dist/node/acceptorCurrent.js +0 -286
  222. package/dist/node/admissionRecord.d.ts +0 -23
  223. package/dist/node/admissionRecord.js +0 -178
  224. package/dist/node/clientV4.d.ts +0 -59
  225. package/dist/node/clientV4.js +0 -197
  226. package/dist/node/endpointDialer.d.ts +0 -70
  227. package/dist/node/endpointDialer.js +0 -231
  228. package/dist/node/endpointListener.d.ts +0 -48
  229. package/dist/node/endpointListener.js +0 -403
  230. package/dist/node/endpointTransport.d.ts +0 -7
  231. package/dist/node/endpointTransport.js +0 -18
  232. package/dist/node/grantIssuerCurrent.d.ts +0 -64
  233. package/dist/node/grantIssuerCurrent.js +0 -355
  234. package/dist/node/liveHTTPSV4.d.ts +0 -28
  235. package/dist/node/liveHTTPSV4.js +0 -298
  236. package/dist/node/liveTunnelAuthorityCurrent.d.ts +0 -153
  237. package/dist/node/liveTunnelAuthorityCurrent.js +0 -590
  238. package/dist/node/nativeDuplexBridgeV4.d.ts +0 -41
  239. package/dist/node/nativeDuplexBridgeV4.js +0 -494
  240. package/dist/node/nativeTransportCurrent.d.ts +0 -196
  241. package/dist/node/nativeTransportCurrent.js +0 -37
  242. package/dist/node/poolServerAllow.d.ts +0 -33
  243. package/dist/node/poolServerAllow.js +0 -277
  244. package/dist/node/proxyCredentials.d.ts +0 -67
  245. package/dist/node/proxyCredentials.js +0 -364
  246. package/dist/node/proxyNetwork.d.ts +0 -18
  247. package/dist/node/proxyNetwork.js +0 -213
  248. package/dist/node/rawQUICCurrent.d.ts +0 -139
  249. package/dist/node/rawQUICCurrent.js +0 -1177
  250. package/dist/node/registeredLiveTunnelControl.d.ts +0 -74
  251. package/dist/node/registeredLiveTunnelControl.js +0 -865
  252. package/dist/node/registeredPoolTunnelAuthority.d.ts +0 -50
  253. package/dist/node/registeredPoolTunnelAuthority.js +0 -305
  254. package/dist/node/registeredTunnelControl.d.ts +0 -189
  255. package/dist/node/registeredTunnelControl.js +0 -1007
  256. package/dist/node/registeredWinnerContinuation.d.ts +0 -26
  257. package/dist/node/registeredWinnerContinuation.js +0 -83
  258. package/dist/node/relayNativePair.d.ts +0 -62
  259. package/dist/node/relayNativePair.js +0 -737
  260. package/dist/node/relayRecord.d.ts +0 -57
  261. package/dist/node/relayRecord.js +0 -275
  262. package/dist/node/serveRawQUIC.d.ts +0 -58
  263. package/dist/node/serveRawQUIC.js +0 -331
  264. package/dist/node/serveWSS.d.ts +0 -58
  265. package/dist/node/serveWSS.js +0 -309
  266. package/dist/node/sqliteAdmission.d.ts +0 -100
  267. package/dist/node/sqliteAdmission.js +0 -1185
  268. package/dist/node/sqliteExecutionContentV4.d.ts +0 -63
  269. package/dist/node/sqliteExecutionContentV4.js +0 -251
  270. package/dist/node/sqliteExecutionV4.d.ts +0 -114
  271. package/dist/node/sqliteExecutionV4.js +0 -1052
  272. package/dist/node/sqliteFormat.d.ts +0 -20
  273. package/dist/node/sqliteFormat.js +0 -72
  274. package/dist/node/sqliteInspectionV4.d.ts +0 -7
  275. package/dist/node/sqliteInspectionV4.js +0 -47
  276. package/dist/node/sqliteNativeV4.d.ts +0 -3
  277. package/dist/node/sqliteNativeV4.js +0 -16
  278. package/dist/node/sqlitePoolV4.d.ts +0 -41
  279. package/dist/node/sqlitePoolV4.js +0 -282
  280. package/dist/node/sqlitePoolWorkerProgramV4.js +0 -411
  281. package/dist/node/sqlitePoolWorkerV4.d.ts +0 -67
  282. package/dist/node/sqlitePoolWorkerV4.js +0 -206
  283. package/dist/node/sqliteV4.d.ts +0 -82
  284. package/dist/node/sqliteV4.js +0 -166
  285. package/dist/node/sqliteWorkerProgramV4.js +0 -175
  286. package/dist/node/sqliteWorkerV4.d.ts +0 -47
  287. package/dist/node/sqliteWorkerV4.js +0 -142
  288. package/dist/node/streamDuplexV4.d.ts +0 -33
  289. package/dist/node/streamDuplexV4.js +0 -359
  290. package/dist/node/tunnelListenerPreparation.d.ts +0 -37
  291. package/dist/node/tunnelListenerPreparation.js +0 -162
  292. package/dist/node/tunnelRuntime.d.ts +0 -124
  293. package/dist/node/tunnelRuntime.js +0 -1205
  294. package/dist/node/webTransportCurrent.d.ts +0 -24
  295. package/dist/node/webTransportCurrent.js +0 -12
  296. package/dist/node/wssV4.d.ts +0 -99
  297. package/dist/node/wssV4.js +0 -846
  298. package/dist/proxy/admission.d.ts +0 -21
  299. package/dist/proxy/admission.js +0 -126
  300. package/dist/proxy/brotliBody.d.ts +0 -10
  301. package/dist/proxy/brotliBody.js +0 -85
  302. package/dist/proxy/credentialControl.d.ts +0 -30
  303. package/dist/proxy/credentialControl.js +0 -86
  304. package/dist/proxy/currentStream.d.ts +0 -24
  305. package/dist/proxy/currentStream.js +0 -158
  306. package/dist/proxy/headers.d.ts +0 -8
  307. package/dist/proxy/headers.js +0 -63
  308. package/dist/proxy/publicationOwner.d.ts +0 -10
  309. package/dist/proxy/publicationOwner.js +0 -130
  310. package/dist/proxy/requestAssociation.d.ts +0 -11
  311. package/dist/proxy/requestAssociation.js +0 -8
  312. package/dist/proxy/surface.d.ts +0 -45
  313. package/dist/proxy/surface.js +0 -384
  314. package/dist/proxy/wire.d.ts +0 -11
  315. package/dist/proxy/wire.js +0 -214
  316. package/dist/public/streamKind.d.ts +0 -3
  317. package/dist/public/streamKind.js +0 -19
  318. package/dist/testSupport/tlsFixture.d.ts +0 -2
  319. package/dist/testSupport/tlsFixture.js +0 -8
  320. package/dist/v4/admissionOffer.d.ts +0 -8
  321. package/dist/v4/admissionOffer.js +0 -1
  322. package/dist/v4/checkpoint.d.ts +0 -23
  323. package/dist/v4/checkpoint.js +0 -16
  324. package/dist/v4/clientServices.d.ts +0 -35
  325. package/dist/v4/clientServices.js +0 -11
  326. package/dist/v4/connectionDiagnostic.d.ts +0 -42
  327. package/dist/v4/connectionDiagnostic.js +0 -45
  328. package/dist/v4/connectionRequirements.d.ts +0 -5
  329. package/dist/v4/connectionRequirements.js +0 -34
  330. package/dist/v4/controller.d.ts +0 -122
  331. package/dist/v4/controller.js +0 -1161
  332. package/dist/v4/controllerNotifications.d.ts +0 -81
  333. package/dist/v4/controllerNotifications.js +0 -610
  334. package/dist/v4/diagnostics.d.ts +0 -44
  335. package/dist/v4/diagnostics.js +0 -9
  336. package/dist/v4/drain.d.ts +0 -39
  337. package/dist/v4/drain.js +0 -80
  338. package/dist/v4/duplexBridge.d.ts +0 -53
  339. package/dist/v4/duplexBridge.js +0 -446
  340. package/dist/v4/entrypoints.d.ts +0 -20
  341. package/dist/v4/entrypoints.js +0 -50
  342. package/dist/v4/eventSource.d.ts +0 -34
  343. package/dist/v4/eventSource.js +0 -28
  344. package/dist/v4/handlerPlan.d.ts +0 -53
  345. package/dist/v4/handlerPlan.js +0 -129
  346. package/dist/v4/liveness.d.ts +0 -20
  347. package/dist/v4/liveness.js +0 -10
  348. package/dist/v4/localReport.d.ts +0 -17
  349. package/dist/v4/localReport.js +0 -10
  350. package/dist/v4/messageDefinition.d.ts +0 -66
  351. package/dist/v4/messageDefinition.js +0 -109
  352. package/dist/v4/messageStream.d.ts +0 -89
  353. package/dist/v4/messageStream.js +0 -1375
  354. package/dist/v4/notificationOperation.d.ts +0 -30
  355. package/dist/v4/notificationOperation.js +0 -31
  356. package/dist/v4/notificationSubscription.d.ts +0 -47
  357. package/dist/v4/notificationSubscription.js +0 -24
  358. package/dist/v4/operationReference.d.ts +0 -28
  359. package/dist/v4/operationReference.js +0 -61
  360. package/dist/v4/operationReferenceCodec.d.ts +0 -20
  361. package/dist/v4/operationReferenceCodec.js +0 -129
  362. package/dist/v4/operationReferenceStore.d.ts +0 -90
  363. package/dist/v4/operationReferenceStore.js +0 -272
  364. package/dist/v4/operationResultRead.d.ts +0 -26
  365. package/dist/v4/operationResultRead.js +0 -24
  366. package/dist/v4/poolControl.d.ts +0 -11
  367. package/dist/v4/poolControl.js +0 -50
  368. package/dist/v4/poolSource.d.ts +0 -93
  369. package/dist/v4/poolSource.js +0 -900
  370. package/dist/v4/profileDHReference.d.ts +0 -2
  371. package/dist/v4/profileDHReference.js +0 -42
  372. package/dist/v4/public.d.ts +0 -232
  373. package/dist/v4/public.js +0 -632
  374. package/dist/v4/responsePublication.d.ts +0 -48
  375. package/dist/v4/responsePublication.js +0 -227
  376. package/dist/v4/resume.d.ts +0 -17
  377. package/dist/v4/resume.js +0 -15
  378. package/dist/v4/runtime/applicationExecutor.d.ts +0 -190
  379. package/dist/v4/runtime/applicationExecutor.js +0 -759
  380. package/dist/v4/runtime/applicationHeader.d.ts +0 -61
  381. package/dist/v4/runtime/applicationHeader.js +0 -222
  382. package/dist/v4/runtime/canonicalText.d.ts +0 -8
  383. package/dist/v4/runtime/canonicalText.js +0 -142
  384. package/dist/v4/runtime/cbor.d.ts +0 -92
  385. package/dist/v4/runtime/cbor.js +0 -728
  386. package/dist/v4/runtime/cborWriter.d.ts +0 -18
  387. package/dist/v4/runtime/cborWriter.js +0 -59
  388. package/dist/v4/runtime/checkpointToken.d.ts +0 -41
  389. package/dist/v4/runtime/checkpointToken.js +0 -61
  390. package/dist/v4/runtime/clientAdmission.d.ts +0 -40
  391. package/dist/v4/runtime/clientAdmission.js +0 -378
  392. package/dist/v4/runtime/clientSessionSpec.d.ts +0 -45
  393. package/dist/v4/runtime/clientSessionSpec.js +0 -91
  394. package/dist/v4/runtime/clock.d.ts +0 -80
  395. package/dist/v4/runtime/clock.js +0 -284
  396. package/dist/v4/runtime/connectionFacts.d.ts +0 -23
  397. package/dist/v4/runtime/connectionFacts.js +0 -106
  398. package/dist/v4/runtime/contractAcceptance.d.ts +0 -20
  399. package/dist/v4/runtime/contractAcceptance.js +0 -91
  400. package/dist/v4/runtime/contractQuery.d.ts +0 -57
  401. package/dist/v4/runtime/contractQuery.js +0 -265
  402. package/dist/v4/runtime/contractQueryAccess.d.ts +0 -25
  403. package/dist/v4/runtime/contractQueryAccess.js +0 -117
  404. package/dist/v4/runtime/contractQueryAcquisition.d.ts +0 -83
  405. package/dist/v4/runtime/contractQueryAcquisition.js +0 -572
  406. package/dist/v4/runtime/contractQueryClient.d.ts +0 -70
  407. package/dist/v4/runtime/contractQueryClient.js +0 -411
  408. package/dist/v4/runtime/contractQueryCodecs.d.ts +0 -20
  409. package/dist/v4/runtime/contractQueryCodecs.js +0 -71
  410. package/dist/v4/runtime/contractQueryExchange.d.ts +0 -36
  411. package/dist/v4/runtime/contractQueryExchange.js +0 -160
  412. package/dist/v4/runtime/contractQueryService.d.ts +0 -42
  413. package/dist/v4/runtime/contractQueryService.js +0 -572
  414. package/dist/v4/runtime/contractQuerySession.d.ts +0 -38
  415. package/dist/v4/runtime/contractQuerySession.js +0 -158
  416. package/dist/v4/runtime/contractRoutes.d.ts +0 -87
  417. package/dist/v4/runtime/contractRoutes.js +0 -396
  418. package/dist/v4/runtime/contractSnapshotReader.d.ts +0 -59
  419. package/dist/v4/runtime/contractSnapshotReader.js +0 -418
  420. package/dist/v4/runtime/contractSnapshotWriter.d.ts +0 -32
  421. package/dist/v4/runtime/contractSnapshotWriter.js +0 -208
  422. package/dist/v4/runtime/controllerServiceSource.d.ts +0 -23
  423. package/dist/v4/runtime/controllerServiceSource.js +0 -109
  424. package/dist/v4/runtime/controllerUnaryRoute.d.ts +0 -28
  425. package/dist/v4/runtime/controllerUnaryRoute.js +0 -1
  426. package/dist/v4/runtime/credentialNamespace.d.ts +0 -143
  427. package/dist/v4/runtime/credentialNamespace.js +0 -1286
  428. package/dist/v4/runtime/credentialSupport.d.ts +0 -60
  429. package/dist/v4/runtime/credentialSupport.js +0 -294
  430. package/dist/v4/runtime/credentialVerifier.d.ts +0 -404
  431. package/dist/v4/runtime/credentialVerifier.js +0 -1443
  432. package/dist/v4/runtime/cryptoUsage.d.ts +0 -135
  433. package/dist/v4/runtime/cryptoUsage.js +0 -552
  434. package/dist/v4/runtime/deadline.d.ts +0 -31
  435. package/dist/v4/runtime/deadline.js +0 -188
  436. package/dist/v4/runtime/diagnosticCounters.d.ts +0 -15
  437. package/dist/v4/runtime/diagnosticCounters.js +0 -78
  438. package/dist/v4/runtime/diagnosticObservation.d.ts +0 -25
  439. package/dist/v4/runtime/diagnosticObservation.js +0 -67
  440. package/dist/v4/runtime/diagnosticSink.d.ts +0 -16
  441. package/dist/v4/runtime/diagnosticSink.js +0 -320
  442. package/dist/v4/runtime/ed25519.d.ts +0 -1
  443. package/dist/v4/runtime/ed25519.js +0 -34
  444. package/dist/v4/runtime/endpointHop.d.ts +0 -12
  445. package/dist/v4/runtime/endpointHop.js +0 -26
  446. package/dist/v4/runtime/envelope.d.ts +0 -66
  447. package/dist/v4/runtime/envelope.js +0 -275
  448. package/dist/v4/runtime/environment.d.ts +0 -277
  449. package/dist/v4/runtime/environment.js +0 -1913
  450. package/dist/v4/runtime/executionManagementChannel.d.ts +0 -27
  451. package/dist/v4/runtime/executionManagementChannel.js +0 -733
  452. package/dist/v4/runtime/executionManagementCodec.d.ts +0 -84
  453. package/dist/v4/runtime/executionManagementCodec.js +0 -127
  454. package/dist/v4/runtime/executionStorage.d.ts +0 -71
  455. package/dist/v4/runtime/executionStorage.js +0 -10
  456. package/dist/v4/runtime/fixedDiagnosticExecutor.d.ts +0 -34
  457. package/dist/v4/runtime/fixedDiagnosticExecutor.js +0 -149
  458. package/dist/v4/runtime/fixedManagementExecutor.d.ts +0 -21
  459. package/dist/v4/runtime/fixedManagementExecutor.js +0 -153
  460. package/dist/v4/runtime/fixedQueryExecutor.d.ts +0 -46
  461. package/dist/v4/runtime/fixedQueryExecutor.js +0 -311
  462. package/dist/v4/runtime/grantDigest.d.ts +0 -9
  463. package/dist/v4/runtime/grantDigest.js +0 -31
  464. package/dist/v4/runtime/hopAuthentication.d.ts +0 -51
  465. package/dist/v4/runtime/hopAuthentication.js +0 -392
  466. package/dist/v4/runtime/host.d.ts +0 -15
  467. package/dist/v4/runtime/host.js +0 -332
  468. package/dist/v4/runtime/initializerWorkload.d.ts +0 -38
  469. package/dist/v4/runtime/initializerWorkload.js +0 -164
  470. package/dist/v4/runtime/lifecycle.d.ts +0 -5
  471. package/dist/v4/runtime/lifecycle.js +0 -17
  472. package/dist/v4/runtime/liveAuthorization.d.ts +0 -42
  473. package/dist/v4/runtime/liveAuthorization.js +0 -133
  474. package/dist/v4/runtime/liveAuthorizationWire.d.ts +0 -8
  475. package/dist/v4/runtime/liveAuthorizationWire.js +0 -31
  476. package/dist/v4/runtime/liveCarrierPreparation.d.ts +0 -9
  477. package/dist/v4/runtime/liveCarrierPreparation.js +0 -27
  478. package/dist/v4/runtime/liveness.d.ts +0 -37
  479. package/dist/v4/runtime/liveness.js +0 -319
  480. package/dist/v4/runtime/maintenancePositions.d.ts +0 -29
  481. package/dist/v4/runtime/maintenancePositions.js +0 -152
  482. package/dist/v4/runtime/messageCodec.d.ts +0 -20
  483. package/dist/v4/runtime/messageCodec.js +0 -192
  484. package/dist/v4/runtime/namespaceContinuity.d.ts +0 -20
  485. package/dist/v4/runtime/namespaceContinuity.js +0 -176
  486. package/dist/v4/runtime/nativeCandidates.d.ts +0 -18
  487. package/dist/v4/runtime/nativeCandidates.js +0 -109
  488. package/dist/v4/runtime/nativeFailure.d.ts +0 -10
  489. package/dist/v4/runtime/nativeFailure.js +0 -32
  490. package/dist/v4/runtime/nativeFrame.d.ts +0 -47
  491. package/dist/v4/runtime/nativeFrame.js +0 -318
  492. package/dist/v4/runtime/nativeIngress.d.ts +0 -30
  493. package/dist/v4/runtime/nativeIngress.js +0 -177
  494. package/dist/v4/runtime/nativePositions.d.ts +0 -24
  495. package/dist/v4/runtime/nativePositions.js +0 -131
  496. package/dist/v4/runtime/nativeProviderPositions.d.ts +0 -16
  497. package/dist/v4/runtime/nativeProviderPositions.js +0 -75
  498. package/dist/v4/runtime/nativeSend.d.ts +0 -15
  499. package/dist/v4/runtime/nativeSend.js +0 -57
  500. package/dist/v4/runtime/noiseHandshake.d.ts +0 -70
  501. package/dist/v4/runtime/noiseHandshake.js +0 -373
  502. package/dist/v4/runtime/noiseWasmBinary.d.ts +0 -2
  503. package/dist/v4/runtime/noiseWasmBinary.js +0 -3
  504. package/dist/v4/runtime/notifyChannel.d.ts +0 -37
  505. package/dist/v4/runtime/notifyChannel.js +0 -277
  506. package/dist/v4/runtime/notifyDispatch.d.ts +0 -108
  507. package/dist/v4/runtime/notifyDispatch.js +0 -717
  508. package/dist/v4/runtime/notifyExecution.d.ts +0 -18
  509. package/dist/v4/runtime/notifyExecution.js +0 -59
  510. package/dist/v4/runtime/notifyPreparation.d.ts +0 -70
  511. package/dist/v4/runtime/notifyPreparation.js +0 -465
  512. package/dist/v4/runtime/openAdmission.d.ts +0 -125
  513. package/dist/v4/runtime/openAdmission.js +0 -810
  514. package/dist/v4/runtime/peerOpenPreparation.d.ts +0 -18
  515. package/dist/v4/runtime/peerOpenPreparation.js +0 -61
  516. package/dist/v4/runtime/poolJournal.d.ts +0 -18
  517. package/dist/v4/runtime/poolJournal.js +0 -14
  518. package/dist/v4/runtime/poolJournalStorage.d.ts +0 -4
  519. package/dist/v4/runtime/poolJournalStorage.js +0 -172
  520. package/dist/v4/runtime/poolRecord.d.ts +0 -9
  521. package/dist/v4/runtime/poolRecord.js +0 -23
  522. package/dist/v4/runtime/poolRecordStorage.d.ts +0 -10
  523. package/dist/v4/runtime/poolRecordStorage.js +0 -216
  524. package/dist/v4/runtime/poolServerAllow.d.ts +0 -49
  525. package/dist/v4/runtime/poolServerAllow.js +0 -38
  526. package/dist/v4/runtime/poolSpend.d.ts +0 -20
  527. package/dist/v4/runtime/poolSpend.js +0 -4
  528. package/dist/v4/runtime/queryRenewalPosition.d.ts +0 -59
  529. package/dist/v4/runtime/queryRenewalPosition.js +0 -220
  530. package/dist/v4/runtime/random.d.ts +0 -15
  531. package/dist/v4/runtime/random.js +0 -71
  532. package/dist/v4/runtime/rawStreamPreparation.d.ts +0 -40
  533. package/dist/v4/runtime/rawStreamPreparation.js +0 -125
  534. package/dist/v4/runtime/receiveDirection.d.ts +0 -135
  535. package/dist/v4/runtime/receiveDirection.js +0 -957
  536. package/dist/v4/runtime/receiveWorkspace.d.ts +0 -19
  537. package/dist/v4/runtime/receiveWorkspace.js +0 -82
  538. package/dist/v4/runtime/record.d.ts +0 -7
  539. package/dist/v4/runtime/record.js +0 -173
  540. package/dist/v4/runtime/recordCrypto.d.ts +0 -121
  541. package/dist/v4/runtime/recordCrypto.js +0 -633
  542. package/dist/v4/runtime/recordWorkspace.d.ts +0 -17
  543. package/dist/v4/runtime/recordWorkspace.js +0 -69
  544. package/dist/v4/runtime/registeredCarrierPreparation.d.ts +0 -17
  545. package/dist/v4/runtime/registeredCarrierPreparation.js +0 -191
  546. package/dist/v4/runtime/rekey.d.ts +0 -40
  547. package/dist/v4/runtime/rekey.js +0 -362
  548. package/dist/v4/runtime/relayCredentials.d.ts +0 -126
  549. package/dist/v4/runtime/relayCredentials.js +0 -349
  550. package/dist/v4/runtime/replayWindow.d.ts +0 -6
  551. package/dist/v4/runtime/replayWindow.js +0 -59
  552. package/dist/v4/runtime/resources.d.ts +0 -200
  553. package/dist/v4/runtime/resources.js +0 -1236
  554. package/dist/v4/runtime/resumeCodec.d.ts +0 -44
  555. package/dist/v4/runtime/resumeCodec.js +0 -192
  556. package/dist/v4/runtime/resumeStream.d.ts +0 -23
  557. package/dist/v4/runtime/resumeStream.js +0 -23
  558. package/dist/v4/runtime/rpcApplication.d.ts +0 -234
  559. package/dist/v4/runtime/rpcApplication.js +0 -2170
  560. package/dist/v4/runtime/rpcApplicationServices.d.ts +0 -18
  561. package/dist/v4/runtime/rpcApplicationServices.js +0 -62
  562. package/dist/v4/runtime/rpcCallCapacity.d.ts +0 -62
  563. package/dist/v4/runtime/rpcCallCapacity.js +0 -289
  564. package/dist/v4/runtime/rpcChannel.d.ts +0 -58
  565. package/dist/v4/runtime/rpcChannel.js +0 -334
  566. package/dist/v4/runtime/rpcCompletion.d.ts +0 -42
  567. package/dist/v4/runtime/rpcCompletion.js +0 -152
  568. package/dist/v4/runtime/rpcEventSource.d.ts +0 -27
  569. package/dist/v4/runtime/rpcEventSource.js +0 -201
  570. package/dist/v4/runtime/rpcFragment.d.ts +0 -42
  571. package/dist/v4/runtime/rpcFragment.js +0 -227
  572. package/dist/v4/runtime/rpcInput.d.ts +0 -41
  573. package/dist/v4/runtime/rpcInput.js +0 -137
  574. package/dist/v4/runtime/rpcNetwork.d.ts +0 -143
  575. package/dist/v4/runtime/rpcNetwork.js +0 -652
  576. package/dist/v4/runtime/rpcOutputInterest.d.ts +0 -20
  577. package/dist/v4/runtime/rpcOutputInterest.js +0 -106
  578. package/dist/v4/runtime/rpcPayload.d.ts +0 -24
  579. package/dist/v4/runtime/rpcPayload.js +0 -82
  580. package/dist/v4/runtime/rpcPreacceptedStreams.d.ts +0 -46
  581. package/dist/v4/runtime/rpcPreacceptedStreams.js +0 -406
  582. package/dist/v4/runtime/rpcPublisher.d.ts +0 -49
  583. package/dist/v4/runtime/rpcPublisher.js +0 -406
  584. package/dist/v4/runtime/rpcReceiver.d.ts +0 -40
  585. package/dist/v4/runtime/rpcReceiver.js +0 -255
  586. package/dist/v4/runtime/rpcResumeDispatch.d.ts +0 -46
  587. package/dist/v4/runtime/rpcResumeDispatch.js +0 -266
  588. package/dist/v4/runtime/rpcStream.d.ts +0 -14
  589. package/dist/v4/runtime/rpcStream.js +0 -12
  590. package/dist/v4/runtime/rpcStreamMessages.d.ts +0 -53
  591. package/dist/v4/runtime/rpcStreamMessages.js +0 -428
  592. package/dist/v4/runtime/rpcStreamPreparation.d.ts +0 -21
  593. package/dist/v4/runtime/rpcStreamPreparation.js +0 -110
  594. package/dist/v4/runtime/rpcStreamingDispatch.d.ts +0 -26
  595. package/dist/v4/runtime/rpcStreamingDispatch.js +0 -607
  596. package/dist/v4/runtime/rpcStreamingExchange.d.ts +0 -91
  597. package/dist/v4/runtime/rpcStreamingExchange.js +0 -812
  598. package/dist/v4/runtime/rpcUnaryCall.d.ts +0 -16
  599. package/dist/v4/runtime/rpcUnaryCall.js +0 -152
  600. package/dist/v4/runtime/rpcUnaryDispatch.d.ts +0 -34
  601. package/dist/v4/runtime/rpcUnaryDispatch.js +0 -569
  602. package/dist/v4/runtime/rpcUnaryExchange.d.ts +0 -127
  603. package/dist/v4/runtime/rpcUnaryExchange.js +0 -1042
  604. package/dist/v4/runtime/rpcUnaryPreparation.d.ts +0 -102
  605. package/dist/v4/runtime/rpcUnaryPreparation.js +0 -736
  606. package/dist/v4/runtime/rpcUnaryRegistration.d.ts +0 -33
  607. package/dist/v4/runtime/rpcUnaryRegistration.js +0 -113
  608. package/dist/v4/runtime/rpcUnaryResultRecipient.d.ts +0 -21
  609. package/dist/v4/runtime/rpcUnaryResultRecipient.js +0 -57
  610. package/dist/v4/runtime/schema.d.ts +0 -26
  611. package/dist/v4/runtime/schema.js +0 -668
  612. package/dist/v4/runtime/schemaRegistry.d.ts +0 -128
  613. package/dist/v4/runtime/schemaRegistry.js +0 -74
  614. package/dist/v4/runtime/sendBudget.d.ts +0 -10
  615. package/dist/v4/runtime/sendBudget.js +0 -46
  616. package/dist/v4/runtime/serveGroup.d.ts +0 -73
  617. package/dist/v4/runtime/serveGroup.js +0 -589
  618. package/dist/v4/runtime/serverAdmission.d.ts +0 -33
  619. package/dist/v4/runtime/serverAdmission.js +0 -342
  620. package/dist/v4/runtime/serverAdmissionAuthority.d.ts +0 -23
  621. package/dist/v4/runtime/serverAdmissionAuthority.js +0 -5
  622. package/dist/v4/runtime/serverSessionSpec.d.ts +0 -9
  623. package/dist/v4/runtime/serverSessionSpec.js +0 -12
  624. package/dist/v4/runtime/serviceBinding.d.ts +0 -128
  625. package/dist/v4/runtime/serviceBinding.js +0 -1435
  626. package/dist/v4/runtime/serviceBindingConfig.d.ts +0 -72
  627. package/dist/v4/runtime/serviceBindingConfig.js +0 -85
  628. package/dist/v4/runtime/serviceBindingPool.d.ts +0 -58
  629. package/dist/v4/runtime/serviceBindingPool.js +0 -327
  630. package/dist/v4/runtime/serviceContract.d.ts +0 -111
  631. package/dist/v4/runtime/serviceContract.js +0 -588
  632. package/dist/v4/runtime/serviceInputs.d.ts +0 -30
  633. package/dist/v4/runtime/serviceInputs.js +0 -201
  634. package/dist/v4/runtime/serviceOfferPlan.d.ts +0 -81
  635. package/dist/v4/runtime/serviceOfferPlan.js +0 -335
  636. package/dist/v4/runtime/serviceOfferScheduler.d.ts +0 -12
  637. package/dist/v4/runtime/serviceOfferScheduler.js +0 -201
  638. package/dist/v4/runtime/serviceOfferWork.d.ts +0 -25
  639. package/dist/v4/runtime/serviceOfferWork.js +0 -1
  640. package/dist/v4/runtime/session.d.ts +0 -411
  641. package/dist/v4/runtime/session.js +0 -6369
  642. package/dist/v4/runtime/sessionActivity.d.ts +0 -19
  643. package/dist/v4/runtime/sessionActivity.js +0 -97
  644. package/dist/v4/runtime/sessionAdmission.d.ts +0 -93
  645. package/dist/v4/runtime/sessionAdmission.js +0 -498
  646. package/dist/v4/runtime/sessionCleanup.d.ts +0 -47
  647. package/dist/v4/runtime/sessionCleanup.js +0 -268
  648. package/dist/v4/runtime/sessionKeyPreparation.d.ts +0 -19
  649. package/dist/v4/runtime/sessionKeyPreparation.js +0 -50
  650. package/dist/v4/runtime/signedMap.d.ts +0 -68
  651. package/dist/v4/runtime/signedMap.js +0 -425
  652. package/dist/v4/runtime/streamAdapter.d.ts +0 -113
  653. package/dist/v4/runtime/streamAdapter.js +0 -62
  654. package/dist/v4/runtime/streamData.d.ts +0 -11
  655. package/dist/v4/runtime/streamData.js +0 -50
  656. package/dist/v4/runtime/streamOpenPreparation.d.ts +0 -23
  657. package/dist/v4/runtime/streamOpenPreparation.js +0 -77
  658. package/dist/v4/runtime/streamRegistration.d.ts +0 -87
  659. package/dist/v4/runtime/streamRegistration.js +0 -296
  660. package/dist/v4/runtime/taskObservation.d.ts +0 -1
  661. package/dist/v4/runtime/taskObservation.js +0 -48
  662. package/dist/v4/runtime/timeArithmetic.d.ts +0 -29
  663. package/dist/v4/runtime/timeArithmetic.js +0 -107
  664. package/dist/v4/runtime/unreliable.d.ts +0 -76
  665. package/dist/v4/runtime/unreliable.js +0 -473
  666. package/dist/v4/runtime/volatileExecutions.d.ts +0 -128
  667. package/dist/v4/runtime/volatileExecutions.js +0 -792
  668. package/dist/v4/runtime/wireRegistry.d.ts +0 -52
  669. package/dist/v4/runtime/wireRegistry.js +0 -29
  670. package/dist/v4/runtime/writeRequest.d.ts +0 -42
  671. package/dist/v4/runtime/writeRequest.js +0 -237
  672. package/dist/v4/serve.d.ts +0 -107
  673. package/dist/v4/serve.js +0 -80
  674. package/dist/v4/serviceClient.d.ts +0 -92
  675. package/dist/v4/serviceClient.js +0 -323
  676. package/dist/v4/serviceDefinition.d.ts +0 -138
  677. package/dist/v4/serviceDefinition.js +0 -150
  678. package/dist/v4/serviceDependencies.d.ts +0 -66
  679. package/dist/v4/serviceDependencies.js +0 -250
  680. package/dist/v4/serviceFactory.d.ts +0 -31
  681. package/dist/v4/serviceFactory.js +0 -157
  682. package/dist/v4/serviceHandlers.d.ts +0 -55
  683. package/dist/v4/serviceHandlers.js +0 -15
  684. package/dist/v4/serviceMembers.d.ts +0 -4
  685. package/dist/v4/serviceMembers.js +0 -12
  686. package/dist/v4/staticServiceContracts.d.ts +0 -43
  687. package/dist/v4/staticServiceContracts.js +0 -161
  688. package/dist/v4/storageFormat.d.ts +0 -16
  689. package/dist/v4/storageFormat.js +0 -5
  690. package/dist/v4/streamContent.d.ts +0 -30
  691. package/dist/v4/streamContent.js +0 -29
  692. package/dist/v4/streamHandlers.d.ts +0 -61
  693. package/dist/v4/streamHandlers.js +0 -16
  694. package/dist/v4/streamingOperation.d.ts +0 -64
  695. package/dist/v4/streamingOperation.js +0 -141
  696. package/dist/v4/strictEd25519Reference.d.ts +0 -2
  697. package/dist/v4/strictEd25519Reference.js +0 -37
  698. package/dist/v4/testSupport/cbor.d.ts +0 -124
  699. package/dist/v4/testSupport/cbor.js +0 -230
  700. package/dist/v4/testSupport/credentials.d.ts +0 -55
  701. package/dist/v4/testSupport/credentials.js +0 -111
  702. package/dist/v4/testSupport/unicode.d.ts +0 -19
  703. package/dist/v4/testSupport/unicode.js +0 -112
  704. package/dist/v4/unaryOperation.d.ts +0 -59
  705. package/dist/v4/unaryOperation.js +0 -80
  706. package/dist/v4/unreliable.d.ts +0 -26
  707. package/dist/v4/unreliable.js +0 -10
  708. package/dist/v4/webStreams.d.ts +0 -30
  709. package/dist/v4/webStreams.js +0 -377
  710. /package/dist/{interop/proxyServerPeer.d.ts → rpc/wire.js} +0 -0
  711. /package/dist/{node/sqlitePoolWorkerProgramV4.d.ts → v3/publicSession.d.ts} +0 -0
  712. /package/dist/{node/sqliteWorkerProgramV4.d.ts → v3/streamMetadata.d.ts} +0 -0
@@ -1,1177 +0,0 @@
1
- import { isIP } from "node:net";
2
- import { pinProfile } from "./wssV4.js";
3
- import { createHash, X509Certificate } from "node:crypto";
4
- import { CredentialWork, credentialWorkCharge, equalCredential, requireCredential } from "../v4/runtime/credentialSupport.js";
5
- import { ResourceVector } from "../v4/runtime/resources.js";
6
- import { timerChunk } from "../v4/runtime/deadline.js";
7
- import { NativeDirectionFailure } from "../v4/runtime/nativeFailure.js";
8
- import { NativeProviderPositions, nativeProviderStreamCharge } from "../v4/runtime/nativeProviderPositions.js";
9
- import { HopAuthentication, HopAuthenticationPreparation, hopAuthenticationCharge } from "../v4/runtime/hopAuthentication.js";
10
- import { observeTask } from "../v4/runtime/taskObservation.js";
11
- function nativeFailure(error) {
12
- if (error instanceof NativeDirectionFailure)
13
- return error;
14
- if (error instanceof Error) {
15
- const native = error;
16
- const reason = native.source === "stream" ? native.reason : native.code === "normal_drained" || native.code === "direction_reset" ? native.code : native.message;
17
- if (reason === "normal_drained" || reason === "direction_reset")
18
- return new NativeDirectionFailure(reason);
19
- }
20
- return new Error("carrier_failed");
21
- }
22
- /** A finite local carrier set. Each entry has its own TLS/Origin configuration;
23
- * a verified Route chooses among these entries and never supplies configuration. */
24
- export function captureNodeRawQUICCandidates(inputs) {
25
- requireCredential(Array.isArray(inputs) && inputs.length >= 1 && inputs.length <= 2, "configuration_capacity");
26
- const candidates = [];
27
- try {
28
- for (const input of inputs)
29
- candidates.push(captureNodeRawQUIC(input));
30
- const first = candidates[0];
31
- requireCredential(new Set(candidates.map(value => value.nativeCarrier ?? "raw-quic")).size === candidates.length &&
32
- candidates.every(value => value.applicationStreams === first.applicationStreams), "configuration_capacity");
33
- return Object.freeze(candidates);
34
- }
35
- catch (error) {
36
- for (const value of candidates)
37
- for (const root of value.trustRootsDER ?? [])
38
- root.fill(0);
39
- throw error;
40
- }
41
- }
42
- /** Reserves one independently owned native plan for each possible retry before
43
- * Acquire. Per-attempt vectors take only their actual carrier's bounded share. */
44
- export function nodeRawQUICCandidateAdmissionCosts(maxFrame, candidates, runtimeBytes, attemptLimit) {
45
- requireCredential(Number.isSafeInteger(attemptLimit) && attemptLimit >= 1 && attemptLimit <= 16 && candidates.length >= 1, "configuration_capacity");
46
- const plans = candidates.map(value => nodeRawQUICAdmissionCosts(maxFrame, value, runtimeBytes));
47
- const shape = plans[0];
48
- requireCredential(plans.every(plan => plan.length === shape.length && plan.every((part, index) => part[0] === shape[index][0])), "configuration_capacity");
49
- const maximum = shape.map((part, index) => {
50
- const vectors = plans.map(plan => plan[index][1].values());
51
- return [part[0], new ResourceVector(vectors[0].map((_, dimension) => vectors.reduce((value, current) => current[dimension] > value ? current[dimension] : value, 0n)))];
52
- });
53
- return Object.freeze(Array.from({ length: attemptLimit }, () => [["node_raw_quic_candidate_route", credentialWorkCharge(16384, runtimeBytes)], ...maximum]).flat());
54
- }
55
- export function nodeNativePreparationBudgetCost(runtimeBytes) {
56
- return ["node_native_preparation_budget", new ResourceVector([16384n + runtimeBytes, 65536n, 0n, 1n, 1n, 0n, 0n, 0n, 0n, 0n, 0n])];
57
- }
58
- const preparationOwners = new WeakMap();
59
- export class NodeNativePreparationOwner {
60
- #budget;
61
- #dependency;
62
- #configured = false;
63
- #transferred = false;
64
- #closed = false;
65
- #candidates = new Map();
66
- constructor(runtime, binding, admission) {
67
- requireCredential(typeof binding.createPreparationBudget === "function", "configuration_capacity");
68
- const cost = nodeNativePreparationBudgetCost(runtime.resources.runtimeBytes), reference = admission?.take([cost])[0];
69
- try {
70
- this.#dependency = runtime.admitDependency(cost[0], cost[1], reference, admission);
71
- }
72
- finally {
73
- reference?.release();
74
- }
75
- try {
76
- this.#budget = binding.createPreparationBudget();
77
- this.#dependency.onClose(() => { this.#budget.close(); });
78
- }
79
- catch (error) {
80
- this.#dependency.release();
81
- throw error;
82
- }
83
- }
84
- configure(fields) {
85
- this.#dependency.check();
86
- requireCredential(!this.#closed && !this.#configured, "credential_binding");
87
- const pool = fields.source === "preauthorized_pool";
88
- this.#budget.configure({ preauthInputBytes: pool ? fields.totalPreparationBytes ?? fields.preparationBytes : 1048576,
89
- addressAttempts: pool ? fields.totalCandidateAttempts ?? 1 : 2, workUnits: pool ? fields.totalPreparationWork ?? fields.preparationWork : 4096 });
90
- this.#configured = true;
91
- }
92
- candidate(fields) {
93
- this.#dependency.check();
94
- requireCredential(!this.#closed && this.#configured, "credential_binding");
95
- const pool = fields.source === "preauthorized_pool";
96
- const index = fields.candidateIndex ?? 0;
97
- requireCredential(Number.isSafeInteger(index) && index >= 0 && index < 16, "credential_binding");
98
- const original = this.#candidates.get(index);
99
- if (original !== undefined)
100
- return original;
101
- const candidate = this.#budget.beginCandidate({ preauthInputBytes: pool ? fields.preparationBytes : 1048576,
102
- addressAttempts: pool ? fields.preparationAddressAttempts ?? 1 : 2, workUnits: pool ? fields.preparationWork : 4096 });
103
- this.#candidates.set(index, candidate);
104
- return candidate;
105
- }
106
- transfer(carrier) { requireCredential(!this.#transferred && !this.#closed, "credential_binding"); carrier.retainPreparationOwner(() => this.close()); this.#transferred = true; }
107
- releaseUnused() { if (!this.#transferred)
108
- this.close(); }
109
- close() { if (this.#closed)
110
- return; this.#closed = true; this.#budget.close(); this.#candidates.clear(); this.#dependency.release(); }
111
- }
112
- export function prepayNodeNativePreparationBudget(runtime, admission, binding) {
113
- requireCredential(!preparationOwners.has(admission), "credential_binding");
114
- preparationOwners.set(admission, new NodeNativePreparationOwner(runtime, binding, admission));
115
- }
116
- export function releaseNodeNativePreparationBudget(admission) { preparationOwners.get(admission)?.releaseUnused(); preparationOwners.delete(admission); }
117
- export function originalNodeNativePreparationOwner(runtime, fields, binding, admission) {
118
- const owner = admission === undefined ? new NodeNativePreparationOwner(runtime, binding) : preparationOwners.get(admission);
119
- requireCredential(owner !== undefined, "configuration_capacity");
120
- try {
121
- owner.configure(fields);
122
- return owner;
123
- }
124
- catch (error) {
125
- owner.releaseUnused();
126
- throw error;
127
- }
128
- }
129
- export function captureNodeRawQUIC(input, beforeCopy) {
130
- const applicationStreams = input.applicationStreams, streamBufferBytes = input.streamBufferBytes;
131
- const runtimeBytes = input.runtimeBytes, providerRuntimeBytes = input.providerRuntimeBytes, providerStreamBytes = input.providerStreamBytes;
132
- const roots = input.trustRootsDER, nativeCarrier = input.nativeCarrier ?? "raw-quic", wt = input.webTransport;
133
- requireCredential(nativeCarrier === "raw-quic" || nativeCarrier === "webtransport", "configuration_capacity");
134
- if (nativeCarrier === "webtransport") {
135
- requireCredential(wt !== undefined && Number.isSafeInteger(wt.headerBytes) && wt.headerBytes >= 1024 && wt.headerBytes <= 65536 && Number.isSafeInteger(wt.controlBytes) && wt.controlBytes >= 16384 && wt.controlBytes <= 1048576 &&
136
- Array.isArray(wt.tuples) && wt.tuples.length >= 1 && wt.tuples.length <= 2 && new Set(wt.tuples).size === wt.tuples.length && wt.tuples.every(tuple => tuple === "chromium_draft02" || tuple === "native_h3") &&
137
- Array.isArray(wt.allowedOrigins) && wt.allowedOrigins.length <= 64 && new Set(wt.allowedOrigins).size === wt.allowedOrigins.length && typeof wt.allowAbsentOrigin === "boolean", "configuration_capacity");
138
- for (const origin of wt.allowedOrigins) {
139
- const parsed = new URL(origin);
140
- requireCredential(parsed.origin === origin && (parsed.protocol === "https:" || parsed.protocol === "http:") && origin.length <= 4096, "configuration_capacity");
141
- }
142
- }
143
- else
144
- requireCredential(wt === undefined, "configuration_capacity");
145
- requireCredential(Number.isSafeInteger(applicationStreams) && applicationStreams >= 1 && applicationStreams <= 4096 &&
146
- Number.isSafeInteger(streamBufferBytes) && streamBufferBytes >= 65544 && streamBufferBytes <= 16777224 &&
147
- [runtimeBytes, providerRuntimeBytes, providerStreamBytes].every(value => typeof value === "bigint" && value > 0n && value <= 0xffffffffffffffffn) &&
148
- (roots === undefined || Array.isArray(roots) && roots.length > 0 && roots.length <= 64 && roots.every(value => value instanceof Uint8Array && value.byteLength > 0 && value.byteLength <= 65536) && roots.reduce((n, value) => n + value.byteLength, 0) <= 1048576), "configuration_capacity");
149
- const transport = { nativeCarrier, ...(wt === undefined ? {} : { webTransport: Object.freeze({ ...wt, tuples: Object.freeze([...wt.tuples]), allowedOrigins: Object.freeze([...wt.allowedOrigins]) }) }) };
150
- beforeCopy?.({ applicationStreams, streamBufferBytes, runtimeBytes, providerRuntimeBytes, providerStreamBytes, ...transport, ...(roots === undefined ? {} : { trustRootsDER: roots }) });
151
- return Object.freeze({ applicationStreams, streamBufferBytes, runtimeBytes, providerRuntimeBytes, providerStreamBytes, ...transport,
152
- ...(roots === undefined ? {} : { trustRootsDER: Object.freeze(roots.map(value => new Uint8Array(value))) }) });
153
- }
154
- /** Exact captured configuration for adoption of a physical listener. */
155
- export function sameNodeRawQUICOptions(left, right) {
156
- if ((left.nativeCarrier ?? "raw-quic") !== (right.nativeCarrier ?? "raw-quic") || left.applicationStreams !== right.applicationStreams ||
157
- left.streamBufferBytes !== right.streamBufferBytes || left.runtimeBytes !== right.runtimeBytes || left.providerRuntimeBytes !== right.providerRuntimeBytes || left.providerStreamBytes !== right.providerStreamBytes)
158
- return false;
159
- const roots = left.trustRootsDER, otherRoots = right.trustRootsDER;
160
- if ((roots === undefined) !== (otherRoots === undefined) || roots !== undefined && (roots.length !== otherRoots.length || !roots.every((bytes, index) => equalCredential(bytes, otherRoots[index]))))
161
- return false;
162
- const wt = left.webTransport, otherWT = right.webTransport;
163
- return wt === undefined ? otherWT === undefined : otherWT !== undefined && wt.headerBytes === otherWT.headerBytes && wt.controlBytes === otherWT.controlBytes && wt.allowAbsentOrigin === otherWT.allowAbsentOrigin &&
164
- wt.tuples.length === otherWT.tuples.length && wt.tuples.every((tuple, index) => tuple === otherWT.tuples[index]) && wt.allowedOrigins.length === otherWT.allowedOrigins.length && wt.allowedOrigins.every((origin, index) => origin === otherWT.allowedOrigins[index]);
165
- }
166
- /** ABI4 prepays two native datagram queues, the fixed UDP receive scratch
167
- * buffer and aggregate receive/send windows before connect/bind. The native
168
- * endpoint uses a 1472-byte maximum payload; the supported UDP runtime has at
169
- * most 64 GRO segments and 32 receive slots. Library heap and stream metadata
170
- * remain separately covered by providerRuntimeBytes. */
171
- export function nativeRawQUICQueueBytes(options) {
172
- const streamRead = BigInt(Math.min(16384, options.streamBufferBytes)), aggregate = BigInt(options.applicationStreams + 1) * streamRead;
173
- const receiveScratch = 1472n * 64n * 32n;
174
- return 131072n + receiveScratch + (options.webTransport === undefined ? 0n : BigInt(2 * options.webTransport.controlBytes + 4 * options.webTransport.headerBytes)) + 2n * (aggregate < 16777216n ? aggregate : 16777216n);
175
- }
176
- export function nodeRawQUICAdmissionCosts(maxFrame, options, runtimeBytes) {
177
- const maximum = Math.max(maxFrame, 65536) + 8;
178
- requireCredential(maximum <= options.streamBufferBytes, "configuration_capacity");
179
- const main = new ResourceVector([options.runtimeBytes + 65536n + 16384n + 1024n + BigInt(options.applicationStreams + 1) * 128n,
180
- options.providerRuntimeBytes + nativeRawQUICQueueBytes(options), 0n, BigInt(options.applicationStreams + 20), 4n, 8n, 1n, 1n, 1n, 0n, 5n]);
181
- const position = nativeProviderStreamCharge(maximum, options.runtimeBytes, options.providerStreamBytes);
182
- return [["node_raw_quic", main], ...Array.from({ length: options.applicationStreams + 1 }, () => ["carrier_stream_position", position]),
183
- ["node_raw_quic_policy", credentialWorkCharge(16384, runtimeBytes)]];
184
- }
185
- /** Each object is tied to actual native create/accept provenance. An observer
186
- * cancellation never releases a handle or byte borrow before native exit. */
187
- class RawQUICStream {
188
- role;
189
- origin;
190
- maximum;
191
- position;
192
- checking;
193
- released;
194
- mode = "stream";
195
- #done;
196
- #resolve;
197
- #raw;
198
- #creating = true;
199
- #closed = false;
200
- #nativeEnded = false;
201
- #released = false;
202
- #reading = false;
203
- #writing = false;
204
- #unobservedWrite = false;
205
- #tails = 0;
206
- #borrowed = false;
207
- #input;
208
- #read;
209
- #writeFailure;
210
- #writeObserver;
211
- #detachWrite;
212
- #fin;
213
- #stop;
214
- #reset;
215
- constructor(role, origin, maximum, position, checking, released) {
216
- this.role = role;
217
- this.origin = origin;
218
- this.maximum = maximum;
219
- this.position = position;
220
- this.checking = checking;
221
- this.released = released;
222
- this.#done = new Promise(resolve => { this.#resolve = resolve; });
223
- }
224
- attach(raw) {
225
- if (!this.#creating)
226
- throw new Error("credential_binding");
227
- this.#raw = raw;
228
- this.#creating = false;
229
- void raw.waitTermination().then(() => { this.#nativeEnded = true; if (this.#unobservedWrite)
230
- this.#writing = false; this.#finish(); }, () => { void this.close(); });
231
- this.#detachWrite = raw.onWriteFailure(reason => { this.#writeFailure = new NativeDirectionFailure(reason); this.#writeObserver?.(this.#writeFailure); });
232
- if (this.#closed)
233
- raw.abort();
234
- }
235
- creationFailed() { if (!this.#creating) {
236
- void this.close();
237
- return;
238
- } this.#creating = false; this.#nativeEnded = true; void this.close(); }
239
- #check() { if (this.#closed || this.#creating || this.#nativeEnded || this.#released)
240
- throw new Error("carrier_closed"); this.position.check(); this.checking(); }
241
- observeWriteFailure(callback) {
242
- if (this.#writeObserver !== undefined)
243
- throw new Error("busy");
244
- this.#writeObserver = callback;
245
- if (this.#writeFailure !== undefined)
246
- queueMicrotask(() => { if (this.#writeObserver === callback)
247
- callback(this.#writeFailure); });
248
- return () => { if (this.#writeObserver === callback)
249
- this.#writeObserver = undefined; };
250
- }
251
- async read(maxBytes, options) {
252
- this.#check();
253
- if (options?.signal?.aborted)
254
- throw new Error("canceled");
255
- requireCredential(Number.isSafeInteger(maxBytes) && maxBytes > 0 && maxBytes <= this.maximum, "configuration_capacity");
256
- if (this.#reading)
257
- throw new Error("busy");
258
- this.#borrowed = false;
259
- this.#input?.fill(0);
260
- this.#input = undefined;
261
- this.#reading = true;
262
- const cancel = () => this.#read?.cancel();
263
- options?.signal?.addEventListener("abort", cancel, { once: true });
264
- let actual;
265
- try {
266
- const operation = this.#read = this.#raw.read(Math.min(maxBytes, 16384));
267
- actual = operation.result().catch(error => { throw nativeFailure(error); }).then(bytes => {
268
- if (bytes === null)
269
- return null;
270
- requireCredential(bytes instanceof Uint8Array && bytes.length > 0 && bytes.length <= Math.min(maxBytes, 16384) && bytes.buffer.byteLength <= 16384, "credential_binding");
271
- if (this.#closed || options?.signal?.aborted) {
272
- bytes.fill(0);
273
- throw new Error("canceled");
274
- }
275
- this.#input = bytes;
276
- this.#borrowed = true;
277
- return bytes;
278
- }).finally(() => { this.#reading = false; this.#read = undefined; options?.signal?.removeEventListener("abort", cancel); this.#finish(); });
279
- if (options?.signal?.aborted)
280
- operation.cancel();
281
- }
282
- catch (error) {
283
- this.#reading = false;
284
- this.#read = undefined;
285
- options?.signal?.removeEventListener("abort", cancel);
286
- this.#finish();
287
- throw error;
288
- }
289
- return observeTask(actual, options?.signal);
290
- }
291
- submit(bytes, admitted, beforeSubmit) {
292
- this.#check();
293
- if (this.#writing || this.#fin !== undefined || this.#reset !== undefined)
294
- return undefined;
295
- if (this.#writeFailure !== undefined)
296
- throw this.#writeFailure;
297
- requireCredential(bytes.length > 0 && bytes.length <= this.maximum, "configuration_capacity");
298
- // Acquire custody before native submission: synchronous promise hooks may
299
- // close the original owner while a receipt or completion is constructed.
300
- beforeSubmit?.();
301
- this.#writing = true;
302
- let native;
303
- try {
304
- native = this.#raw.submit(bytes);
305
- }
306
- catch (error) {
307
- this.#writing = false;
308
- this.#finish();
309
- throw nativeFailure(error);
310
- }
311
- if (native === undefined) {
312
- this.#writing = false;
313
- this.#finish();
314
- return undefined;
315
- }
316
- try {
317
- admitted();
318
- }
319
- catch {
320
- void this.close();
321
- }
322
- let completion;
323
- try {
324
- completion = native.completion().catch(error => { throw nativeFailure(error); })
325
- .finally(() => { this.#writing = false; this.#finish(); });
326
- }
327
- catch {
328
- // A malformed provider receipt cannot erase an accepted native borrow.
329
- // Keep custody until the actual stream termination observation settles.
330
- this.#unobservedWrite = true;
331
- if (this.#nativeEnded)
332
- this.#writing = false;
333
- void this.close();
334
- completion = this.#done.then(() => { throw new Error("carrier_failed"); });
335
- }
336
- return Object.freeze({ completion });
337
- }
338
- async write(bytes, options) {
339
- if (options?.signal?.aborted)
340
- throw new Error("canceled");
341
- const output = this.submit(bytes, () => { });
342
- if (output === undefined)
343
- throw new Error("carrier_closed");
344
- await observeTask(output.completion, options?.signal);
345
- return bytes.length;
346
- }
347
- #tail(run) {
348
- this.#tails++;
349
- let actual;
350
- try {
351
- actual = run();
352
- }
353
- catch (error) {
354
- this.#tails--;
355
- this.#finish();
356
- return Promise.reject(error);
357
- }
358
- return actual.finally(() => { this.#tails--; this.#finish(); });
359
- }
360
- closeWrite() {
361
- if (this.#fin !== undefined)
362
- return this.#fin;
363
- // Peer STOP_SENDING may retire both physical directions before the
364
- // original FIN record's completion resumes in JavaScript. Native cleanup
365
- // is then already complete; authenticated DRAINED remains Session-owned.
366
- if (this.#nativeEnded)
367
- return Promise.resolve();
368
- this.#check();
369
- return this.#fin ??= this.#tail(() => this.#raw.closeWrite()).catch(error => { throw nativeFailure(error); });
370
- }
371
- stopSending(reason) {
372
- this.#borrowed = false;
373
- if (this.#creating || this.#raw === undefined || this.#nativeEnded)
374
- return Promise.resolve();
375
- return this.#stop ??= this.#tail(() => this.#raw.stopSending(reason));
376
- }
377
- resetWrite() {
378
- if (this.#fin !== undefined)
379
- return this.#fin;
380
- if (this.#creating || this.#raw === undefined || this.#nativeEnded)
381
- return Promise.resolve();
382
- return this.#reset ??= this.#tail(() => this.#raw.resetWrite());
383
- }
384
- close() {
385
- this.#closed = true;
386
- this.#borrowed = false;
387
- this.#read?.cancel();
388
- this.#raw?.abort();
389
- this.#finish();
390
- return this.#done;
391
- }
392
- cleanupComplete() { return this.#released; }
393
- waitTermination() { return this.#done; }
394
- #finish() {
395
- if (this.#released || this.#creating || !this.#nativeEnded || this.#reading || this.#writing || this.#tails !== 0 || this.#borrowed)
396
- return;
397
- this.#released = this.#closed = true;
398
- this.#input?.fill(0);
399
- this.#input = undefined;
400
- this.#detachWrite?.();
401
- this.#detachWrite = undefined;
402
- this.#writeObserver = undefined;
403
- this.#raw = undefined;
404
- this.checking = undefined;
405
- this.position?.release();
406
- this.position = undefined;
407
- const done = this.released;
408
- this.released = undefined;
409
- done?.();
410
- this.#resolve();
411
- }
412
- }
413
- export class NodeRawQUICCarrier {
414
- environment;
415
- dependency;
416
- positions;
417
- options;
418
- preparation;
419
- role;
420
- path;
421
- selectedCandidateIndex;
422
- preparationBudget;
423
- mode = "stream";
424
- nativeStreams;
425
- nativeDatagrams;
426
- #datagramReading = false;
427
- #datagramRead;
428
- #done;
429
- #resolve;
430
- #session;
431
- #tls;
432
- #preparationOwnerRelease;
433
- #preparationCompleted = false;
434
- #wt;
435
- get nativeCarrier() { return this.options.nativeCarrier ?? "raw-quic"; }
436
- #alpn() { return this.nativeCarrier === "webtransport" ? "h3" : this.path === "direct" ? "flowersec-direct/4" : "flowersec-tunnel/4"; }
437
- #path() { return this.nativeCarrier === "webtransport" ? `/flowersec/webtransport/v4/${this.path}` : ""; }
438
- #checkOrigin(leg, node = 0, schema = "Leg") {
439
- const origin = leg.optional("origin_policy", node, schema), actual = this.#wt?.origin;
440
- if (this.nativeCarrier === "raw-quic") {
441
- requireCredential(origin < 0 || leg.doc.boolean(leg.field("allow_absent", origin, "OriginPolicy")));
442
- return;
443
- }
444
- requireCredential(origin >= 0 && this.#wt !== undefined);
445
- if (actual === undefined)
446
- requireCredential(leg.doc.boolean(leg.field("allow_absent", origin, "OriginPolicy")), "credential_untrusted");
447
- else
448
- requireCredential([...leg.items("origins", origin, "OriginPolicy")].some(entry => leg.doc.text(entry) === actual), "credential_untrusted");
449
- }
450
- #captureWT(session) {
451
- if (this.nativeCarrier !== "webtransport") {
452
- requireCredential(session.kind === "raw_quic");
453
- return;
454
- }
455
- requireCredential(session.kind === "webtransport" && typeof session.request === "function");
456
- const request = session.request();
457
- requireCredential(request.scheme === "https" && request.path === this.#path() && request.authority.length > 0 && request.authority.length <= 512 && (request.origin === undefined || request.origin.length <= 4096) &&
458
- request.sessionFlowControl === false && request.streamPrefixes === "rfc_webtransport" && request.datagramContext === "rfc_h3_quarter_stream_id" && this.options.webTransport.tuples.includes(request.tuple) &&
459
- (request.tuple === "chromium_draft02" && request.protocol === "webtransport" || request.tuple === "native_h3" && request.protocol === "webtransport-h3"), "credential_untrusted");
460
- this.#wt = Object.freeze({ ...request });
461
- }
462
- #maintenance;
463
- #acceptedMaintenance;
464
- #streams = new Set();
465
- #physical = new Map();
466
- #closed = false;
467
- #nativeEnded = false;
468
- #connecting = false;
469
- #operations = 0;
470
- #accepting = false;
471
- #activated = false;
472
- #applications = false;
473
- #released = false;
474
- #connect;
475
- #expectation;
476
- #certificateEnd;
477
- #accepted;
478
- constructor(environment, dependency, positions, options, preparation, role = "client", path = "direct", selectedCandidateIndex = -1, preparationBudget) {
479
- this.environment = environment;
480
- this.dependency = dependency;
481
- this.positions = positions;
482
- this.options = options;
483
- this.preparation = preparation;
484
- this.role = role;
485
- this.path = path;
486
- this.selectedCandidateIndex = selectedCandidateIndex;
487
- this.preparationBudget = preparationBudget;
488
- this.#done = new Promise(resolve => { this.#resolve = resolve; });
489
- this.nativeStreams = Object.freeze({ capacity: options.applicationStreams, enable: () => { this.#check(); this.#applications = true; },
490
- open: (operation) => this.#application(true, operation), accept: (operation) => this.#application(false, operation) });
491
- this.nativeDatagrams = Object.freeze({ maxDatagramBytes: () => this.maxDatagramBytes(),
492
- receive: (maximum, operation) => this.receiveDatagram(maximum, operation),
493
- submit: (bytes, admitted) => this.submitDatagram(bytes, admitted) });
494
- dependency.onClose(() => { void this.close(); });
495
- }
496
- #check() { this.dependency.check(); if (this.#closed || this.#nativeEnded || this.#session === undefined)
497
- throw new Error("carrier_closed"); }
498
- #captureTLS(session) {
499
- requireCredential(this.#tls === undefined);
500
- const native = session.tls();
501
- if (!(native.peerLeafDER instanceof Uint8Array) || native.peerLeafDER.length > 65536) {
502
- if (native.peerLeafDER instanceof Uint8Array)
503
- native.peerLeafDER.fill(0);
504
- requireCredential(false, "credential_untrusted");
505
- }
506
- // ABI4 returns this bounded owned copy. Keep exactly one private snapshot
507
- // for the original carrier rather than recopying its leaf on each guard.
508
- this.#tls = Object.freeze({ version: native.version, alpn: native.alpn, earlyDataAccepted: native.earlyDataAccepted, dedicatedConnection: native.dedicatedConnection,
509
- peerLeafDER: native.peerLeafDER, certificateVerified: native.certificateVerified });
510
- }
511
- checkPreparation() {
512
- this.#check();
513
- this.preparation.check();
514
- const tls = this.#tls;
515
- requireCredential(this.#session.wireVersion === 4 && this.#session.path === this.path && tls.version === "TLSv1.3" && tls.alpn === this.#alpn() &&
516
- tls.earlyDataAccepted === false && tls.dedicatedConnection === true && tls.peerLeafDER instanceof Uint8Array && (this.role === "server" || tls.peerLeafDER.length > 0) && tls.peerLeafDER.length <= 65536 &&
517
- this.#session.inboundBidirectionalStreamCapacity >= this.options.applicationStreams + 1 && typeof this.#session.maxDatagramBytes === "function" &&
518
- typeof this.#session.receiveDatagram === "function" && typeof this.#session.submitDatagram === "function", "credential_untrusted");
519
- const now = this.environment.clock.sample().requireInterval();
520
- if (this.#certificateEnd !== undefined)
521
- requireCredential(now.upperMS < this.#certificateEnd, "credential_expired");
522
- const expected = this.#expectation;
523
- if (expected !== undefined) {
524
- if (expected.mode === "ca")
525
- requireCredential(tls.certificateVerified, "credential_untrusted");
526
- else {
527
- const leaf = new Uint8Array(createHash("sha256").update(tls.peerLeafDER).digest());
528
- try {
529
- requireCredential(expected.pins.some(pin => now.lowerMS >= pin.from && now.upperMS < pin.until && equalCredential(pin.digest, leaf)), "credential_expired");
530
- }
531
- finally {
532
- leaf.fill(0);
533
- }
534
- }
535
- }
536
- }
537
- /** Called only by the configured current native listener. A dedicated
538
- * candidate can finish physical Prepare before accepting its peer's first
539
- * maintenance stream; the original carrier retains that later native tail. */
540
- async accept(session, endpoint, signal, deferMaintenance = false) {
541
- this.dependency.check();
542
- this.preparation.check();
543
- requireCredential(this.role === "server" && this.#session === undefined && !this.#closed, "credential_binding");
544
- this.#connecting = true;
545
- this.#session = session;
546
- this.#accepted = Object.freeze({ ...endpoint });
547
- const cancel = () => { void this.close(); };
548
- signal?.addEventListener("abort", cancel, { once: true });
549
- try {
550
- void session.waitTermination().then(() => { this.#nativeEnded = true; void this.close(); this.#finish(); }, () => { void this.close(); });
551
- if (signal?.aborted)
552
- throw new Error("canceled");
553
- this.#captureWT(session);
554
- this.#captureTLS(session);
555
- this.checkPreparation();
556
- const local = session.localAddress();
557
- requireCredential(local.port === endpoint.port && (isIP(endpoint.host) === 0 || local.host === endpoint.host), "credential_binding");
558
- const now = this.environment.clock.sample().requireInterval(), from = BigInt(endpoint.leaf.validFromDate.getTime()), until = BigInt(endpoint.leaf.validToDate.getTime());
559
- requireCredential(now.lowerMS >= from && now.upperMS < until, "credential_expired");
560
- this.#certificateEnd = until;
561
- this.#checkWTAuthority(endpoint.host, endpoint.port);
562
- // Shared ingress ends network Prepare after the original physical
563
- // binding checks, before waiting for a peer's HELLO/HOP stream. A
564
- // dedicated candidate keeps its explicit token until the physical
565
- // candidate race selects and retires all other sockets.
566
- if (this.preparationBudget === undefined)
567
- this.completePreparation();
568
- if (!deferMaintenance)
569
- this.#maintenance = await this.#createStream(false, true, signal === undefined ? undefined : { signal });
570
- this.checkPreparation();
571
- this.#activated = true;
572
- }
573
- catch (error) {
574
- void this.close();
575
- throw error;
576
- }
577
- finally {
578
- this.#connecting = false;
579
- signal?.removeEventListener("abort", cancel);
580
- this.#finish();
581
- }
582
- }
583
- /** Compare complete original signed route facts with the accepted listener,
584
- * never with a remote header, proxy assertion or QUIC stream number. */
585
- checkAcceptedRoute(fields, endpointRole = 1) {
586
- this.checkPreparation();
587
- const actual = this.#accepted;
588
- requireCredential(this.role === "server" && actual !== undefined && fields.accessClass === 0n, "credential_binding");
589
- const ref = this.environment.reserveConnectionWork("accepted_raw_quic_route", credentialWorkCharge(16384, this.environment.resources.runtimeBytes));
590
- let work;
591
- try {
592
- work = new CredentialWork(this.environment.resources, 16384, ref);
593
- const route = work.parse(fields.route, "Route", 16384);
594
- try {
595
- const leg = route.field(this.path === "direct" ? "direct_leg" : endpointRole === 0 ? "client_leg" : "server_leg"), tls = route.field("tls_policy", leg, "Leg");
596
- requireCredential(route.uint("path_kind") === (this.path === "direct" ? 0n : 1n) && route.uint("access_class", leg, "Leg") === 0n && route.uint("carrier", leg, "Leg") === (this.nativeCarrier === "webtransport" ? 2n : 0n) &&
597
- route.uint("dialer_role", leg, "Leg") === (this.path === "direct" ? 0n : 2n) && route.uint("listener_role", leg, "Leg") === BigInt(endpointRole) && route.text("alpn", leg, "Leg") === this.#alpn() &&
598
- route.text("path", leg, "Leg") === this.#path() && route.text("subprotocol", leg, "Leg") === "" && route.text("host", leg, "Leg") === actual.host &&
599
- route.uint("port", leg, "Leg") === BigInt(actual.port), "credential_binding");
600
- this.#checkOrigin(route, leg, "Leg");
601
- this.#checkWTAuthority(actual.host, actual.port);
602
- const mode = route.uint("mode", tls, "TLSPolicy");
603
- if (mode === 0n)
604
- requireCredential(isIP(actual.host) ? actual.leaf.checkIP(actual.host) === actual.host : actual.leaf.checkHost(actual.host, { subject: "never" }) !== undefined, "credential_binding");
605
- else {
606
- requireCredential(mode === 1n && route.uint("pin_kind", tls, "TLSPolicy") === 0n, "credential_binding");
607
- const now = this.environment.clock.sample().requireInterval(), window = pinProfile(actual.leaf, now), digest = new Uint8Array(createHash("sha256").update(actual.leaf.raw).digest());
608
- try {
609
- requireCredential([...route.items("pins", tls, "TLSPolicy")].some(pin => {
610
- const from = route.uint("not_before_ms", pin, "TLSPin"), until = route.uint("not_after_ms", pin, "TLSPin");
611
- return now.lowerMS >= from && now.upperMS < until && from >= window.from && until <= window.until && equalCredential(digest, route.bytes("leaf_der_sha256", pin, "TLSPin"));
612
- }), "credential_binding");
613
- }
614
- finally {
615
- digest.fill(0);
616
- }
617
- }
618
- }
619
- finally {
620
- route.close();
621
- }
622
- this.checkPreparation();
623
- }
624
- finally {
625
- work?.close();
626
- ref.release();
627
- }
628
- }
629
- checkAcceptedHopRoute(credentials, reference, localRole = 2) {
630
- this.checkPreparation();
631
- credentials.check(reference);
632
- const actual = this.#accepted;
633
- requireCredential(actual !== undefined && this.path === "tunnel");
634
- const ref = this.environment.reserveConnectionWork("accepted_relay_quic_policy", credentialWorkCharge(16384, this.environment.resources.runtimeBytes));
635
- let work;
636
- const bytes = credentials.descriptor(reference);
637
- try {
638
- work = new CredentialWork(this.environment.resources, 16384, ref);
639
- const leg = work.parse(bytes, "Leg", 16384, 16384, { selectors: { path_kind: "tunnel" } });
640
- try {
641
- const tls = leg.field("tls_policy"), host = leg.text("host");
642
- requireCredential(leg.uint("carrier") === (this.nativeCarrier === "webtransport" ? 2n : 0n) && leg.uint("access_class") === 0n && leg.uint("dialer_role") === (localRole === 2 ? BigInt(credentials.role) : 2n) && leg.uint("listener_role") === BigInt(localRole) && leg.text("alpn") === this.#alpn() && leg.text("path") === this.#path() && leg.text("subprotocol") === "" && host === actual.host && leg.uint("port") === BigInt(actual.port));
643
- this.#checkOrigin(leg);
644
- this.#checkWTAuthority(actual.host, actual.port);
645
- const mode = leg.uint("mode", tls, "TLSPolicy");
646
- if (mode === 0n)
647
- requireCredential(isIP(host) ? actual.leaf.checkIP(host) === host : actual.leaf.checkHost(host, { subject: "never" }) !== undefined);
648
- else {
649
- requireCredential(mode === 1n && leg.uint("pin_kind", tls, "TLSPolicy") === 0n);
650
- const now = this.environment.clock.sample().requireInterval(), window = pinProfile(actual.leaf, now), digest = new Uint8Array(createHash("sha256").update(actual.leaf.raw).digest());
651
- try {
652
- requireCredential([...leg.items("pins", tls, "TLSPolicy")].some(pin => { const from = leg.uint("not_before_ms", pin, "TLSPin"), until = leg.uint("not_after_ms", pin, "TLSPin"); return now.lowerMS >= from && now.upperMS < until && from >= window.from && until <= window.until && equalCredential(digest, leg.bytes("leaf_der_sha256", pin, "TLSPin")); }));
653
- }
654
- finally {
655
- digest.fill(0);
656
- }
657
- }
658
- }
659
- finally {
660
- leg.close();
661
- }
662
- }
663
- finally {
664
- bytes.fill(0);
665
- work?.close();
666
- ref.release();
667
- }
668
- }
669
- #checkWTAuthority(host, port) {
670
- if (this.#wt === undefined)
671
- return;
672
- const expected = new URL(`https://${isIP(host) === 6 ? `[${host}]` : host}:${port}${this.#path()}`);
673
- requireCredential(this.#wt.authority === expected.host, "credential_untrusted");
674
- }
675
- async prepare(driver, endpoint, expectation, signal) {
676
- this.dependency.check();
677
- this.preparation.check();
678
- requireCredential(this.role === "client" && !this.#connecting && this.#session === undefined && !this.#closed, "credential_binding");
679
- this.#expectation = expectation;
680
- this.#connecting = true;
681
- let timer;
682
- let submitted = false, tlsVerified = false;
683
- const cancel = () => { this.#connect?.cancel(); void this.close(); };
684
- signal?.addEventListener("abort", cancel, { once: true });
685
- try {
686
- this.dependency.check();
687
- this.preparation.check();
688
- if (signal?.aborted)
689
- throw new Error("canceled");
690
- const connectOptions = { host: endpoint.host, port: endpoint.port, serverName: expectation.serverName, path: this.path,
691
- inboundBidirectionalStreamCapacity: this.options.applicationStreams + 1, readBufferBytes: Math.min(16384, this.options.streamBufferBytes), datagramQueueBytes: 65536,
692
- handshakeTimeoutMs: Math.min(60000, Number(this.preparation.remainingMS())), ...(this.preparationBudget === undefined ? {} : { preparationBudget: this.preparationBudget }), tlsMode: expectation.mode,
693
- ...(expectation.mode === "ca" ? { trustRootsDer: this.options.trustRootsDER } : { activeLeafDerSha256: expectation.pins.map(pin => pin.digest) }) };
694
- const operation = this.#connect = this.nativeCarrier === "raw-quic" ? driver.connectRawQuic(connectOptions) : driver.connectWebTransport({ ...connectOptions,
695
- connectPath: this.#path(), tuple: "native_h3", headerBytes: this.options.webTransport.headerBytes, controlBytes: this.options.webTransport.controlBytes });
696
- submitted = true;
697
- const tick = () => { try {
698
- this.preparation.check();
699
- this.dependency.check();
700
- timer = setTimeout(tick, timerChunk(this.preparation.remainingMS()));
701
- }
702
- catch {
703
- cancel();
704
- } };
705
- tick();
706
- if (signal?.aborted)
707
- cancel();
708
- const actual = operation.result().then(async (session) => {
709
- this.#session = session;
710
- void session.waitTermination().then(() => { this.#nativeEnded = true; void this.close(); this.#finish(); }, () => { void this.close(); });
711
- if (this.#closed || signal?.aborted) {
712
- session.abort();
713
- throw new Error("canceled");
714
- }
715
- this.#captureWT(session);
716
- this.#captureTLS(session);
717
- this.checkPreparation();
718
- this.#checkWTAuthority(endpoint.host, endpoint.port);
719
- requireCredential(this.#wt === undefined || this.#wt.origin === undefined, "credential_untrusted");
720
- const certificate = new X509Certificate(this.#tls.peerLeafDER), from = BigInt(certificate.validFromDate.getTime()), until = BigInt(certificate.validToDate.getTime());
721
- const now = this.environment.clock.sample().requireInterval();
722
- requireCredential(now.lowerMS >= from && now.upperMS < until && (isIP(expectation.serverName) ? certificate.checkIP(expectation.serverName) === expectation.serverName : certificate.checkHost(expectation.serverName, { subject: "never" }) !== undefined), "credential_untrusted");
723
- this.#certificateEnd = until;
724
- if (expectation.mode === "pin")
725
- pinProfile(certificate, now);
726
- tlsVerified = true;
727
- this.#maintenance = await this.#createStream(true, true);
728
- this.checkPreparation();
729
- }).finally(() => { this.#connecting = false; this.#connect = undefined; if (this.#session === undefined)
730
- this.#nativeEnded = true; this.#finish(); });
731
- await observeTask(actual, signal);
732
- }
733
- catch (error) {
734
- // A synchronous refusal transfers no native operation. A submitted
735
- // connection keeps its original custody through the actual continuation.
736
- if (!submitted) {
737
- this.#connecting = false;
738
- this.#nativeEnded = true;
739
- }
740
- void this.close();
741
- if (!tlsVerified && error instanceof Error && ["credential_binding", "credential_untrusted", "credential_expired"].includes(error.message))
742
- this.environment.diagnosticCounters.observe("tls_rejection", { phase: "prepare", code: "tls_rejected" });
743
- if (error instanceof Error && ["handshake_failed", "pin_mismatch", "pin_certificate_invalid", "invalid_alpn"].includes(error.message)) {
744
- this.environment.diagnosticCounters.observe("tls_rejection", { phase: "prepare", code: "tls_rejected" });
745
- throw new Error("authentication_failed");
746
- }
747
- throw error;
748
- }
749
- finally {
750
- if (timer !== undefined)
751
- clearTimeout(timer);
752
- signal?.removeEventListener("abort", cancel);
753
- }
754
- }
755
- async authenticateHop(credentials, signer, random, resources, reference, options, acceptedHello, prepared, originalDeadline) {
756
- const incarnation = new Uint8Array(16);
757
- let ref = prepared, hop;
758
- try {
759
- this.checkPreparation();
760
- requireCredential(this.path === "tunnel" && (credentials.role === 0 || credentials.role === 1));
761
- if (originalDeadline !== undefined)
762
- this.preparation.tightenFrom(originalDeadline);
763
- if (this.role === "server")
764
- this.checkAcceptedHopRoute(credentials, reference, credentials.role);
765
- ref ??= this.environment.reserveConnectionWork("endpoint_hop_authentication", hopAuthenticationCharge(resources.runtimeBytes));
766
- random(incarnation);
767
- if (!(ref instanceof HopAuthenticationPreparation))
768
- requireCredential(ref.sameEnvironment(reference));
769
- hop = new HopAuthentication({ resources, transport: this, credentials, localRole: credentials.role, localIncarnation: incarnation, random, signer, deadline: this.preparation,
770
- guard: () => this.checkPreparation(), ...(acceptedHello === undefined ? {} : { acceptedHello }) }, ref, reference);
771
- await hop.authenticateEndpoint(options);
772
- }
773
- finally {
774
- hop?.close();
775
- incarnation.fill(0);
776
- if (ref instanceof HopAuthenticationPreparation)
777
- ref.close();
778
- else
779
- ref?.release();
780
- }
781
- }
782
- retainPreparationOwner(release) { requireCredential(!this.#closed && this.#preparationOwnerRelease === undefined, "credential_binding"); this.#preparationOwnerRelease = release; }
783
- completePreparation() {
784
- if (this.#preparationCompleted)
785
- return;
786
- this.checkPreparation();
787
- if (this.preparationBudget !== undefined)
788
- requireCredential(typeof this.#session.completePreparation === "function", "configuration_capacity");
789
- this.#session.completePreparation?.();
790
- this.#preparationCompleted = true;
791
- }
792
- activate() { this.checkPreparation(); this.#activated = true; }
793
- exportBinding(artifactDigest) {
794
- this.checkPreparation();
795
- requireCredential(artifactDigest.length === 32 && artifactDigest.some(byte => byte !== 0));
796
- const output = this.#session.exportKeyingMaterial(32, "EXPORTER-flowersec-v4", artifactDigest);
797
- requireCredential(output.length === 32);
798
- return output;
799
- }
800
- async #createStream(local, maintenance, options) {
801
- this.#check();
802
- if (options?.signal?.aborted)
803
- throw new Error("canceled");
804
- const position = this.positions.acquire(maintenance);
805
- let rawBinding;
806
- const stream = new RawQUICStream(this.role, maintenance ? "maintenance" : local ? "local" : "peer", this.options.streamBufferBytes, position, () => this.#check(), () => { if (rawBinding !== undefined)
807
- this.#physical.delete(rawBinding); this.#streams.delete(stream); this.#finish(); });
808
- this.#streams.add(stream);
809
- this.#operations++;
810
- let operation, acceptHeld = false;
811
- try {
812
- this.#check();
813
- position.check();
814
- if (options?.signal?.aborted)
815
- throw new Error("canceled");
816
- if (!local && !maintenance) {
817
- if (this.#accepting)
818
- throw new Error("carrier_closed");
819
- this.#accepting = true;
820
- acceptHeld = true;
821
- }
822
- operation = local ? this.#session.openStream() : this.#session.acceptStream();
823
- }
824
- catch (error) {
825
- if (acceptHeld)
826
- this.#accepting = false;
827
- stream.creationFailed();
828
- this.#operations--;
829
- this.#finish();
830
- throw error;
831
- }
832
- const cancel = () => { operation.cancel(); void stream.close(); };
833
- options?.signal?.addEventListener("abort", cancel, { once: true });
834
- const actual = operation.result().then(raw => {
835
- try {
836
- requireCredential(!this.#physical.has(raw), "credential_binding");
837
- rawBinding = raw;
838
- this.#physical.set(raw, stream);
839
- stream.attach(raw);
840
- }
841
- catch (error) {
842
- stream.creationFailed();
843
- void this.close();
844
- throw error;
845
- }
846
- if (this.#closed || options?.signal?.aborted) {
847
- void stream.close();
848
- throw new Error("canceled");
849
- }
850
- return stream;
851
- }, error => { stream.creationFailed(); throw error; })
852
- .finally(() => { if (acceptHeld)
853
- this.#accepting = false; this.#operations--; options?.signal?.removeEventListener("abort", cancel); this.#finish(); });
854
- if (options?.signal?.aborted)
855
- cancel();
856
- return observeTask(actual, options?.signal);
857
- }
858
- async #application(local, options) {
859
- this.#check();
860
- if (!this.#activated || !this.#applications || !local && this.#accepting)
861
- throw new Error("carrier_closed");
862
- // The native accept owns its gate through actual completion. An observer's
863
- // cancellation can return earlier without admitting a second native accept.
864
- return this.#createStream(local, false, options);
865
- }
866
- #acceptMaintenance(options) {
867
- this.#check();
868
- if (!this.#activated || this.role !== "server")
869
- return Promise.reject(new Error("carrier_closed"));
870
- if (options?.signal?.aborted)
871
- return Promise.reject(new Error("canceled"));
872
- // One original native accept owns the prepaid maintenance position through
873
- // actual completion. Concurrent observers never create another accept.
874
- this.#acceptedMaintenance ??= this.#createStream(false, true, options).then(stream => {
875
- this.#check();
876
- this.#maintenance = stream;
877
- return stream;
878
- });
879
- return observeTask(this.#acceptedMaintenance, options?.signal);
880
- }
881
- read(maxBytes, options) {
882
- this.#check();
883
- if (!this.#activated)
884
- return Promise.reject(new Error("carrier_closed"));
885
- return this.#maintenance === undefined ? this.#acceptMaintenance(options).then(stream => stream.read(maxBytes, options)) : this.#maintenance.read(maxBytes, options);
886
- }
887
- write(bytes, options) {
888
- this.#check();
889
- if (!this.#activated)
890
- return Promise.reject(new Error("carrier_closed"));
891
- return this.#maintenance === undefined ? this.#acceptMaintenance(options).then(stream => stream.write(bytes, options)) : this.#maintenance.write(bytes, options);
892
- }
893
- submit(bytes, admitted, beforeSubmit) { this.#check(); if (!this.#activated || this.#maintenance === undefined)
894
- return undefined; return this.#maintenance.submit(bytes, admitted, beforeSubmit); }
895
- maxDatagramBytes() {
896
- this.#check();
897
- const maximum = this.#session.maxDatagramBytes();
898
- if (!Number.isSafeInteger(maximum) || maximum < 0)
899
- throw new Error("carrier_failed");
900
- return Math.min(maximum, 1024);
901
- }
902
- async receiveDatagram(maximum, options) {
903
- this.#check();
904
- if (!this.#activated || !this.#applications || this.#datagramReading || !Number.isSafeInteger(maximum) || maximum < 1 || maximum > 1024)
905
- throw new Error("carrier_closed");
906
- if (options?.signal?.aborted)
907
- throw new Error("canceled");
908
- this.#datagramReading = true;
909
- this.#operations++;
910
- let operation;
911
- const cancel = () => operation?.cancel();
912
- try {
913
- operation = this.#datagramRead = this.#session.receiveDatagram(maximum);
914
- if (this.#closed || options?.signal?.aborted)
915
- operation.cancel();
916
- options?.signal?.addEventListener("abort", cancel, { once: true });
917
- if (options?.signal?.aborted)
918
- cancel();
919
- const bytes = await operation.result();
920
- try {
921
- this.#check();
922
- if (options?.signal?.aborted)
923
- throw new Error("canceled");
924
- if (!(bytes instanceof Uint8Array) || bytes.length > maximum)
925
- throw new Error("carrier_failed");
926
- return new Uint8Array(bytes);
927
- }
928
- finally {
929
- bytes.fill(0);
930
- }
931
- }
932
- finally {
933
- options?.signal?.removeEventListener("abort", cancel);
934
- this.#datagramRead = undefined;
935
- this.#datagramReading = false;
936
- this.#operations--;
937
- this.#finish();
938
- }
939
- }
940
- submitDatagram(bytes, admitted) {
941
- this.#check();
942
- if (!this.#activated || !this.#applications || bytes.length > this.maxDatagramBytes())
943
- return undefined;
944
- const receipt = this.#session.submitDatagram(bytes);
945
- if (receipt === undefined)
946
- return undefined;
947
- this.#operations++;
948
- let acknowledgment;
949
- try {
950
- admitted();
951
- }
952
- catch (error) {
953
- acknowledgment = error;
954
- }
955
- const completion = (async () => {
956
- try {
957
- await receipt.completion();
958
- if (acknowledgment !== undefined)
959
- throw acknowledgment;
960
- }
961
- finally {
962
- this.#operations--;
963
- this.#finish();
964
- }
965
- })();
966
- return Object.freeze({ completion });
967
- }
968
- close() {
969
- if (!this.#closed) {
970
- this.#closed = true;
971
- this.#connect?.cancel();
972
- this.#datagramRead?.cancel();
973
- this.positions.close();
974
- for (const stream of Array.from(this.#streams))
975
- void stream.close();
976
- this.#session?.abort();
977
- if (this.#session === undefined && !this.#connecting)
978
- this.#nativeEnded = true;
979
- }
980
- this.#finish();
981
- return this.#done;
982
- }
983
- waitTermination() { return this.#done; }
984
- #finish() {
985
- if (this.#released || !this.#closed || !this.#nativeEnded || this.#connecting || this.#operations !== 0 || this.#streams.size !== 0 || !this.positions.cleanupComplete())
986
- return;
987
- this.#released = true;
988
- this.#maintenance = undefined;
989
- this.#acceptedMaintenance = undefined;
990
- this.#session = undefined;
991
- this.#accepted = undefined;
992
- this.#tls?.peerLeafDER.fill(0);
993
- this.#tls = undefined;
994
- this.#wt = undefined;
995
- for (const pin of this.#expectation?.pins ?? [])
996
- pin.digest.fill(0);
997
- this.#expectation = undefined;
998
- this.#preparationOwnerRelease?.();
999
- this.#preparationOwnerRelease = undefined;
1000
- this.dependency.release();
1001
- this.#resolve();
1002
- }
1003
- }
1004
- export function nodeRawQUICRouteCarrier(environment, candidate, endpointRole = 0, admission) {
1005
- const reference = environment.reserveConnectionWork("node_raw_quic_candidate_route", credentialWorkCharge(16384, environment.resources.runtimeBytes), admission);
1006
- let work;
1007
- try {
1008
- work = new CredentialWork(environment.resources, 16384, reference);
1009
- const route = work.parse(candidate.route, "Route", 16384);
1010
- try {
1011
- requireCredential(route.uint("path_kind") === BigInt(candidate.pathKind), "credential_binding");
1012
- const leg = route.field(candidate.pathKind === 0 ? "direct_leg" : endpointRole === 0 ? "client_leg" : "server_leg"), carrier = route.uint("carrier", leg, "Leg");
1013
- requireCredential(route.uint("access_class", leg, "Leg") === candidate.accessClass && (carrier === 0n || carrier === 2n), "credential_untrusted");
1014
- return carrier === 2n ? "webtransport" : "raw-quic";
1015
- }
1016
- finally {
1017
- route.close();
1018
- }
1019
- }
1020
- finally {
1021
- work?.close();
1022
- reference.release();
1023
- }
1024
- }
1025
- /** Attempts only the verifier-authorized candidate order, with one separately
1026
- * prepaid carrier plan per attempt. A failed provider is fully retired by
1027
- * prepareNodeRawQUIC before the next candidate can consume its plan. */
1028
- export async function prepareNodeRawQUICCandidates(environment, fields, configured, drivers, signal, admission, endpointRole = 0, physicalDialerRole = endpointRole, attemptLimit = fields.totalCandidateAttempts ?? 1) {
1029
- const candidates = fields.candidates ?? [], preferred = fields.candidateIndex ?? candidates[0]?.candidateIndex ?? -1;
1030
- requireCredential(candidates.length > 0 && candidates.some(value => value.candidateIndex === preferred) && Number.isSafeInteger(attemptLimit) && attemptLimit >= 1 && attemptLimit <= 16, "credential_binding");
1031
- if (fields.source === "preauthorized_pool")
1032
- requireCredential(fields.preparationWork >= 1, "configuration_capacity");
1033
- const signedLimit = fields.totalCandidateAttempts ?? 1;
1034
- requireCredential(Number.isSafeInteger(signedLimit) && signedLimit >= 1, "credential_binding");
1035
- const ordered = [candidates.find(value => value.candidateIndex === preferred), ...candidates.filter(value => value.candidateIndex !== preferred)].slice(0, Math.min(attemptLimit, signedLimit));
1036
- const owner = originalNodeNativePreparationOwner(environment, fields, drivers[configured[0]?.nativeCarrier ?? "raw-quic"], admission);
1037
- let lastError;
1038
- try {
1039
- for (const candidate of ordered) {
1040
- if (signal?.aborted)
1041
- throw new Error("canceled");
1042
- fields.preparationDeadline.check();
1043
- requireCredential(candidate.pathKind === fields.pathKind, "credential_binding");
1044
- const kind = nodeRawQUICRouteCarrier(environment, candidate, endpointRole, admission), options = configured.find(value => (value.nativeCarrier ?? "raw-quic") === kind), driver = drivers[kind];
1045
- if (options === undefined || driver === undefined)
1046
- continue;
1047
- const selected = Object.freeze({ ...fields, ...candidate });
1048
- let carrier;
1049
- try {
1050
- carrier = await prepareNodeRawQUIC(environment, selected, options, driver, signal, admission, endpointRole, physicalDialerRole, candidate.candidateIndex, owner.candidate(selected));
1051
- // Network Prepare ends before durable spend. Activated HOP has its own
1052
- // original Grant quota and cannot consume this candidate's UDP cap.
1053
- carrier.completePreparation();
1054
- owner.transfer(carrier);
1055
- return carrier;
1056
- }
1057
- catch (error) {
1058
- if (carrier !== undefined)
1059
- await Promise.allSettled([carrier.close(), carrier.waitTermination()]);
1060
- lastError = error;
1061
- const code = error instanceof Error ? error.message : "";
1062
- if (signal?.aborted || ["canceled", "credential_binding", "credential_untrusted", "credential_expired", "credential_closed", "configuration_capacity", "resource_exhausted", "admission_closed", "required_guarantee_unavailable"].includes(code))
1063
- throw error;
1064
- }
1065
- }
1066
- if (lastError !== undefined)
1067
- throw lastError;
1068
- throw new Error("connection_requirement_unavailable");
1069
- }
1070
- finally {
1071
- owner.releaseUnused();
1072
- }
1073
- }
1074
- export async function prepareNodeRawQUIC(environment, fields, options, driver, signal, admission, endpointRole = 0, physicalDialerRole = endpointRole, selectedCandidateIndex = fields.candidateIndex ?? -1, preparationBudget) {
1075
- requireCredential(fields.accessClass === 0n, "credential_untrusted");
1076
- const costs = nodeRawQUICAdmissionCosts(fields.maxFrame, options, environment.resources.runtimeBytes), refs = admission?.take(costs.slice(0, -1));
1077
- let reserved;
1078
- try {
1079
- reserved = environment.admitDependencyPositions("node_raw_quic", costs[0][1], costs[1][1], options.applicationStreams + 1, refs, admission);
1080
- }
1081
- finally {
1082
- for (const ref of refs ?? [])
1083
- ref.release();
1084
- }
1085
- const { dependency, positions: prepaid } = reserved;
1086
- let positions, carrier, work;
1087
- try {
1088
- positions = new NativeProviderPositions(prepaid);
1089
- const ref = environment.reserveConnectionWork("node_raw_quic_policy", costs[costs.length - 1][1], admission);
1090
- try {
1091
- work = new CredentialWork(environment.resources, 16384, ref);
1092
- }
1093
- finally {
1094
- ref.release();
1095
- }
1096
- const route = work.parse(fields.route, "Route", 16384);
1097
- let endpoint, expectation;
1098
- try {
1099
- const leg = route.field(fields.pathKind === 0 ? "direct_leg" : endpointRole === 0 ? "client_leg" : "server_leg"), tls = route.field("tls_policy", leg, "Leg"), origin = route.optional("origin_policy", leg, "Leg");
1100
- requireCredential(route.uint("path_kind") === BigInt(fields.pathKind) && route.uint("access_class", leg, "Leg") === 0n && route.uint("carrier", leg, "Leg") === (options.nativeCarrier === "webtransport" ? 2n : 0n) &&
1101
- route.uint("endpoint_role", leg, "Leg") === (fields.pathKind === 0 ? 1n : BigInt(endpointRole)) && route.uint("dialer_role", leg, "Leg") === BigInt(physicalDialerRole) && route.uint("listener_role", leg, "Leg") === (fields.pathKind === 0 ? 1n : physicalDialerRole === 2 ? BigInt(endpointRole) : 2n) && route.text("path", leg, "Leg") === (options.nativeCarrier === "webtransport" ? `/flowersec/webtransport/v4/${fields.pathKind === 0 ? "direct" : "tunnel"}` : "") &&
1102
- route.text("subprotocol", leg, "Leg") === "" && route.text("alpn", leg, "Leg") === (options.nativeCarrier === "webtransport" ? "h3" : fields.pathKind === 0 ? "flowersec-direct/4" : "flowersec-tunnel/4") && (origin < 0 ? options.nativeCarrier !== "webtransport" : route.doc.boolean(route.field("allow_absent", origin, "OriginPolicy"))), "credential_untrusted");
1103
- endpoint = { host: route.text("host", leg, "Leg"), port: Number(route.uint("port", leg, "Leg")) };
1104
- const mode = route.uint("mode", tls, "TLSPolicy"), pins = [], now = environment.clock.sample().requireInterval();
1105
- if (mode === 0n)
1106
- requireCredential(options.trustRootsDER !== undefined, "configuration_capacity");
1107
- else {
1108
- requireCredential(mode === 1n && route.uint("pin_kind", tls, "TLSPolicy") === 0n, "credential_untrusted");
1109
- for (const pin of route.items("pins", tls, "TLSPolicy")) {
1110
- const from = route.uint("not_before_ms", pin, "TLSPin"), until = route.uint("not_after_ms", pin, "TLSPin");
1111
- if (now.lowerMS >= from && now.upperMS < until)
1112
- pins.push({ from, until, digest: route.bytes("leaf_der_sha256", pin, "TLSPin") });
1113
- }
1114
- requireCredential(pins.length > 0 && pins.length <= 16, "credential_expired");
1115
- }
1116
- expectation = { serverName: endpoint.host, mode: mode === 0n ? "ca" : "pin", pins };
1117
- }
1118
- finally {
1119
- route.close();
1120
- work.close();
1121
- work = undefined;
1122
- }
1123
- carrier = new NodeRawQUICCarrier(environment, dependency, positions, options, fields.preparationDeadline, "client", fields.pathKind === 0 ? "direct" : "tunnel", selectedCandidateIndex, preparationBudget);
1124
- await carrier.prepare(driver, endpoint, expectation, signal);
1125
- requireCredential((fields.required & 1n) === 0n || carrier.maxDatagramBytes() >= 76, "required_guarantee_unavailable");
1126
- return carrier;
1127
- }
1128
- catch (error) {
1129
- work?.close();
1130
- if (carrier !== undefined)
1131
- await Promise.allSettled([carrier.close(), carrier.waitTermination()]);
1132
- else {
1133
- positions?.close();
1134
- for (const position of prepaid)
1135
- position.closeAfterUse();
1136
- dependency.release();
1137
- }
1138
- throw error;
1139
- }
1140
- }
1141
- /** Relay dialing is selected from the original verified server Grant. No
1142
- * endpoint Session fields or direct route are manufactured for this hop. */
1143
- export function rawQUICRelayDialPolicy(environment, credentials, options, reference) {
1144
- credentials.check(reference);
1145
- const ref = environment.reserveConnectionWork("relay_quic_dial_policy", credentialWorkCharge(16384, environment.resources.runtimeBytes));
1146
- let work;
1147
- const bytes = credentials.descriptor(reference);
1148
- try {
1149
- work = new CredentialWork(environment.resources, 16384, ref);
1150
- const leg = work.parse(bytes, "Leg", 16384, 16384, { selectors: { path_kind: "tunnel" } });
1151
- try {
1152
- const tls = leg.field("tls_policy"), origin = leg.optional("origin_policy");
1153
- requireCredential(leg.uint("carrier") === (options.nativeCarrier === "webtransport" ? 2n : 0n) && leg.uint("access_class") === 0n && leg.uint("dialer_role") === 2n && leg.uint("listener_role") === BigInt(credentials.role) && leg.text("alpn") === (options.nativeCarrier === "webtransport" ? "h3" : "flowersec-tunnel/4") && leg.text("path") === (options.nativeCarrier === "webtransport" ? "/flowersec/webtransport/v4/tunnel" : "") && leg.text("subprotocol") === "" && (origin < 0 || leg.doc.boolean(leg.field("allow_absent", origin, "OriginPolicy"))));
1154
- const host = leg.text("host"), port = Number(leg.uint("port")), mode = leg.uint("mode", tls, "TLSPolicy"), pins = [], now = environment.clock.sample().requireInterval();
1155
- if (mode === 0n)
1156
- requireCredential(options.trustRootsDER !== undefined, "configuration_capacity");
1157
- else {
1158
- requireCredential(mode === 1n && leg.uint("pin_kind", tls, "TLSPolicy") === 0n);
1159
- for (const pin of leg.items("pins", tls, "TLSPolicy")) {
1160
- const from = leg.uint("not_before_ms", pin, "TLSPin"), until = leg.uint("not_after_ms", pin, "TLSPin");
1161
- if (now.lowerMS >= from && now.upperMS < until)
1162
- pins.push({ from, until, digest: leg.bytes("leaf_der_sha256", pin, "TLSPin") });
1163
- }
1164
- requireCredential(pins.length > 0, "credential_expired");
1165
- }
1166
- return Object.freeze({ endpoint: Object.freeze({ host, port }), expectation: Object.freeze({ mode: mode === 0n ? "ca" : "pin", serverName: host, pins: Object.freeze(pins) }) });
1167
- }
1168
- finally {
1169
- leg.close();
1170
- }
1171
- }
1172
- finally {
1173
- bytes.fill(0);
1174
- work?.close();
1175
- ref.release();
1176
- }
1177
- }