@floegence/flowersec-core 5.11.0 → 6.1.0

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