@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,1443 +0,0 @@
1
- import { applicationResumeFeature } from "./checkpointToken.js";
2
- import { ed25519, x25519 } from "@noble/curves/ed25519.js";
3
- import { p256 } from "@noble/curves/nist.js";
4
- import { TimeError } from "./timeArithmetic.js";
5
- import { TrustedDeadline } from "./deadline.js";
6
- import { isCredentialNamespace } from "./credentialNamespace.js";
7
- import { CredentialWork, credentialWorkCharge, checkCredentialTime, credentialDigest, credentialOwner, equalCredential, requireCredential } from "./credentialSupport.js";
8
- import { FixedCBORWriter } from "./openAdmission.js";
9
- import { CBORDecoder, cborDecoderCharge } from "./cbor.js";
10
- import { ResourceVector } from "./resources.js";
11
- import { ownProfile } from "./wireRegistry.js";
12
- import { HopAuthenticationPreparation } from "./hopAuthentication.js";
13
- import { verifyRelayCredentials, RelayCredentialPreparation } from "./relayCredentials.js";
14
- export function credentialVerifierCharge(runtimeBytes) {
15
- requireCredential(runtimeBytes > 0n, "configuration_capacity");
16
- // Original material, result projection, route/set encoding and bounded crypto
17
- // temporaries stay paid through the verified closure's last use.
18
- return new ResourceVector([524288n + runtimeBytes, 0n, 0n, 16n, 1n, 1n, 0n, 0n, 0n, 0n, 0n]);
19
- }
20
- /** Owns every additional tunnel verification and hop position before the
21
- * configured credential provider can publish or remove an original lease. */
22
- const liveMaterialDecoderConfig = (runtimeBytes) => Object.freeze({ bytes: 73728, nodes: 8, textBytes: 32, arrayItems: 3, runtimeBytes });
23
- export class TunnelCredentialPreparation {
24
- #reference;
25
- #work;
26
- #decoder;
27
- #relays = [];
28
- #hops = [];
29
- constructor(config) {
30
- requireCredential(config.tunnel !== undefined, "configuration_capacity");
31
- const resources = config.resources, capacity = config.tunnel.candidateCapacity ?? 1;
32
- requireCredential(Number.isSafeInteger(capacity) && capacity >= 1 && capacity <= 16, "configuration_capacity");
33
- const material = credentialVerifierCharge(resources.runtimeBytes).add(new ResourceVector([resources.runtimeBytes, 0n, 0n, 0n, 0n, 0n, 1n, 0n, 0n, 0n, 0n]));
34
- const refs = resources.root.reserveBatch([material, credentialWorkCharge(270336, resources.runtimeBytes), cborDecoderCharge(liveMaterialDecoderConfig(resources.runtimeBytes))].map((charge, index) => ({ owner: credentialOwner(resources, `tunnel_preparation_${index}`), accounts: resources.accounts, charge })));
35
- try {
36
- this.#decoder = new CBORDecoder(liveMaterialDecoderConfig(resources.runtimeBytes), refs[2]);
37
- this.#reference = refs[0].take(material);
38
- this.#work = new CredentialWork(resources, 270336, refs[1]);
39
- this.#work.prepaySignatures(65536, 32768);
40
- this.#work.prepayParsers(65536, 32768, 8);
41
- for (let index = 0; index < capacity; index++) {
42
- this.#relays.push(new RelayCredentialPreparation(resources, config.namespaces));
43
- this.#hops.push(new HopAuthenticationPreparation(resources));
44
- }
45
- Object.freeze(this);
46
- }
47
- catch (error) {
48
- this.close();
49
- throw error;
50
- }
51
- finally {
52
- for (const ref of refs)
53
- ref.release();
54
- }
55
- }
56
- takeMaterial() { requireCredential(this.#reference !== undefined); this.#reference.check(); const result = this.#reference; this.#reference = undefined; return result; }
57
- takeWork(reference) { requireCredential(this.#work !== undefined && this.#work.sameEnvironment(reference)); const result = this.#work; this.#work = undefined; return result; }
58
- takeLiveDecoder() { requireCredential(this.#decoder !== undefined); const result = this.#decoder; this.#decoder = undefined; return result; }
59
- takeRelay() { const result = this.#relays.shift(); requireCredential(result !== undefined); return result; }
60
- takeHop() { const result = this.#hops.shift(); requireCredential(result !== undefined); return result; }
61
- close() { this.#decoder?.close(); this.#decoder = undefined; for (const hop of this.#hops.splice(0))
62
- hop.close(); for (const relay of this.#relays.splice(0))
63
- relay.close(); this.#work?.close(); this.#work = undefined; this.#reference?.release(); this.#reference = undefined; }
64
- }
65
- function clearCredentialEvidence(evidence) {
66
- evidence.issuer.fill(0);
67
- evidence.digest.fill(0);
68
- evidence.permissionDigest.fill(0);
69
- evidence.lease?.fill(0);
70
- evidence.grant?.fill(0);
71
- }
72
- const token = Symbol("original verified credential closure");
73
- function notifyCallback(callback) {
74
- if (callback === undefined)
75
- return;
76
- try {
77
- const result = callback();
78
- if (result !== undefined && typeof result === "object" && result !== null && "then" in result && typeof result.then === "function")
79
- void Promise.resolve(result).catch(() => undefined);
80
- }
81
- catch { /* Revocation is a safety signal; the owning Session observes the denied state. */ }
82
- }
83
- const closures = new WeakMap();
84
- export function isVerifiedCredentialClosure(value) {
85
- return typeof value === "object" && value !== null && closures.has(value);
86
- }
87
- function original(value) {
88
- const state = closures.get(value);
89
- requireCredential(state !== undefined && !state.closed, "credential_closed");
90
- return state;
91
- }
92
- const poolFacts = new WeakMap();
93
- export class VerifiedPoolSpendFacts {
94
- constructor(capability, state) { requireCredential(capability === token); poolFacts.set(this, state); Object.freeze(this); }
95
- check(reference) {
96
- const state = poolFacts.get(this);
97
- requireCredential(state !== undefined && !state.closed);
98
- requireCredential(state.reference.sameEnvironment(reference));
99
- state.closure.checkPreparation(reference);
100
- }
101
- fields(reference) {
102
- this.check(reference);
103
- const fields = poolFacts.get(this).fields;
104
- return Object.freeze({ ...fields, issuer: new Uint8Array(fields.issuer), lease: new Uint8Array(fields.lease), attempt: new Uint8Array(fields.attempt),
105
- artifactDigest: new Uint8Array(fields.artifactDigest), proofDigest: new Uint8Array(fields.proofDigest), proof: new Uint8Array(fields.proof),
106
- candidateID: new Uint8Array(fields.candidateID), routeDigest: new Uint8Array(fields.routeDigest), descriptor: new Uint8Array(fields.descriptor),
107
- candidateSet: new Uint8Array(fields.candidateSet), routeSet: new Uint8Array(fields.routeSet), sessionNonce: new Uint8Array(fields.sessionNonce),
108
- capacityDigest: new Uint8Array(fields.capacityDigest), identities: Object.freeze(fields.identities.map(value => new Uint8Array(value))) });
109
- }
110
- close() {
111
- const state = poolFacts.get(this);
112
- if (state === undefined || state.closed)
113
- return;
114
- state.closed = true;
115
- for (const value of Object.values(state.fields))
116
- if (value instanceof Uint8Array)
117
- value.fill(0);
118
- for (const value of state.fields.identities)
119
- value.fill(0);
120
- state.reference.release();
121
- }
122
- toJSON() { return {}; }
123
- }
124
- export function isVerifiedPoolSpendFacts(value) { return value instanceof VerifiedPoolSpendFacts && poolFacts.has(value); }
125
- /** Unforgeable internal mathematical/authorization closure. It is never an
126
- * assertion of durable spend, server admission, provider identity or READY.
127
- * It cannot be serialized/restored or constructed with asserted success. */
128
- export class VerifiedCredentialClosure {
129
- constructor(capability, state) {
130
- requireCredential(capability === token, "credential_untrusted");
131
- closures.set(this, state);
132
- Object.freeze(this);
133
- }
134
- /** Internal synchronous handoff from the verified material's current owner. */
135
- withOriginalMaterialReference(handoff) {
136
- const state = original(this);
137
- this.checkPreparation(state.reference);
138
- return handoff(state.reference);
139
- }
140
- checkPreparation(reference) {
141
- const s = original(this);
142
- requireCredential(!s.detached, "credential_closed");
143
- this.#check(s, reference);
144
- s.preparationDeadline.check();
145
- checkCredentialTime(s.config.clock, s.from, s.initiation);
146
- }
147
- originalPreparationDeadline(reference) {
148
- this.checkPreparation(reference);
149
- return original(this).preparationDeadline;
150
- }
151
- /** Pool retention cannot extend original signed preparation or certificate authority. */
152
- checkPoolInstallExpiry(expiry, reference) {
153
- this.checkPreparation(reference);
154
- const s = original(this);
155
- requireCredential(expiry > s.config.clock.sample().requireInterval().upperMS && expiry <= s.preparationDeadline.cap && expiry <= s.sessionDeadline.cap, "credential_binding");
156
- }
157
- checkApplicationProfile(profile, reference) {
158
- this.checkPreparation(reference);
159
- if (original(this).applicationProfile !== (profile === "transport" ? 0n : profile === "services" ? 1n : 2n))
160
- throw new Error("connection_requirement_unavailable");
161
- }
162
- checkConnectionRequirements(request, reference, candidateIndex = original(this).candidateIndex) {
163
- this.checkPreparation(reference);
164
- const s = original(this), artifact = s.maps[0], candidates = [...artifact.items("candidates")];
165
- requireCredential(Number.isSafeInteger(candidateIndex) && candidateIndex >= 0 && candidateIndex < candidates.length, "credential_binding");
166
- const candidate = candidates[candidateIndex];
167
- if (s.activation !== undefined)
168
- checkSelection({ source: s.source, candidateIndex }, artifact, s.activation, s.artifactDigest, artifact.bytes("candidate_id", candidate, "Candidate"), candidateRouteDigest(artifact, candidate), s.once);
169
- if (request.application_profile !== undefined)
170
- this.checkApplicationProfile(request.application_profile, reference);
171
- if (request.datagram && (s.allowed & 1n) === 0n)
172
- throw new Error("connection_requirement_unavailable");
173
- const legs = s.pathKind === 0 ? ["direct_leg"] : ["client_leg", "server_leg"];
174
- const hasMessageLeg = legs.some(name => artifact.uint("carrier", artifact.field(name, candidate, "Candidate"), "Leg") === 1n);
175
- if ((request.datagram || request.independent_reliable_read_progress || request.bound_stream_input_isolation) && hasMessageLeg) {
176
- throw new Error("connection_requirement_unavailable");
177
- }
178
- }
179
- clientPreparation(reference, candidateIndex = original(this).candidateIndex) {
180
- this.checkPreparation(reference);
181
- const s = original(this), artifact = s.maps[0], candidates = [...artifact.items("candidates")];
182
- requireCredential(Number.isSafeInteger(candidateIndex) && candidateIndex >= 0 && candidateIndex < candidates.length && (!s.selectionSealed || candidateIndex === s.candidateIndex), "credential_binding");
183
- const activation = s.activation;
184
- const authorizedIndices = activation === undefined ? [s.candidateIndex] : checkSelection({ source: s.source, candidateIndex }, artifact, activation, s.artifactDigest, artifact.bytes("candidate_id", candidates[candidateIndex], "Candidate"), candidateRouteDigest(artifact, candidates[candidateIndex]), s.once);
185
- const availableIndices = s.selectionSealed ? [s.candidateIndex] : s.pathKind === 0 || s.source === "live_authority" ? authorizedIndices : authorizedIndices.filter(index => s.tunnelCandidates.has(index));
186
- requireCredential(availableIndices.includes(candidateIndex), "credential_binding");
187
- const route = (index) => {
188
- const candidate = candidates[index], pathKind = Number(artifact.uint("path_kind", candidate, "Candidate"));
189
- requireCredential(pathKind === s.pathKind, "connection_requirement_unavailable");
190
- const buffer = new Uint8Array(16384), writer = new FixedCBORWriter(buffer), copied = [];
191
- try {
192
- const id = artifact.bytes("candidate_id", candidate, "Candidate");
193
- copied.push(id);
194
- writer.map(pathKind === 0 ? 3 : 4).uint(0).uint(pathKind).uint(1).data(id);
195
- for (const [id, name] of pathKind === 0 ? [[2, "direct_leg"]] : [[3, "client_leg"], [4, "server_leg"]]) {
196
- const leg = artifact.encoded(artifact.field(name, candidate, "Candidate"));
197
- copied.push(leg);
198
- writer.uint(id).encoded(leg);
199
- }
200
- return new Uint8Array(writer.result());
201
- }
202
- finally {
203
- buffer.fill(0);
204
- for (const value of copied)
205
- value.fill(0);
206
- }
207
- };
208
- const project = (index) => {
209
- const candidate = candidates[index], pathKind = Number(artifact.uint("path_kind", candidate, "Candidate"));
210
- requireCredential(pathKind === s.pathKind, "connection_requirement_unavailable");
211
- if (pathKind === 0)
212
- checkClosure(artifact, candidate, [s.evidence[0].namespace, s.evidence[1].namespace, s.evidence[2].namespace]);
213
- const candidateID = artifact.bytes("candidate_id", candidate, "Candidate");
214
- let routeBytes, routeDigest;
215
- try {
216
- routeBytes = route(index);
217
- routeDigest = credentialDigest("route_digest", routeBytes);
218
- const pathLeg = artifact.field(pathKind === 0 ? "direct_leg" : s.localRole === 0 ? "client_leg" : "server_leg", candidate, "Candidate");
219
- const messageRoute = (pathKind === 0 ? ["direct_leg"] : ["client_leg", "server_leg"]).some(name => artifact.uint("carrier", artifact.field(name, candidate, "Candidate"), "Leg") === 1n);
220
- return Object.freeze({ candidateIndex: index, candidateID, routeDigest, route: routeBytes,
221
- accessClass: artifact.uint("access_class", pathLeg, "Leg"), pathKind, reliableProgress: messageRoute ? "shared_ordered" : "native_bound" });
222
- }
223
- catch (error) {
224
- candidateID.fill(0);
225
- routeBytes?.fill(0);
226
- routeDigest?.fill(0);
227
- throw error;
228
- }
229
- };
230
- const projected = [];
231
- try {
232
- for (const index of availableIndices)
233
- projected.push(project(index));
234
- }
235
- catch (error) {
236
- for (const candidate of projected) {
237
- candidate.candidateID.fill(0);
238
- candidate.routeDigest.fill(0);
239
- candidate.route.fill(0);
240
- }
241
- throw error;
242
- }
243
- const selected = projected.find(value => value.candidateIndex === candidateIndex);
244
- requireCredential(selected !== undefined, "credential_binding");
245
- const resume = artifact.field("resume_policy");
246
- let preparationBytes = 0, totalPreparationBytes = 0, preparationWork = 0, totalCandidateAttempts = 1, preparationAddressAttempts = 1, totalPreparationWork = 0;
247
- if (s.source === "preauthorized_pool") {
248
- requireCredential(activation !== undefined);
249
- const selection = activation.field("candidate_selection"), budget = activation.field("attempt_budget", selection, "PoolSelectionRef"), perCandidate = activation.field("per_candidate", budget, "PoolAttemptBudget");
250
- totalCandidateAttempts = Number(min(activation.uint("total_address_attempts", budget, "PoolAttemptBudget"), activation.uint("total_work_units", budget, "PoolAttemptBudget")));
251
- totalPreparationBytes = Number(activation.uint("total_preauth_bytes", budget, "PoolAttemptBudget"));
252
- totalPreparationWork = Number(activation.uint("total_work_units", budget, "PoolAttemptBudget"));
253
- preparationAddressAttempts = Number(activation.uint("address_attempts", perCandidate, "CandidateAttemptBudget"));
254
- preparationBytes = Number(min(activation.uint("preauth_bytes", perCandidate, "CandidateAttemptBudget"), BigInt(totalPreparationBytes)));
255
- preparationWork = Number(min(activation.uint("work_units", perCandidate, "CandidateAttemptBudget"), activation.uint("total_work_units", budget, "PoolAttemptBudget")));
256
- }
257
- return Object.freeze({ candidateIndex, candidates: Object.freeze(projected), totalCandidateAttempts, totalPreparationBytes, preparationAddressAttempts, totalPreparationWork,
258
- ...(selected.reliableProgress === undefined ? {} : { reliableProgress: selected.reliableProgress }), pathKind: selected.pathKind, accessClass: selected.accessClass, source: s.source, profile: s.profile, tenant: s.config.tenant,
259
- issuer: artifact.bytes("issuer_key_id"), lease: artifact.bytes("lease_id"), artifactDigest: new Uint8Array(s.artifactDigest), candidateID: new Uint8Array(selected.candidateID), routeDigest: new Uint8Array(selected.routeDigest), route: new Uint8Array(selected.route),
260
- attempt: new Uint8Array(s.attemptID), nonce: new Uint8Array(s.nonce), activation: activation?.encoded() ?? new Uint8Array(), clientCertificate: s.maps[1].encoded(), serverCertificate: s.maps[2].encoded(),
261
- identities: s.certificateDigests.map(x => new Uint8Array(x)), noiseKeys: s.noiseKeys.map(x => new Uint8Array(x)), identityKeys: s.identityKeys.map(x => new Uint8Array(x)), psk: new Uint8Array(s.psk),
262
- allowed: s.allowed, required: s.required, resume: artifact.doc.boolean(artifact.field("enabled", resume, "ResumePolicy")), maxFrame: Number(s.maxFrame), maxStreams: Number(s.maxStreams), maxCredit: s.maxCredit,
263
- applicationProfile: s.applicationProfile, idleDurationMS: s.idleDurationMS, rpcMaxGeneralOutstanding: Number(s.rpcMaxGeneralOutstanding), rekeyBurst: s.rekeyBurst, rekeyRefill: s.rekeyRefill,
264
- preparationDeadline: s.preparationDeadline, sessionDeadline: s.sessionDeadline, preparationBytes, preparationWork });
265
- }
266
- clientPreparationForCandidate(reference, candidateIndex) {
267
- return this.clientPreparation(reference, candidateIndex);
268
- }
269
- /** Commits the original prepared member before TxA. All later spend, hop,
270
- * HELLO/FSB and Session facts read the same closure-owned selection. */
271
- selectClientCandidate(reference, candidateIndex) {
272
- this.checkPreparation(reference);
273
- const s = original(this);
274
- requireCredential(!s.claimed && !s.selectionSealed, "credential_binding");
275
- const owner = s.pathKind === 1 && s.source === "preauthorized_pool" ? s.tunnelCandidates.get(candidateIndex) : undefined;
276
- if (s.pathKind === 1 && s.source === "preauthorized_pool") {
277
- requireCredential(owner !== undefined, "credential_binding");
278
- owner.relay.check(reference);
279
- }
280
- const fields = this.clientPreparation(reference, candidateIndex);
281
- if (owner !== undefined) {
282
- s.relay = owner.relay;
283
- s.hop = owner.hop;
284
- for (const [index, other] of s.tunnelCandidates)
285
- if (index !== candidateIndex) {
286
- other.hop?.close();
287
- other.relay.close();
288
- s.tunnelCandidates.delete(index);
289
- }
290
- s.sessionEnd = min(s.sessionEnd, owner.relay.deadline.cap);
291
- s.sessionDeadline.tighten(s.sessionEnd);
292
- }
293
- s.candidateIndex = candidateIndex;
294
- s.candidateID.set(fields.candidateID);
295
- s.routeDigest.set(fields.routeDigest);
296
- s.selectionSealed = true;
297
- return fields;
298
- }
299
- /** One original client attempt, selected before carrier preparation. No
300
- * activation success or durable-spend fact is inferred from this binding. */
301
- beginLivePreparation(attempt, reference) {
302
- this.checkPreparation(reference);
303
- const s = original(this);
304
- requireCredential(s.source === "live_authority" && s.activation === undefined && !s.claimed && !s.attemptID.some(n => n !== 0) &&
305
- attempt.length === 16 && attempt.some(n => n !== 0), "credential_binding");
306
- s.attemptID.set(attempt);
307
- }
308
- /** Routing binds an accepted live attempt to this original signed snapshot.
309
- * The hello remains unauthenticated until the matching FSB signature and
310
- * independently signed activation proof pass the admission gate. */
311
- bindAcceptedLiveAttempt(helloBytes, reference) {
312
- this.checkPreparation(reference);
313
- const s = original(this);
314
- if (s.source !== "live_authority" || s.activation !== undefined)
315
- return;
316
- requireCredential(!s.claimed && !s.attemptID.some(byte => byte !== 0), "credential_binding");
317
- const hello = s.work.parse(helloBytes, "ClientHello", 16384);
318
- let attempt;
319
- try {
320
- requireCredential(hello.text("crypto_profile_id") === s.profile &&
321
- equalCredential(hello.bytes("artifact_digest"), s.artifactDigest) && equalCredential(hello.bytes("candidate_id"), s.candidateID) &&
322
- equalCredential(hello.bytes("route_digest"), s.routeDigest) && equalCredential(hello.bytes("client_nonce"), s.nonce), "credential_binding");
323
- attempt = hello.bytes("attempt_id");
324
- this.beginLivePreparation(attempt, reference);
325
- }
326
- finally {
327
- attempt?.fill(0);
328
- hello.close();
329
- }
330
- }
331
- liveAuthorizationRequest(reference) {
332
- this.checkPreparation(reference);
333
- const s = original(this), artifact = s.maps[0];
334
- requireCredential(s.source === "live_authority" && s.activation === undefined && s.attemptID.some(n => n !== 0), "credential_binding");
335
- return Object.freeze({ tenant: s.config.tenant, audience: s.config.audience, cryptoProfile: s.profile,
336
- authority: s.once.text("spend_authority_id"), issuer: artifact.bytes("issuer_key_id"), lease: artifact.bytes("lease_id"),
337
- attempt: new Uint8Array(s.attemptID), artifact: new Uint8Array(s.artifactDigest),
338
- clientIdentity: new Uint8Array(s.certificateDigests[0]), serverIdentity: new Uint8Array(s.certificateDigests[1]),
339
- candidateIndex: s.candidateIndex, candidateID: new Uint8Array(s.candidateID), routeDigest: new Uint8Array(s.routeDigest),
340
- activationNotAfterMS: s.initiation, attemptNo: 1 });
341
- }
342
- /** Install the authority's actual signed response once, under the original
343
- * prepared carrier/admission guard. A query receipt cannot pass this gate. */
344
- /** A verified original authority response proves durable spend even when a
345
- * later relay handoff fails. This observation neither installs nor activates it. */
346
- observeLiveSpend(bytes, reference) {
347
- this.checkPreparation(reference);
348
- const s = original(this);
349
- requireCredential(s.source === "live_authority" && s.activation === undefined && s.attemptID.some(n => n !== 0), "credential_binding");
350
- const activation = s.work.parse(bytes, "ActivationAuthorization", 4096, 16384, { selectors: { activation_source_profile: s.source } });
351
- let evidence;
352
- try {
353
- const verified = validateActivation(s.config, s.work, s.maps[0], activation, s.evidence[0], s.once, s.source, s.candidateIndex, s.artifactDigest, s.candidateID, s.routeDigest);
354
- evidence = verified.evidence;
355
- requireCredential(equalCredential(activation.bytes("attempt_id"), s.attemptID), "credential_binding");
356
- this.checkPreparation(reference);
357
- }
358
- finally {
359
- if (evidence !== undefined)
360
- clearCredentialEvidence(evidence);
361
- activation.close();
362
- }
363
- }
364
- installLiveAuthorization(bytes, reference) {
365
- this.checkPreparation(reference);
366
- const s = original(this);
367
- requireCredential(s.source === "live_authority" && s.activation === undefined && s.attemptID.some(n => n !== 0), "credential_binding");
368
- let activation, relay, activationEvidence;
369
- let activationBytes, grantBytes;
370
- try {
371
- if (s.pathKind === 1) {
372
- const pending = s.liveTunnel;
373
- requireCredential(pending !== undefined, "credential_binding");
374
- const doc = pending.decoder.decode(bytes);
375
- try {
376
- requireCredential(doc.sameEnvironment(reference) && doc.kind() === "array" && doc.size() === 3, "control_response_invalid");
377
- const label = doc.firstChild(), proof = doc.nextSibling(label), grant = doc.nextSibling(proof);
378
- requireCredential(doc.kind(label) === "text" && doc.text(label) === "live-tunnel-material-1" && doc.kind(proof) === "bytes" && doc.size(proof) > 0 && doc.size(proof) <= 4096 &&
379
- doc.kind(grant) === "bytes" && doc.size(grant) > 0 && doc.size(grant) <= 65536 && doc.nextSibling(grant) < 0, "control_response_invalid");
380
- activationBytes = new Uint8Array(doc.size(proof));
381
- grantBytes = new Uint8Array(doc.size(grant));
382
- doc.copyPayload(proof, activationBytes);
383
- doc.copyPayload(grant, grantBytes);
384
- }
385
- finally {
386
- doc.release();
387
- }
388
- }
389
- else {
390
- activationBytes = new Uint8Array(bytes);
391
- }
392
- requireCredential(activationBytes !== undefined);
393
- activation = s.work.parse(activationBytes, "ActivationAuthorization", 4096, 16384, { selectors: { activation_source_profile: s.source } });
394
- const verified = validateActivation(s.config, s.work, s.maps[0], activation, s.evidence[0], s.once, s.source, s.candidateIndex, s.artifactDigest, s.candidateID, s.routeDigest);
395
- activationEvidence = verified.evidence;
396
- requireCredential(equalCredential(activation.bytes("attempt_id"), s.attemptID), "credential_binding");
397
- if (s.pathKind === 1) {
398
- const pending = s.liveTunnel, policy = s.config.tunnel;
399
- pending.scope.namespace.checkEvidence(pending.scope);
400
- relay = verifyRelayCredentials({ ...s.config, audience: policy.audience, service: policy.service,
401
- endpointSubject: s.localRole === 0 ? s.config.clientSubject : s.config.serverSubject, relaySubject: policy.relaySubject }, { grant: grantBytes, endpointCertificate: pending.endpointCertificate, relayCertificate: pending.relayCertificate }, pending.preparation);
402
- requireCredential(relay.role === s.localRole, "credential_binding");
403
- const artifact = s.maps[0], candidate = [...artifact.items("candidates")][s.candidateIndex];
404
- validateTunnelGrantProjection(s.config, s.work, artifact, candidate, activation, s.localRole, s.evidence.slice(0, 3), s.artifactDigest, s.routeDigest, grantBytes, pending.relayCertificate, relay, pending.scope);
405
- }
406
- this.checkPreparation(reference);
407
- s.preparationDeadline.tighten(min(s.initiation, verified.initiation));
408
- const sessionEnd = min(s.sessionEnd, verified.sessionEnd, relay?.deadline.cap ?? s.sessionEnd);
409
- s.sessionDeadline.tighten(sessionEnd);
410
- s.from = max(s.from, verified.issued);
411
- s.initiation = min(s.initiation, verified.initiation);
412
- s.sessionEnd = sessionEnd;
413
- s.activationDigest.set(s.work.digest(activation, "activation_digest"));
414
- s.evidence.push(verified.evidence);
415
- activationEvidence = undefined;
416
- s.maps.push(activation);
417
- s.activation = activation;
418
- activation = undefined;
419
- if (relay !== undefined) {
420
- s.relay = relay;
421
- relay = undefined;
422
- s.relay.onRevoked(error => { if (s.closed || s.denied !== undefined)
423
- return; s.denied = error; notifyCallback(s.revoked); });
424
- s.liveTunnel.decoder.close();
425
- s.liveTunnel.preparation.close();
426
- s.liveTunnel.relayCertificate.fill(0);
427
- s.liveTunnel.endpointCertificate.fill(0);
428
- s.liveTunnel = undefined;
429
- }
430
- this.checkPreparation(reference);
431
- const installed = activationBytes;
432
- activationBytes = undefined;
433
- return installed;
434
- }
435
- catch (error) {
436
- s.denied = error;
437
- throw error;
438
- }
439
- finally {
440
- if (activationEvidence !== undefined)
441
- clearCredentialEvidence(activationEvidence);
442
- activation?.close();
443
- relay?.close();
444
- activationBytes?.fill(0);
445
- grantBytes?.fill(0);
446
- }
447
- }
448
- checkClientIdentity(privateKey, identityKey, reference) {
449
- this.checkPreparation(reference);
450
- const s = original(this);
451
- requireCredential(equalCredential(identityKey, s.identityKeys[0]));
452
- const key = ownProfile(s.profile).dh_algorithm === 0 ? x25519.getPublicKey(privateKey) : p256.getPublicKey(privateKey, false);
453
- try {
454
- requireCredential(equalCredential(key, s.noiseKeys[0]));
455
- }
456
- finally {
457
- key.fill(0);
458
- }
459
- }
460
- checkServerIdentity(privateKey, identityKey, reference) {
461
- this.checkPreparation(reference);
462
- const s = original(this);
463
- requireCredential(equalCredential(identityKey, s.identityKeys[1]));
464
- const key = ownProfile(s.profile).dh_algorithm === 0 ? x25519.getPublicKey(privateKey) : p256.getPublicKey(privateKey, false);
465
- try {
466
- requireCredential(equalCredential(key, s.noiseKeys[1]));
467
- }
468
- finally {
469
- key.fill(0);
470
- }
471
- }
472
- prepayHandshakeChecks(reference) {
473
- this.checkPreparation(reference);
474
- const s = original(this);
475
- if (s.handshakeChecksPrepared)
476
- return;
477
- s.work.prepaySignatures(65536, 16384);
478
- // Live proof installation retains one original position. Admission uses
479
- // two temporary maps at a time; those maps retire before the FSA checks.
480
- s.work.prepayParsers(65536, 16384, 3);
481
- s.handshakeChecksPrepared = true;
482
- }
483
- /** A rejection is authenticated with its supplied server certificate too.
484
- * Its zero identity sentinel never becomes a certificate-digest check. */
485
- authenticateAdmission(map, work, reference) {
486
- this.checkPreparation(reference);
487
- const s = original(this), bytes = map.bytes("server_certificate");
488
- const certificate = work.parse(bytes, "IdentityCertificate", 8192);
489
- bytes.fill(0);
490
- try {
491
- requireCredential(certificate.text("tenant_id") === s.config.tenant && certificate.text("audience") === s.config.audience &&
492
- certificate.text("subject_id") === s.config.serverSubject && certificate.text("crypto_profile_id") === s.profile && certificate.uint("role") === 1n, "credential_untrusted");
493
- const namespace = s.config.namespaces.find(n => n.matches(certificate));
494
- requireCredential(namespace !== undefined, "credential_untrusted");
495
- checkCredentialTime(s.config.clock, certificate.uint("issued_at_ms"), certificate.uint("expires_at_ms"));
496
- const evidence = namespace.verifyCredential(certificate, 0, work), parentPolicy = s.evidence[0].namespace.policyRequirements(s.evidence[0]), childPolicy = namespace.policyRequirements(evidence);
497
- requireCredential(parentPolicy.staleness <= childPolicy.staleness && parentPolicy.signerLifetime <= childPolicy.signerLifetime);
498
- namespace.checkPolicy(parentPolicy.staleness, parentPolicy.signerLifetime);
499
- const key = certificate.bytes("ed25519_public_key");
500
- try {
501
- work.verify(map, key);
502
- }
503
- finally {
504
- key.fill(0);
505
- }
506
- if (map.uint("status") === 0n)
507
- requireCredential(equalCredential(evidence.digest, s.certificateDigests[1]) && equalCredential(map.bytes("server_identity_digest"), evidence.digest));
508
- this.checkPreparation(reference);
509
- }
510
- finally {
511
- certificate.close();
512
- }
513
- }
514
- #check(s, reference) {
515
- if (s.denied !== undefined)
516
- throw s.denied;
517
- s.relay?.check(reference);
518
- for (const subscription of s.subscriptions)
519
- subscription.check();
520
- s.work?.check();
521
- s.reference.check();
522
- requireCredential(s.reference.sameEnvironment(reference));
523
- s.sessionDeadline.check();
524
- checkCredentialTime(s.config.clock, s.from, s.sessionEnd);
525
- let staleness = (1n << 64n) - 1n, signerLifetime = staleness;
526
- for (const evidence of s.evidence) {
527
- evidence.namespace.check(reference);
528
- evidence.namespace.checkEvidence(evidence);
529
- const policy = evidence.namespace.policyRequirements(evidence);
530
- staleness = min(staleness, policy.staleness);
531
- signerLifetime = min(signerLifetime, policy.signerLifetime);
532
- }
533
- for (const namespace of new Set(s.evidence.map(e => e.namespace))) {
534
- namespace.checkPolicy(staleness, signerLifetime);
535
- const original = s.freshness.get(namespace), [generation, sequence] = namespace.activeVersion(), cap = namespace.availableUntil(staleness);
536
- // A callback installed after an original deadline expired cannot revive
537
- // that Session, even when its new namespace Head is independently fresh.
538
- original?.deadline.check();
539
- if (original?.generation !== generation || original.sequence !== sequence)
540
- s.freshness.set(namespace, { generation, sequence, deadline: new TrustedDeadline(s.config.clock, cap) });
541
- else if (cap < original.deadline.cap)
542
- original.deadline.tighten(cap);
543
- }
544
- }
545
- attachNamespaces(capability, prepared) {
546
- requireCredential(capability === token, "credential_untrusted");
547
- const s = original(this);
548
- for (const ns of new Set(s.evidence.map(e => e.namespace))) {
549
- const subscription = prepared === undefined ? ns.reserveSubscription(s.reference) : prepared.get(ns);
550
- requireCredential(subscription !== undefined);
551
- s.subscriptions.push(subscription);
552
- prepared?.delete(ns);
553
- subscription.attach(ns, s.reference, () => {
554
- if (s.closed || s.denied !== undefined)
555
- return;
556
- try {
557
- this.#check(s, s.reference);
558
- notifyCallback(s.changed);
559
- }
560
- catch (error) {
561
- if (error instanceof TimeError && ["time_unavailable", "time_continuity", "time_pending"].includes(error.code))
562
- return;
563
- s.denied = error;
564
- notifyCallback(s.revoked);
565
- }
566
- });
567
- }
568
- this.#check(s, s.reference);
569
- }
570
- /** Fix the opposite leg and original recipient before the consumer's TxA-P.
571
- * Verification grants no publication: only Connect uses this prepared slot
572
- * after its own consume call explicitly succeeds. */
573
- poolServerAllowCandidate(reference) {
574
- this.checkPreparation(reference);
575
- const s = original(this);
576
- requireCredential(s.source === "preauthorized_pool" && s.localRole === 0, "credential_binding");
577
- return s.pathKind === 1 ? s.candidateIndex : undefined;
578
- }
579
- requiresPoolServerAllow(reference) {
580
- this.checkPreparation(reference);
581
- const s = original(this);
582
- return s.source === "preauthorized_pool" && s.pathKind === 1 && s.localRole === 1;
583
- }
584
- checkPoolServerAllow(request, grant, reference) {
585
- this.checkPreparation(reference);
586
- const s = original(this);
587
- requireCredential(s.source === "preauthorized_pool" && s.pathKind === 1 && s.localRole === 1 && s.relay !== undefined && s.activation !== undefined &&
588
- request.tenant === s.config.tenant && request.audience === s.config.audience && request.candidateIndex === s.candidateIndex &&
589
- equalCredential(request.artifact, s.artifactDigest) && equalCredential(request.attempt, s.attemptID) && equalCredential(request.candidateID, s.candidateID) && equalCredential(request.routeDigest, s.routeDigest), "credential_binding");
590
- const originalGrant = s.relay.grant(reference);
591
- let map;
592
- const copied = [], keep = (bytes) => { copied.push(bytes); return bytes; };
593
- try {
594
- requireCredential(equalCredential(grant, originalGrant) && equalCredential(request.grant, keep(s.relay.grantDigest(reference))), "credential_binding");
595
- map = s.work.parse(originalGrant, "Grant", 65536);
596
- const artifact = s.maps[0], candidate = [...artifact.items("candidates")][s.candidateIndex], leg = artifact.field("server_leg", candidate, "Candidate");
597
- requireCredential(equalCredential(request.pairing, keep(map.bytes("pairing_id"))) && equalCredential(request.relayIdentity, keep(map.bytes("relay_identity_digest"))) &&
598
- equalCredential(request.leg, keep(artifact.bytes("leg_id", leg, "Leg"))) && request.notAfterMS > 0n && request.notAfterMS <= min(map.uint("not_after_ms"), s.sessionDeadline.cap), "credential_binding");
599
- // The accepted instruction can shorten this original preparation. Keep
600
- // that bound on the closure so every later HOP/admission check retains it.
601
- const allowed = s.preparationDeadline.fork(min(request.notAfterMS, s.preparationDeadline.cap));
602
- s.preparationDeadline.tightenFrom(allowed);
603
- }
604
- finally {
605
- originalGrant.fill(0);
606
- map?.close();
607
- for (const bytes of copied)
608
- bytes.fill(0);
609
- }
610
- }
611
- preparePoolServerAllow(recipient, reference) {
612
- this.checkPreparation(reference);
613
- const s = original(this), policy = s.config.tunnel;
614
- requireCredential(s.source === "preauthorized_pool" && s.pathKind === 1 && s.localRole === 0 && s.selectionSealed &&
615
- s.relay !== undefined && s.activation !== undefined && policy !== undefined && recipient.candidateIndex === s.candidateIndex, "credential_binding");
616
- requireCredential(recipient.recipient.length === 16 && recipient.recipient.some(value => value !== 0) && recipient.incarnation.length === 16 &&
617
- recipient.incarnation.some(value => value !== 0) && recipient.grant.length > 0 && recipient.grant.length <= 65536, "credential_binding");
618
- const owned = s.work.reserve("pool_server_allow", new ResourceVector([164864n + s.config.resources.runtimeBytes, 0n, 0n, 16n, 1n, 1n, 0n, 0n, 0n, 0n, 0n]));
619
- let relay, request;
620
- let preparation, relayBytes, clientGrant, serverCertificate;
621
- const retained = [], retain = (bytes) => { retained.push(bytes); return bytes; };
622
- let grant, closed = false;
623
- const clear = () => {
624
- if (closed)
625
- return;
626
- closed = true;
627
- relay?.close();
628
- grant?.fill(0);
629
- for (const value of retained)
630
- value.fill(0);
631
- owned.release();
632
- };
633
- try {
634
- preparation = new RelayCredentialPreparation(s.config.resources, s.config.namespaces);
635
- relayBytes = s.relay.certificate("relay", reference);
636
- clientGrant = s.relay.grant(reference);
637
- serverCertificate = s.maps[2].encoded();
638
- grant = new Uint8Array(recipient.grant);
639
- relay = verifyRelayCredentials({ ...s.config, audience: policy.audience, service: policy.service, endpointSubject: s.config.serverSubject, relaySubject: policy.relaySubject }, { grant, endpointCertificate: serverCertificate, relayCertificate: relayBytes }, preparation);
640
- requireCredential(relay.role === 1, "credential_binding");
641
- const artifact = s.maps[0], candidate = [...artifact.items("candidates")][s.candidateIndex];
642
- validateTunnelGrantProjection(s.config, s.work, artifact, candidate, s.activation, 1, s.evidence.slice(0, 3), s.artifactDigest, s.routeDigest, grant, relayBytes, relay);
643
- const server = s.work.parse(grant, "Grant", 65536);
644
- let client;
645
- try {
646
- client = s.work.parse(clientGrant, "Grant", 65536);
647
- for (const name of ["pairing_id", "service", "audience", "relay_identity_digest"]) {
648
- const a = server.encoded(server.field(name)), b = client.encoded(client.field(name));
649
- try {
650
- requireCredential(equalCredential(a, b), "credential_binding");
651
- }
652
- finally {
653
- a.fill(0);
654
- b.fill(0);
655
- }
656
- }
657
- const leg = artifact.field("server_leg", candidate, "Candidate");
658
- request = Object.freeze({ tenant: s.config.tenant, audience: s.config.audience, artifact: retain(new Uint8Array(s.artifactDigest)), grant: retain(relay.grantDigest(reference)),
659
- relayIdentity: retain(credentialDigest("certificate_digest", relayBytes)), attempt: retain(new Uint8Array(s.attemptID)), pairing: retain(server.bytes("pairing_id")), leg: retain(artifact.bytes("leg_id", leg, "Leg")),
660
- recipient: retain(new Uint8Array(recipient.recipient)), incarnation: retain(new Uint8Array(recipient.incarnation)), candidateIndex: s.candidateIndex,
661
- candidateID: retain(new Uint8Array(s.candidateID)), routeDigest: retain(new Uint8Array(s.routeDigest)), notAfterMS: min(server.uint("not_after_ms"), s.sessionDeadline.cap, s.preparationDeadline.cap) });
662
- }
663
- finally {
664
- server.close();
665
- client?.close();
666
- }
667
- const deadline = s.preparationDeadline.fork(request.notAfterMS);
668
- const check = () => { requireCredential(!closed, "credential_closed"); owned.check(); this.checkPreparation(reference); relay.check(reference); deadline.check(); };
669
- check();
670
- return Object.freeze({ request, grant, check, remainingMS: () => { check(); return deadline.remainingMS(); }, close: clear });
671
- }
672
- catch (error) {
673
- clear();
674
- throw error;
675
- }
676
- finally {
677
- preparation?.close();
678
- relayBytes?.fill(0);
679
- clientGrant?.fill(0);
680
- serverCertificate?.fill(0);
681
- }
682
- }
683
- poolSpendFacts(reference) {
684
- const state = original(this);
685
- this.checkPreparation(reference);
686
- requireCredential(state.source === "preauthorized_pool");
687
- const artifact = state.maps[0], activation = state.activation, once = state.once, selection = activation.field("candidate_selection");
688
- const candidates = [...artifact.items("candidates")], candidateIndex = candidates.findIndex(node => equalCredential(artifact.bytes("candidate_id", node, "Candidate"), state.candidateID));
689
- requireCredential(candidateIndex === state.candidateIndex, "credential_binding");
690
- const candidate = candidates[candidateIndex];
691
- state.selectionSealed = true;
692
- const fields = Object.freeze({ tenant: state.config.tenant, audience: state.config.audience, profile: state.profile,
693
- authority: once.text("spend_authority_id"), winnerAuthority: once.text("winner_authority_id"), signingKey: activation.text("signing_key_id"),
694
- namespace: artifact.text("revocation_authority_id"), namespaceGeneration: artifact.uint("revocation_authority_generation"), capacityDigest: artifact.bytes("namespace_capacity_digest"),
695
- issuer: artifact.bytes("issuer_key_id"), lease: artifact.bytes("lease_id"), attempt: new Uint8Array(state.attemptID),
696
- artifactDigest: new Uint8Array(state.artifactDigest), proofDigest: new Uint8Array(state.activationDigest), proof: activation.encoded(),
697
- candidateID: new Uint8Array(state.candidateID), candidateIndex: BigInt(candidateIndex), routeDigest: new Uint8Array(state.routeDigest), descriptor: artifact.encoded(artifact.field(state.pathKind === 0 ? "direct_leg" : "client_leg", candidate, "Candidate")),
698
- candidateSet: activation.bytes("candidate_set_digest", selection, "PoolSelectionRef"), routeSet: activation.bytes("route_selection"),
699
- sessionNonce: new Uint8Array(state.nonce), identities: Object.freeze(state.certificateDigests.map(value => new Uint8Array(value))),
700
- issuedAt: activation.uint("issued_at_ms"), activationEnd: state.initiation, sessionEnd: state.sessionEnd, initiationEnd: artifact.uint("initiation_not_after_ms") });
701
- return new VerifiedPoolSpendFacts(token, { closure: this, reference: state.reference.borrow(), fields, closed: false });
702
- }
703
- /** Authenticate the client request against the original locally negotiated
704
- * context before any server admission transaction or signed success. This
705
- * does not grant once authority or assert that the carrier has been checked. */
706
- authenticateClientAdmission(fsbBytes, transportContext, reference) {
707
- const s = original(this);
708
- requireCredential(!s.claimed && (s.activation !== undefined || s.source === "live_authority"), "credential_binding");
709
- this.checkPreparation(reference);
710
- let context, fsb;
711
- try {
712
- context = s.work.parse(transportContext, "TransportContext", 2048);
713
- const selected = context.uint("selected_features");
714
- requireCredential(context.text("crypto_profile_id") === s.profile && context.uint("path_kind") === BigInt(s.pathKind) &&
715
- (selected & ~s.allowed) === 0n && (selected & s.required) === s.required &&
716
- equalCredential(context.bytes("artifact_digest"), s.artifactDigest) && equalCredential(context.bytes("route_digest"), s.routeDigest) &&
717
- equalCredential(context.bytes("attempt_id"), s.attemptID) && equalCredential(context.bytes("session_nonce"), s.nonce));
718
- const artifact = s.maps[0], candidate = [...artifact.items("candidates")].find(n => equalCredential(artifact.bytes("candidate_id", n, "Candidate"), s.candidateID));
719
- requireCredential(context.uint("access_class") === artifact.uint("access_class", artifact.field(s.pathKind === 0 ? "direct_leg" : "server_leg", candidate, "Candidate"), "Leg"));
720
- fsb = s.work.parse(fsbBytes, "FSB4", 65536, 16384, { selectors: { activation_source_profile: s.source } });
721
- s.work.verify(fsb, s.identityKeys[0], { selectors: { activation_source_profile: s.source } });
722
- for (const name of ["tenant_id", "issuer_key_id", "lease_id", "session_nonce"])
723
- requireCredential(equalCredential(fsb.encoded(fsb.field(name)), artifact.encoded(artifact.field(name))));
724
- requireCredential(equalCredential(fsb.bytes("artifact_digest"), s.artifactDigest) && equalCredential(fsb.bytes("candidate_id"), s.candidateID) &&
725
- equalCredential(fsb.bytes("attempt_id"), s.attemptID) &&
726
- equalCredential(fsb.bytes("client_certificate"), s.maps[1].encoded()) && equalCredential(fsb.bytes("route_digest"), s.routeDigest) &&
727
- equalCredential(fsb.bytes("transport_context_digest"), s.work.digest(context, "transport_context_digest")) &&
728
- equalCredential(fsb.bytes("hello_transcript_digest"), context.bytes("hello_transcript_digest")) &&
729
- fsb.uint("selected_features") === selected && fsb.uint("binding_mode") === context.uint("binding_mode"));
730
- if (s.activation === undefined) {
731
- // Only this already authenticated client request can install the
732
- // authority's actual proof; ClientHello grants no consume authority.
733
- const proof = fsb.bytes("activation_authorization");
734
- try {
735
- this.installLiveAuthorization(proof, reference).fill(0);
736
- }
737
- finally {
738
- proof.fill(0);
739
- }
740
- }
741
- requireCredential(equalCredential(fsb.bytes("activation_authorization"), s.activation.encoded()), "credential_binding");
742
- this.checkPreparation(reference);
743
- return s.work.digest(fsb, "admission_binding");
744
- }
745
- finally {
746
- context?.close();
747
- fsb?.close();
748
- }
749
- }
750
- /** Derive server storage facts from the independently verified request. */
751
- serverAdmissionFields(fsb, context, reference) {
752
- const binding = this.authenticateClientAdmission(fsb, context, reference), s = original(this), artifact = s.maps[0], activation = s.activation;
753
- return Object.freeze({ source: s.source, tenant: s.config.tenant, audience: s.config.audience, profile: s.profile,
754
- spendAuthority: activation.text("authority_id"), signingKey: activation.text("signing_key_id"),
755
- winnerAuthority: s.source === "preauthorized_pool" ? s.once.text("winner_authority_id") : "",
756
- issuer: artifact.bytes("issuer_key_id"), lease: artifact.bytes("lease_id"), attempt: new Uint8Array(s.attemptID),
757
- artifactDigest: new Uint8Array(s.artifactDigest), proofDigest: new Uint8Array(s.activationDigest), candidateID: new Uint8Array(s.candidateID),
758
- candidateSet: s.source === "preauthorized_pool" ? activation.bytes("candidate_set_digest", activation.field("candidate_selection"), "PoolSelectionRef") : new Uint8Array(),
759
- routeDigest: new Uint8Array(s.routeDigest), sessionNonce: new Uint8Array(s.nonce), identities: s.certificateDigests.map(value => new Uint8Array(value)),
760
- admissionBinding: binding, issuedAt: activation.uint("issued_at_ms"), activationEnd: activation.uint("activation_not_after_ms"), sessionEnd: activation.uint("session_not_after_ms"), initiationEnd: artifact.uint("initiation_not_after_ms") });
761
- }
762
- /** Bind the real authenticated FSB/FSA and Noise inputs before their first
763
- * credential-bearing handshake output. Actual once/provider gates remain
764
- * the admission owner's responsibility, not a boolean supplied here. */
765
- checkSessionInputs(config, transportContext) {
766
- const s = original(this);
767
- requireCredential(!s.claimed && s.activation !== undefined, "credential_binding");
768
- this.checkPreparation(config.reservations.session);
769
- requireCredential(config.noise.clock === s.config.clock && config.noise.profile === s.profile && config.ledger.profile === s.profile);
770
- requireCredential(config.noise.authorizationDeadline.belongsTo(s.config.clock) && config.noise.preparationDeadline.belongsTo(s.config.clock) &&
771
- config.noise.authorizationDeadline.cap <= s.sessionEnd && config.noise.preparationDeadline.cap <= s.initiation);
772
- const role = config.noise.role === "client" ? 0 : 1, peer = 1 - role;
773
- requireCredential(equalCredential(config.noise.psk, s.psk) && equalCredential(config.noise.localStaticPublic, s.noiseKeys[role]) &&
774
- equalCredential(config.noise.peerStaticPublic, s.noiseKeys[peer]) && equalCredential(config.signer.publicKey, s.identityKeys[role]) && equalCredential(config.peerReadyPublicKey, s.identityKeys[peer]));
775
- const privateKey = config.noise.localStaticPrivate;
776
- const actualPublic = ownProfile(s.profile).dh_algorithm === 0 ? x25519.getPublicKey(privateKey) : p256.getPublicKey(privateKey, false);
777
- try {
778
- requireCredential(equalCredential(actualPublic, s.noiseKeys[role]));
779
- }
780
- finally {
781
- actualPublic.fill(0);
782
- }
783
- const selected = BigInt(config.ready.selectedFeatures);
784
- requireCredential((selected & ~s.allowed) === 0n && (selected & s.required) === s.required && selected === config.info.selected_features);
785
- requireCredential(BigInt(config.maxFrame) === s.maxFrame && BigInt(config.streams.limits.maxActive) <= s.maxStreams && (config.idleDurationMS ?? 0n) === s.idleDurationMS &&
786
- config.streams.receive.receiveLimit <= s.maxCredit && config.streams.rekeyBurst === s.rekeyBurst && config.streams.rekeyRefillMS === s.rekeyRefill);
787
- requireCredential(config.info.application_profile === ["transport", "services", "execution"][Number(s.applicationProfile)] &&
788
- BigInt(config.streams.rpcMaxGeneralOutstanding ?? 0) === s.rpcMaxGeneralOutstanding);
789
- requireCredential(s.applicationProfile === 0n || s.maxStreams >= 1n && s.maxCredit >= 16384n);
790
- let context, fsa;
791
- try {
792
- const admission = this.authenticateClientAdmission(config.noise.fsb, transportContext, config.reservations.session);
793
- context = s.work.parse(transportContext, "TransportContext", 2048);
794
- requireCredential(context.uint("selected_features") === selected);
795
- const contextDigest = s.work.digest(context, "transport_context_digest");
796
- requireCredential(equalCredential(contextDigest, config.noise.contextDigest) && equalCredential(contextDigest, config.ready.transportContextDigest));
797
- fsa = s.work.parse(config.noise.fsa, "FSA4", 16384);
798
- s.work.verify(fsa, s.identityKeys[1]);
799
- requireCredential(equalCredential(fsa.bytes("server_certificate"), s.maps[2].encoded()) &&
800
- equalCredential(fsa.bytes("route_digest"), s.routeDigest) && equalCredential(fsa.bytes("transport_context_digest"), contextDigest) &&
801
- equalCredential(fsa.bytes("hello_transcript_digest"), context.bytes("hello_transcript_digest")) &&
802
- fsa.uint("selected_features") === selected && fsa.uint("binding_mode") === context.uint("binding_mode"));
803
- requireCredential(fsa.uint("status") === 0n && fsa.uint("code") === 0n &&
804
- equalCredential(fsa.bytes("client_identity_digest"), s.certificateDigests[0]) && equalCredential(fsa.bytes("server_identity_digest"), s.certificateDigests[1]));
805
- const fsbDigest = credentialDigest("fsb_digest", config.noise.fsb), fsaDigest = s.work.digest(fsa, "fsa_digest");
806
- requireCredential(equalCredential(fsbDigest, config.ready.fsbDigest) && equalCredential(fsaDigest, config.ready.fsaDigest) &&
807
- equalCredential(admission, config.ready.admissionBinding) && equalCredential(admission, fsa.bytes("admission_binding")) &&
808
- equalCredential(config.ready.localCertificateDigest, s.certificateDigests[role]) && equalCredential(config.ready.peerCertificateDigest, s.certificateDigests[peer]));
809
- this.checkPreparation(config.reservations.session);
810
- }
811
- finally {
812
- context?.close();
813
- fsa?.close();
814
- }
815
- }
816
- claimSession(config, transportContext) {
817
- this.checkSessionInputs(config, transportContext);
818
- const s = original(this);
819
- const deadline = new TrustedDeadline(s.config.clock, s.sessionEnd), retained = s.reference.borrow();
820
- s.claimed = true;
821
- return new CredentialSessionBinding(token, this, retained, deadline);
822
- }
823
- availableUntil() {
824
- const s = original(this);
825
- this.#check(s, s.reference);
826
- return min(s.sessionEnd, ...Array.from(s.freshness.values(), w => w.deadline.cap));
827
- }
828
- checkpointPolicy(reference) { this.checkOriginal(reference); return original(this).resumePolicy; }
829
- checkOriginal(reference) { const s = original(this); requireCredential(s.claimed); this.#check(s, reference); }
830
- applicationContext(role, reference) {
831
- this.checkOriginal(reference);
832
- return this.#applicationContext(role);
833
- }
834
- /** Internal pre-CAS projection. The exchange must authenticate the original
835
- * FSB and transport context before requesting this view. */
836
- serverRequestContext(fsb, context, reference) {
837
- const binding = this.authenticateClientAdmission(fsb, context, reference);
838
- binding.fill(0);
839
- return this.#applicationContext("server");
840
- }
841
- #applicationContext(role) {
842
- const state = original(this), client = role === "client";
843
- return Object.freeze({ tenant: state.config.tenant, audience: state.config.audience, localRole: role,
844
- localSubject: client ? state.config.clientSubject : state.config.serverSubject,
845
- peerSubject: client ? state.config.serverSubject : state.config.clientSubject,
846
- peerIdentityDigest: Array.from(state.certificateDigests[client ? 1 : 0], n => n.toString(16).padStart(2, "0")).join("") });
847
- }
848
- tunnelCredentials(reference) {
849
- this.checkPreparation(reference);
850
- const owner = original(this).relay;
851
- requireCredential(owner !== undefined, "credential_binding");
852
- return owner;
853
- }
854
- takeTunnelHopPreparation(reference) {
855
- this.checkPreparation(reference);
856
- const s = original(this);
857
- requireCredential(s.pathKind === 1);
858
- const result = s.hop;
859
- s.hop = undefined;
860
- s.selectionSealed = true;
861
- const owner = s.tunnelCandidates.get(s.candidateIndex);
862
- if (owner !== undefined)
863
- owner.hop = undefined;
864
- return result;
865
- }
866
- /** Original signed activation selection for authority issuance and the
867
- * shared ParentWinner. Local Grant/certificate deadlines still constrain
868
- * the closure, but cannot change this immutable parent authorization. */
869
- parentSelectionFields(reference) {
870
- this.checkPreparation(reference);
871
- const s = original(this), artifact = s.maps[0], activation = s.activation;
872
- requireCredential(activation !== undefined);
873
- return Object.freeze({ source: s.source, tenant: s.config.tenant, audience: s.config.audience, profile: s.profile,
874
- spendAuthority: activation.text("authority_id"), signingKey: activation.text("signing_key_id"), winnerAuthority: s.source === "preauthorized_pool" ? s.once.text("winner_authority_id") : "",
875
- issuer: artifact.bytes("issuer_key_id"), lease: artifact.bytes("lease_id"), attempt: new Uint8Array(s.attemptID), artifactDigest: new Uint8Array(s.artifactDigest), proofDigest: new Uint8Array(s.activationDigest),
876
- candidateID: new Uint8Array(s.candidateID), candidateSet: s.source === "preauthorized_pool" ? activation.bytes("candidate_set_digest", activation.field("candidate_selection"), "PoolSelectionRef") : new Uint8Array(),
877
- routeDigest: new Uint8Array(s.routeDigest), sessionNonce: new Uint8Array(s.nonce), identities: s.certificateDigests.map(value => new Uint8Array(value)),
878
- issuedAt: activation.uint("issued_at_ms"), activationEnd: activation.uint("activation_not_after_ms"), sessionEnd: activation.uint("session_not_after_ms"), initiationEnd: artifact.uint("initiation_not_after_ms") });
879
- }
880
- /** Drop handshake-only arenas and secrets while keeping the same original
881
- * evidence, namespace subscriptions and authorization deadlines. */
882
- detachSessionIO() {
883
- const s = original(this);
884
- requireCredential(s.claimed);
885
- if (s.detached)
886
- return;
887
- s.detached = true;
888
- for (const map of s.maps)
889
- map.close();
890
- s.maps.length = 0;
891
- s.activation = s.once = undefined;
892
- s.work?.close();
893
- s.work = undefined;
894
- for (const bytes of [s.candidateID, s.routeDigest, s.artifactDigest, s.activationDigest, s.attemptID, s.psk, s.nonce, ...s.noiseKeys, ...s.identityKeys])
895
- bytes.fill(0);
896
- }
897
- close() {
898
- const s = closures.get(this);
899
- if (s === undefined || s.closed)
900
- return;
901
- s.closed = true;
902
- s.liveTunnel?.decoder.close();
903
- s.liveTunnel?.preparation.close();
904
- s.liveTunnel?.relayCertificate.fill(0);
905
- s.liveTunnel?.endpointCertificate.fill(0);
906
- s.liveTunnel = undefined;
907
- s.relay?.close();
908
- s.relay = undefined;
909
- s.hop?.close();
910
- s.hop = undefined;
911
- for (const owner of s.tunnelCandidates.values()) {
912
- owner.relay.close();
913
- owner.hop?.close();
914
- }
915
- s.tunnelCandidates.clear();
916
- s.revoked = s.changed = undefined;
917
- for (const subscription of s.subscriptions)
918
- subscription.close();
919
- s.subscriptions.length = 0;
920
- s.freshness.clear();
921
- for (const map of s.maps)
922
- map.close();
923
- s.maps.length = 0;
924
- s.activation = s.once = undefined;
925
- for (const bytes of [s.candidateID, s.routeDigest, s.artifactDigest, s.activationDigest, ...s.certificateDigests, s.attemptID, s.psk, s.nonce, ...s.noiseKeys, ...s.identityKeys])
926
- bytes.fill(0);
927
- for (const e of s.evidence)
928
- clearCredentialEvidence(e);
929
- s.config.tunnel?.liveGrant?.issuerKeyID.fill(0);
930
- s.work?.close();
931
- s.work = undefined;
932
- s.reference.release();
933
- }
934
- toJSON() { return {}; }
935
- toString() { return "Flowersec.VerifiedCredentialClosure"; }
936
- }
937
- export class CredentialSessionBinding {
938
- closure;
939
- deadline;
940
- #reference;
941
- #deliveryReferences = 0;
942
- #closed = false;
943
- #deliveryRevoked;
944
- constructor(capability, closure, reference, deadline) {
945
- this.closure = closure;
946
- this.deadline = deadline;
947
- requireCredential(capability === token);
948
- this.#reference = reference;
949
- Object.freeze(this);
950
- }
951
- check() { requireCredential(this.#reference !== undefined, "credential_closed"); this.closure.checkOriginal(this.#reference); this.deadline.check(); }
952
- checkpointPolicy(selected) {
953
- this.check();
954
- return (selected & applicationResumeFeature()) === 0n ? undefined : this.closure.checkpointPolicy(this.#reference);
955
- }
956
- applicationContext(role) {
957
- this.check();
958
- return this.closure.applicationContext(role, this.#reference);
959
- }
960
- onRevoked(callback, deliveryRevoked) {
961
- const s = original(this.closure);
962
- requireCredential(s.revoked === undefined);
963
- this.#deliveryRevoked = deliveryRevoked;
964
- s.revoked = () => { deliveryRevoked?.(); callback(); };
965
- if (s.denied !== undefined)
966
- notifyCallback(s.revoked);
967
- }
968
- /** Delivery retains the original authorization without retaining transport
969
- * keys or using a fresh credential/namespace subscription. */
970
- retainDelivery() {
971
- this.check();
972
- const state = original(this.closure), reference = state.reference.borrow();
973
- this.#deliveryReferences++;
974
- let active = true;
975
- return Object.freeze({ check: () => {
976
- requireCredential(active, "credential_closed");
977
- this.closure.checkOriginal(reference);
978
- this.deadline.check();
979
- }, observe: changed => {
980
- requireCredential(active && state.changed === undefined, "credential_binding");
981
- state.changed = changed;
982
- return () => { if (state.changed === changed)
983
- state.changed = undefined; };
984
- }, remainingMS: () => {
985
- requireCredential(active, "credential_closed");
986
- this.closure.checkOriginal(reference);
987
- return min(this.deadline.remainingMS(), ...Array.from(state.freshness.values(), w => w.deadline.remainingMS()));
988
- }, release: () => {
989
- if (!active)
990
- return;
991
- active = false;
992
- reference.release();
993
- this.#deliveryReferences--;
994
- if (this.#closed && this.#deliveryReferences === 0) {
995
- this.#deliveryRevoked = undefined;
996
- this.closure.close();
997
- }
998
- } });
999
- }
1000
- remainingMS() {
1001
- this.check();
1002
- const s = original(this.closure);
1003
- return min(this.deadline.remainingMS(), ...Array.from(s.freshness.values(), w => w.deadline.remainingMS()));
1004
- }
1005
- close() {
1006
- if (this.#closed)
1007
- return;
1008
- this.#closed = true;
1009
- const state = closures.get(this.closure);
1010
- if (state !== undefined && !state.closed) {
1011
- state.revoked = this.#deliveryRevoked;
1012
- this.closure.detachSessionIO();
1013
- }
1014
- this.#reference?.release();
1015
- this.#reference = undefined;
1016
- if (this.#deliveryReferences === 0) {
1017
- this.#deliveryRevoked = undefined;
1018
- this.closure.close();
1019
- }
1020
- }
1021
- }
1022
- /** One bounded verification job; input bytes are copied into canonical arenas
1023
- * before return. Source profile is fixed before interpretation and never falls
1024
- * back between pool and live. Only the original selected candidate is admitted. */
1025
- export function verifyDirectCredentials(config, input, reservation, subscriptions, prepared) {
1026
- const captured = Object.freeze({ ...config, ...(config.tunnel === undefined ? {} : { tunnel: Object.freeze({ ...config.tunnel, ...(config.tunnel.liveGrant === undefined ? {} : { liveGrant: Object.freeze({ ...config.tunnel.liveGrant, issuerKeyID: new Uint8Array(config.tunnel.liveGrant.issuerKeyID) }) }) }) }), namespaces: Object.freeze([...config.namespaces]), cryptoProfiles: Object.freeze([...config.cryptoProfiles]) });
1027
- requireCredential(captured.namespaces.length > 0 && captured.namespaces.length <= 8 && captured.cryptoProfiles.length > 0 && captured.cryptoProfiles.every(p => ownProfile(p) !== undefined), "configuration_capacity");
1028
- requireCredential(input.source === "live_authority" || input.source === "preauthorized_pool", "credential_invalid");
1029
- requireCredential(Number.isSafeInteger(input.candidateIndex) && input.candidateIndex >= 0 && input.candidateIndex < 16, "credential_invalid");
1030
- const reference = reservation.take(credentialVerifierCharge(config.resources.runtimeBytes));
1031
- let liveTunnel, relay, hop, work, result;
1032
- const tunnelCandidates = new Map();
1033
- const maps = [];
1034
- const acquiredEvidence = [], acquiredKeys = [];
1035
- try {
1036
- if (prepared !== undefined)
1037
- work = prepared.takeWork(reference);
1038
- else {
1039
- const workRef = config.resources.root.reserve({ owner: credentialOwner(config.resources, "verification_work"), accounts: config.resources.accounts, charge: credentialWorkCharge(270336, config.resources.runtimeBytes) });
1040
- try {
1041
- requireCredential(reference.sameEnvironment(workRef));
1042
- work = new CredentialWork(config.resources, 270336, workRef);
1043
- }
1044
- finally {
1045
- workRef.release();
1046
- }
1047
- }
1048
- for (const n of captured.namespaces) {
1049
- requireCredential(isCredentialNamespace(n) && n.clock === config.clock);
1050
- n.check(reference);
1051
- }
1052
- const artifact = work.parse(input.artifact, "Artifact", 65536);
1053
- maps.push(artifact);
1054
- const profile = artifact.text("crypto_profile_id");
1055
- requireCredential(captured.cryptoProfiles.includes(profile) && artifact.text("tenant_id") === captured.tenant && artifact.text("audience") === captured.audience, "credential_untrusted");
1056
- const resolve = (map) => {
1057
- const matches = captured.namespaces.filter(n => n.matches(map));
1058
- requireCredential(matches.length === 1, "credential_untrusted");
1059
- return matches[0];
1060
- };
1061
- const parentNamespace = resolve(artifact), parent = parentNamespace.verifyCredential(artifact, 1, work);
1062
- acquiredEvidence.push(parent);
1063
- checkCredentialTime(config.clock, artifact.uint("issued_at_ms"), artifact.uint("initiation_not_after_ms"));
1064
- const clients = [], noiseKeys = [], identityKeys = [];
1065
- for (const [role, bytes] of [input.clientCertificate, input.serverCertificate].entries()) {
1066
- const certificate = work.parse(bytes, "IdentityCertificate", 8192);
1067
- maps.push(certificate);
1068
- requireCredential(certificate.text("tenant_id") === captured.tenant && certificate.text("audience") === captured.audience && certificate.text("crypto_profile_id") === profile &&
1069
- certificate.text("subject_id") === (role === 0 ? captured.clientSubject : captured.serverSubject) && certificate.uint("role") === BigInt(role), "credential_untrusted");
1070
- checkCredentialTime(config.clock, certificate.uint("issued_at_ms"), certificate.uint("expires_at_ms"));
1071
- const evidence = resolve(certificate).verifyCredential(certificate, 0, work);
1072
- acquiredEvidence.push(evidence);
1073
- requireCredential(equalCredential(evidence.digest, artifact.bytes(role === 0 ? "client_identity_digest" : "server_identity_digest")));
1074
- const parentPolicy = parent.namespace.policyRequirements(parent), childPolicy = evidence.namespace.policyRequirements(evidence);
1075
- requireCredential(parentPolicy.staleness <= childPolicy.staleness && parentPolicy.signerLifetime <= childPolicy.signerLifetime, "credential_untrusted");
1076
- clients.push(evidence);
1077
- const noise = certificate.field("noise_static_public_key"), noiseKey = certificate.bytes("public_key_bytes", noise, "NoiseStaticPublicKey"), identity = certificate.bytes("ed25519_public_key");
1078
- acquiredKeys.push(noiseKey, identity);
1079
- validateIdentityKey(profile, certificate.uint("algorithm", noise, "NoiseStaticPublicKey"), noiseKey, identity);
1080
- noiseKeys.push(noiseKey);
1081
- identityKeys.push(identity);
1082
- }
1083
- const candidates = [...artifact.items("candidates")], candidate = candidates[input.candidateIndex];
1084
- requireCredential(candidate !== undefined);
1085
- const pathKind = Number(artifact.uint("path_kind", candidate, "Candidate")), localRole = captured.tunnel?.role ?? 0;
1086
- requireCredential(pathKind === 0 ? input.tunnel === undefined && captured.tunnel === undefined : pathKind === 1 && input.tunnel !== undefined && captured.tunnel !== undefined, "credential_untrusted");
1087
- const candidateID = artifact.bytes("candidate_id", candidate, "Candidate"), routeDigest = candidateRouteDigest(artifact, candidate);
1088
- if (pathKind === 0)
1089
- checkClosure(artifact, candidate, [parent.namespace, clients[0].namespace, clients[1].namespace]);
1090
- const artifactDigest = work.digest(artifact, "artifact_digest");
1091
- const onceBytes = parentNamespace.onceAuthority(parent.issuer), once = work.parse(onceBytes, "OnceAuthorityRef", 412);
1092
- maps.push(once);
1093
- onceBytes.fill(0);
1094
- const pendingLive = input.source === "live_authority" && (input.activation === undefined || input.activation.length === 0);
1095
- let activation, activationEvidence;
1096
- let issued = artifact.uint("issued_at_ms"), initiation = artifact.uint("initiation_not_after_ms"), sessionEnd = artifact.uint("session_not_after_ms");
1097
- if (!pendingLive) {
1098
- requireCredential(input.activation !== undefined, "credential_invalid");
1099
- activation = work.parse(input.activation, "ActivationAuthorization", 4096, 16384, { selectors: { activation_source_profile: input.source } });
1100
- maps.push(activation);
1101
- const verified = validateActivation(config, work, artifact, activation, parent, once, input.source, input.candidateIndex, artifactDigest, candidateID, routeDigest);
1102
- issued = verified.issued;
1103
- initiation = verified.initiation;
1104
- sessionEnd = verified.sessionEnd;
1105
- activationEvidence = verified.evidence;
1106
- acquiredEvidence.push(activationEvidence);
1107
- }
1108
- let scopeEvidence, relayEvidence;
1109
- if (pathKind === 1 && pendingLive) {
1110
- const policy = captured.tunnel, scope = policy.liveGrant, bytes = input.tunnel;
1111
- requireCredential(scope !== undefined && (bytes.grant === undefined || bytes.grant.length === 0) && (bytes.candidateGrants === undefined || bytes.candidateGrants.length === 0), "credential_untrusted");
1112
- const scopeNamespace = captured.namespaces.find(namespace => namespace.authority === scope.authority);
1113
- requireCredential(scopeNamespace !== undefined, "credential_untrusted");
1114
- const authorized = scopeNamespace.preauthorizeGrantScope(artifact, localRole, policy.audience, policy.service, scope.issuerKeyID, scope.revocationPolicyID, scope.revocationPolicyRevision, min(scope.maxNotAfterMS, sessionEnd), work);
1115
- scopeEvidence = authorized.evidence;
1116
- acquiredEvidence.push(scopeEvidence);
1117
- initiation = min(initiation, authorized.preparationEnd);
1118
- const relayMap = work.parse(bytes.relayCertificate, "IdentityCertificate", 8192);
1119
- try {
1120
- requireCredential(relayMap.text("tenant_id") === captured.tenant && relayMap.text("audience") === policy.audience && relayMap.text("subject_id") === policy.relaySubject && relayMap.text("crypto_profile_id") === profile && relayMap.uint("role") === 2n, "credential_untrusted");
1121
- const ns = captured.namespaces.find(value => value.matches(relayMap));
1122
- requireCredential(ns !== undefined, "credential_untrusted");
1123
- checkCredentialTime(config.clock, relayMap.uint("issued_at_ms"), relayMap.uint("expires_at_ms"));
1124
- relayEvidence = ns.verifyCredential(relayMap, 0, work);
1125
- acquiredEvidence.push(relayEvidence);
1126
- const key = relayMap.bytes("ed25519_public_key");
1127
- try {
1128
- const point = ed25519.Point.fromBytes(key, false);
1129
- requireCredential(!point.is0() && point.isTorsionFree() && equalCredential(point.toBytes(), key));
1130
- }
1131
- finally {
1132
- key.fill(0);
1133
- }
1134
- const baseline = parent.namespace.policyRequirements(parent);
1135
- for (const child of [scopeEvidence, relayEvidence]) {
1136
- const p = child.namespace.policyRequirements(child);
1137
- requireCredential(baseline.staleness <= p.staleness && baseline.signerLifetime <= p.signerLifetime);
1138
- }
1139
- checkTunnelClosure(artifact, candidate, localRole, [parent.namespace, clients[0].namespace, clients[1].namespace], scopeNamespace, undefined, bytes.relayCertificate, work, captured.namespaces);
1140
- }
1141
- finally {
1142
- relayMap.close();
1143
- }
1144
- const preparation = prepared?.takeRelay() ?? new RelayCredentialPreparation(captured.resources, captured.namespaces);
1145
- let decoder;
1146
- try {
1147
- if (prepared !== undefined)
1148
- decoder = prepared.takeLiveDecoder();
1149
- else {
1150
- const ref = captured.resources.root.reserve({ owner: credentialOwner(captured.resources, "live_tunnel_response"), accounts: captured.resources.accounts, charge: cborDecoderCharge(liveMaterialDecoderConfig(captured.resources.runtimeBytes)) });
1151
- try {
1152
- decoder = new CBORDecoder(liveMaterialDecoderConfig(captured.resources.runtimeBytes), ref);
1153
- }
1154
- finally {
1155
- ref.release();
1156
- }
1157
- }
1158
- liveTunnel = { scope: scopeEvidence, relayCertificate: new Uint8Array(bytes.relayCertificate), endpointCertificate: new Uint8Array(localRole === 0 ? input.clientCertificate : input.serverCertificate), preparation, decoder };
1159
- }
1160
- catch (error) {
1161
- preparation.close();
1162
- decoder?.close();
1163
- throw error;
1164
- }
1165
- }
1166
- if (pathKind === 1 && !pendingLive) {
1167
- const policy = captured.tunnel, bytes = input.tunnel, capacity = policy.candidateCapacity ?? 1;
1168
- requireCredential(Number.isSafeInteger(capacity) && capacity >= 1 && capacity <= 16 && bytes.grant instanceof Uint8Array && bytes.grant.length > 0 && bytes.grant.length <= 65536 &&
1169
- (bytes.candidateGrants === undefined || Array.isArray(bytes.candidateGrants) && bytes.candidateGrants.length < capacity) && (input.source === "preauthorized_pool" || (bytes.candidateGrants?.length ?? 0) === 0), "credential_invalid");
1170
- const supplied = [{ candidateIndex: input.candidateIndex, grant: bytes.grant, relayCertificate: bytes.relayCertificate }, ...(bytes.candidateGrants ?? [])];
1171
- const authorized = checkSelection({ source: input.source, candidateIndex: input.candidateIndex }, artifact, activation, artifactDigest, candidateID, routeDigest, once), seen = new Set();
1172
- for (const suppliedCandidate of supplied) {
1173
- const index = suppliedCandidate.candidateIndex, node = candidates[index];
1174
- requireCredential(Number.isSafeInteger(index) && index >= 0 && index < 16 && !seen.has(index) && authorized.includes(index) && node !== undefined && artifact.uint("path_kind", node, "Candidate") === 1n &&
1175
- suppliedCandidate.grant instanceof Uint8Array && suppliedCandidate.grant.length > 0 && suppliedCandidate.grant.length <= 65536 && suppliedCandidate.relayCertificate instanceof Uint8Array && suppliedCandidate.relayCertificate.length > 0 && suppliedCandidate.relayCertificate.length <= 8192, "credential_binding");
1176
- seen.add(index);
1177
- const relayReference = prepared?.takeRelay() ?? new RelayCredentialPreparation(captured.resources, captured.namespaces);
1178
- let candidateRelay, candidateHop;
1179
- const digest = candidateRouteDigest(artifact, node);
1180
- try {
1181
- candidateRelay = verifyRelayCredentials({ ...captured, audience: policy.audience, service: policy.service, endpointSubject: localRole === 0 ? captured.clientSubject : captured.serverSubject, relaySubject: policy.relaySubject }, { grant: suppliedCandidate.grant, endpointCertificate: localRole === 0 ? input.clientCertificate : input.serverCertificate, relayCertificate: suppliedCandidate.relayCertificate }, relayReference);
1182
- requireCredential(candidateRelay.role === localRole, "credential_binding");
1183
- validateTunnelGrantProjection(captured, work, artifact, node, activation, localRole, [parent, ...clients], artifactDigest, digest, suppliedCandidate.grant, suppliedCandidate.relayCertificate, candidateRelay);
1184
- candidateHop = prepared?.takeHop() ?? new HopAuthenticationPreparation(captured.resources);
1185
- tunnelCandidates.set(index, { relay: candidateRelay, hop: candidateHop });
1186
- candidateRelay = undefined;
1187
- candidateHop = undefined;
1188
- }
1189
- finally {
1190
- digest.fill(0);
1191
- relayReference.close();
1192
- candidateRelay?.close();
1193
- candidateHop?.close();
1194
- }
1195
- }
1196
- relay = tunnelCandidates.get(input.candidateIndex).relay;
1197
- hop = tunnelCandidates.get(input.candidateIndex).hop;
1198
- }
1199
- const contract = artifact.field("session_contract"), rekey = artifact.field("rekey_envelope", contract, "SessionContract");
1200
- const state = {
1201
- config: captured, liveTunnel, tunnelCandidates, selectionSealed: false, handshakeChecksPrepared: prepared !== undefined, relay, hop: hop = pathKind === 1 && pendingLive ? prepared?.takeHop() : hop, pathKind, localRole, reference, work, maps, activation, once, candidateIndex: input.candidateIndex, evidence: [parent, ...clients, ...(scopeEvidence === undefined ? [] : [scopeEvidence]), ...(relayEvidence === undefined ? [] : [relayEvidence]), ...(activationEvidence === undefined ? [] : [activationEvidence])],
1202
- profile, source: input.source, candidateID, routeDigest, artifactDigest, activationDigest: activation === undefined ? new Uint8Array(32) : work.digest(activation, "activation_digest"),
1203
- certificateDigests: clients.map(c => new Uint8Array(c.digest)), attemptID: activation?.bytes("attempt_id") ?? new Uint8Array(16), psk: artifact.bytes("e2ee_psk"), nonce: artifact.bytes("session_nonce"),
1204
- noiseKeys, identityKeys, from: max(artifact.uint("issued_at_ms"), issued, maps[1].uint("issued_at_ms"), maps[2].uint("issued_at_ms")),
1205
- preparationDeadline: new TrustedDeadline(config.clock, initiation), sessionDeadline: new TrustedDeadline(config.clock, min(sessionEnd, clients[0].expires, clients[1].expires)),
1206
- resumePolicy: artifact.doc.boolean(artifact.field("enabled", artifact.field("resume_policy"), "ResumePolicy")) ? Object.freeze({
1207
- maxIssuedTokenDurationMS: artifact.uint("max_issued_token_duration_ms", artifact.field("resume_policy"), "ResumePolicy"),
1208
- maxTokenBytes: Number(artifact.uint("max_token_bytes", artifact.field("resume_policy"), "ResumePolicy"))
1209
- }) : undefined,
1210
- initiation, sessionEnd: min(sessionEnd, clients[0].expires, clients[1].expires), allowed: artifact.uint("allowed_features"), required: artifact.uint("required_features"),
1211
- maxFrame: artifact.uint("max_frame", contract, "SessionContract"), maxStreams: artifact.uint("max_streams", contract, "SessionContract"),
1212
- idleDurationMS: artifact.uint("idle_duration_ms", contract, "SessionContract"),
1213
- maxCredit: artifact.uint("max_credit", contract, "SessionContract"), applicationProfile: artifact.uint("application_profile", contract, "SessionContract"),
1214
- rpcMaxGeneralOutstanding: artifact.optional("rpc_max_general_outstanding", contract, "SessionContract") < 0 ? 0n : artifact.uint("rpc_max_general_outstanding", contract, "SessionContract"),
1215
- rekeyBurst: artifact.uint("burst_rounds", rekey, "RekeyEnvelope"), rekeyRefill: artifact.uint("refill_period_ms", rekey, "RekeyEnvelope"), subscriptions: [], freshness: new Map(), denied: undefined, revoked: undefined, changed: undefined, claimed: false, detached: false, closed: false,
1216
- };
1217
- result = new VerifiedCredentialClosure(token, state);
1218
- for (const [index, owner] of tunnelCandidates)
1219
- owner.relay.onRevoked(error => { if (state.closed || state.denied !== undefined || state.candidateIndex !== index)
1220
- return; state.denied = error; notifyCallback(state.revoked); });
1221
- if (tunnelCandidates.size === 0)
1222
- relay?.onRevoked(error => { if (state.closed || state.denied !== undefined)
1223
- return; state.denied = error; notifyCallback(state.revoked); });
1224
- result.checkPreparation(reference);
1225
- result.attachNamespaces(token, subscriptions);
1226
- return result;
1227
- }
1228
- catch (error) {
1229
- if (result !== undefined)
1230
- result.close();
1231
- else {
1232
- liveTunnel?.decoder.close();
1233
- liveTunnel?.preparation.close();
1234
- liveTunnel?.relayCertificate.fill(0);
1235
- liveTunnel?.endpointCertificate.fill(0);
1236
- hop?.close();
1237
- relay?.close();
1238
- for (const owner of tunnelCandidates.values()) {
1239
- owner.hop?.close();
1240
- owner.relay.close();
1241
- }
1242
- tunnelCandidates.clear();
1243
- for (const e of acquiredEvidence)
1244
- clearCredentialEvidence(e);
1245
- for (const key of acquiredKeys)
1246
- key.fill(0);
1247
- captured.tunnel?.liveGrant?.issuerKeyID.fill(0);
1248
- for (const map of maps)
1249
- map.close();
1250
- work?.close();
1251
- reference.release();
1252
- }
1253
- for (const subscription of subscriptions?.values() ?? [])
1254
- subscription.close();
1255
- subscriptions?.clear();
1256
- throw error;
1257
- }
1258
- }
1259
- export function validateActivation(config, work, artifact, activation, parent, once, source, candidateIndex, artifactDigest, candidateID, routeDigest) {
1260
- return validateActivationProjection(config, work, artifact, activation, parent, once, source, candidateIndex, artifactDigest, candidateID, routeDigest);
1261
- }
1262
- /** Authority-only unsigned preparation. Evidence remains a signing permission;
1263
- * the ordinary credential verifier always verifies the actual signature. */
1264
- export function validateActivationIssuance(config, work, artifact, activation, parent, once, candidateIndex, artifactDigest, candidateID, routeDigest, signingKey) {
1265
- return validateActivationProjection(config, work, artifact, activation, parent, once, "live_authority", candidateIndex, artifactDigest, candidateID, routeDigest, signingKey);
1266
- }
1267
- function validateActivationProjection(config, work, artifact, activation, parent, once, source, candidateIndex, artifactDigest, candidateID, routeDigest, signingKey) {
1268
- for (const [a, b] of [["tenant_id", "tenant_id"], ["artifact_issuer_key_id", "issuer_key_id"], ["lease_id", "lease_id"], ["audience", "audience"],
1269
- ["client_identity_digest", "client_identity_digest"], ["server_identity_digest", "server_identity_digest"]]) {
1270
- requireCredential(equalCredential(activation.encoded(activation.field(a)), artifact.encoded(artifact.field(b))));
1271
- }
1272
- requireCredential(equalCredential(activation.bytes("artifact_digest"), artifactDigest));
1273
- const issued = activation.uint("issued_at_ms"), initiation = activation.uint("activation_not_after_ms"), sessionEnd = activation.uint("session_not_after_ms");
1274
- checkCredentialTime(config.clock, issued, initiation);
1275
- requireCredential(issued >= artifact.uint("issued_at_ms") && initiation <= artifact.uint("initiation_not_after_ms") && sessionEnd <= artifact.uint("session_not_after_ms"));
1276
- requireCredential(activation.text("authority_id") === once.text("spend_authority_id"));
1277
- const evidence = signingKey === undefined ? parent.namespace.verifyActivation(activation, parent, work) : parent.namespace.authorizeActivationIssuance(activation, parent, signingKey, work);
1278
- checkSelection({ source, candidateIndex }, artifact, activation, artifactDigest, candidateID, routeDigest, once);
1279
- return { issued, initiation, sessionEnd, evidence };
1280
- }
1281
- export function validateIdentityKey(profile, algorithm, noise, identity) {
1282
- const p = ownProfile(profile);
1283
- requireCredential(algorithm === BigInt(p.dh_algorithm));
1284
- const point = ed25519.Point.fromBytes(identity, false);
1285
- requireCredential(!point.is0() && point.isTorsionFree() && equalCredential(point.toBytes(), identity), "credential_invalid");
1286
- if (algorithm === 0n) {
1287
- const contribution = x25519.getSharedSecret(new Uint8Array(32).fill(0x5a), noise);
1288
- try {
1289
- requireCredential(contribution.some(x => x !== 0), "credential_invalid");
1290
- }
1291
- finally {
1292
- contribution.fill(0);
1293
- }
1294
- }
1295
- else {
1296
- requireCredential(noise.length === 65 && noise[0] === 4, "credential_invalid");
1297
- const point = p256.Point.fromBytes(noise);
1298
- point.assertValidity();
1299
- requireCredential(equalCredential(point.toBytes(false), noise));
1300
- }
1301
- }
1302
- export function candidateRouteBytes(artifact, candidate) {
1303
- const buffer = new Uint8Array(65536), writer = new FixedCBORWriter(buffer), kind = artifact.uint("path_kind", candidate, "Candidate");
1304
- writer.map(kind === 0n ? 3 : 4).uint(0).uint(kind).uint(1).data(artifact.bytes("candidate_id", candidate, "Candidate"));
1305
- const fields = kind === 0n ? [[2, "direct_leg"]] : [[3, "client_leg"], [4, "server_leg"]];
1306
- try {
1307
- for (const [id, field] of fields)
1308
- writer.uint(id).encoded(artifact.encoded(artifact.field(field, candidate, "Candidate")));
1309
- return new Uint8Array(writer.result());
1310
- }
1311
- finally {
1312
- buffer.fill(0);
1313
- }
1314
- }
1315
- export function candidateRouteDigest(artifact, candidate) {
1316
- const bytes = candidateRouteBytes(artifact, candidate);
1317
- try {
1318
- return credentialDigest("route_digest", bytes);
1319
- }
1320
- finally {
1321
- bytes.fill(0);
1322
- }
1323
- }
1324
- function validateTunnelGrantProjection(config, work, artifact, candidate, activation, role, common, artifactDigest, routeDigest, grantBytes, relayBytes, relay, scope) {
1325
- const grant = work.parse(grantBytes, "Grant", 65536);
1326
- let routeBytes;
1327
- try {
1328
- const ref = grant.field("parent_ref"), contract = artifact.field("session_contract"), ns = config.namespaces.find(value => value.matches(grant));
1329
- requireCredential(ns !== undefined, "credential_untrusted");
1330
- routeBytes = candidateRouteBytes(artifact, candidate);
1331
- for (const [name, originalName] of [["artifact_digest", undefined], ["namespace_capacity_digest", "namespace_capacity_digest"], ["artifact_issuer_key_id", "issuer_key_id"], ["lease_id", "lease_id"]]) {
1332
- const expected = originalName === undefined ? artifactDigest : artifact.bytes(originalName);
1333
- try {
1334
- requireCredential(equalCredential(grant.bytes(name, ref, "GrantParentRef"), expected));
1335
- }
1336
- finally {
1337
- if (originalName !== undefined)
1338
- expected.fill(0);
1339
- }
1340
- }
1341
- for (const [name, originalName] of [["authority_generation", "revocation_authority_generation"], ["revocation_epoch", "revocation_epoch"], ["revocation_policy_revision", "revocation_policy_revision"], ["issued_at_ms", "issued_at_ms"], ["initiation_not_after_ms", "initiation_not_after_ms"], ["session_not_after_ms", "session_not_after_ms"]])
1342
- requireCredential(grant.uint(name, ref, "GrantParentRef") === artifact.uint(originalName));
1343
- for (const name of ["tenant_id", "revocation_authority_id", "revocation_policy_id"])
1344
- requireCredential(grant.text(name, ref, "GrantParentRef") === artifact.text(name));
1345
- requireCredential(equalCredential(grant.encoded(grant.field("route_descriptor")), routeBytes) && equalCredential(grant.bytes("route_digest"), routeDigest) &&
1346
- equalCredential(grant.bytes("session_contract_digest"), work.digest(artifact, "session_contract_digest", contract)) &&
1347
- grant.uint("max_envelope_bytes", grant.field("limits"), "GrantLimits") === artifact.uint("max_frame", contract, "SessionContract") + 8n && equalCredential(grant.bytes("attempt_id"), activation.bytes("attempt_id")));
1348
- const identities = [...grant.items("identity_digests")];
1349
- requireCredential(identities.length === 2);
1350
- for (const [index, node] of identities.entries()) {
1351
- const digest = new Uint8Array(grant.doc.size(node));
1352
- grant.doc.copyPayload(node, digest);
1353
- try {
1354
- requireCredential(equalCredential(digest, common[index + 1].digest));
1355
- }
1356
- finally {
1357
- digest.fill(0);
1358
- }
1359
- }
1360
- if (scope !== undefined) {
1361
- const namespace = grant.field("namespace");
1362
- scope.namespace.checkEvidence(scope);
1363
- requireCredential(ns === scope.namespace && equalCredential(grant.bytes("issuer_key_id"), scope.issuer) && grant.uint("revocation_epoch", namespace, "GrantNamespace") === scope.cohort &&
1364
- grant.text("revocation_policy_id", namespace, "GrantNamespace") === scope.policyID && grant.uint("revocation_policy_revision", namespace, "GrantNamespace") === scope.policyRevision &&
1365
- grant.uint("role_mask", namespace, "GrantNamespace") === (4n | 1n << BigInt(role)) && grant.uint("not_after_ms") <= scope.expires, "credential_binding");
1366
- }
1367
- checkTunnelClosure(artifact, candidate, role, common.map(value => value.namespace), ns, relay, relayBytes, work, config.namespaces);
1368
- }
1369
- finally {
1370
- routeBytes?.fill(0);
1371
- grant.close();
1372
- }
1373
- }
1374
- function checkTunnelClosure(artifact, candidate, role, commonNamespaces, grantNamespace, relay, relayBytes, work, namespaces) {
1375
- const certificate = work.parse(relayBytes, "IdentityCertificate", 8192);
1376
- try {
1377
- const relayNamespace = namespaces.find(ns => ns.matches(certificate));
1378
- requireCredential(relayNamespace !== undefined);
1379
- const contexts = [...commonNamespaces, grantNamespace, relayNamespace], seen = new Set(), masks = new Map(), mask = 4n | 1n << BigInt(role);
1380
- for (const ns of commonNamespaces)
1381
- masks.set(ns, 7n);
1382
- for (const ns of [grantNamespace, relayNamespace])
1383
- masks.set(ns, (masks.get(ns) ?? 0n) | mask);
1384
- for (const node of artifact.items("revocation_namespace_refs", candidate, "Candidate")) {
1385
- const ns = contexts.find(value => artifact.text("tenant_id", node, "RevocationNamespaceRef") === value.tenant && artifact.text("revocation_authority_id", node, "RevocationNamespaceRef") === value.authority);
1386
- if (ns === undefined) {
1387
- requireCredential((artifact.uint("role_mask", node, "RevocationNamespaceRef") & mask) !== mask);
1388
- continue;
1389
- }
1390
- const required = masks.get(ns);
1391
- requireCredential((artifact.uint("role_mask", node, "RevocationNamespaceRef") & required) === required && !seen.has(ns));
1392
- ns.checkReference(artifact, node);
1393
- seen.add(ns);
1394
- }
1395
- requireCredential(contexts.every(ns => seen.has(ns)));
1396
- relay?.check();
1397
- }
1398
- finally {
1399
- certificate.close();
1400
- }
1401
- }
1402
- function checkClosure(artifact, candidate, contexts) {
1403
- const references = [...artifact.items("revocation_namespace_refs", candidate, "Candidate")], seen = new Set();
1404
- for (const node of references) {
1405
- const ns = contexts.find(n => artifact.text("tenant_id", node, "RevocationNamespaceRef") === n.tenant && artifact.text("revocation_authority_id", node, "RevocationNamespaceRef") === n.authority);
1406
- requireCredential(ns !== undefined && !seen.has(ns) && artifact.uint("role_mask", node, "RevocationNamespaceRef") === 3n);
1407
- ns.checkReference(artifact, node);
1408
- seen.add(ns);
1409
- }
1410
- requireCredential(contexts.every(n => seen.has(n)));
1411
- }
1412
- export function checkSelection(input, artifact, activation, artifactDigest, candidateID, route, once) {
1413
- if (input.source === "live_authority") {
1414
- requireCredential(equalCredential(activation.bytes("candidate_selection"), candidateID) && equalCredential(activation.bytes("route_selection"), route));
1415
- return [input.candidateIndex];
1416
- }
1417
- const selection = activation.field("candidate_selection"), schema = "PoolSelectionRef";
1418
- requireCredential(equalCredential(activation.bytes("artifact_digest", selection, schema), artifactDigest) &&
1419
- equalCredential(activation.encoded(activation.field("once_authority_ref", selection, schema)), once.encoded()));
1420
- const indices = [...activation.items("candidate_indices", selection, schema)], candidates = [...artifact.items("candidates")], buffer = new Uint8Array(2048);
1421
- const writer = new FixedCBORWriter(buffer).map(2).uint(0).data(artifactDigest).uint(1).array(indices.length);
1422
- let found = false;
1423
- for (const node of indices) {
1424
- const index = Number(activation.doc.uint(node)), candidate = candidates[index];
1425
- requireCredential(candidate !== undefined);
1426
- found ||= index === input.candidateIndex;
1427
- writer.map(3).uint(0).uint(index).uint(1).data(artifact.bytes("candidate_id", candidate, "Candidate")).uint(2).data(candidateRouteDigest(artifact, candidate));
1428
- }
1429
- try {
1430
- requireCredential(found && equalCredential(credentialDigest("candidate_set_digest", writer.result()), activation.bytes("candidate_set_digest", selection, schema)) &&
1431
- equalCredential(credentialDigest("route_set_digest", writer.result()), activation.bytes("route_selection")));
1432
- return indices.map(node => Number(activation.doc.uint(node)));
1433
- }
1434
- finally {
1435
- buffer.fill(0);
1436
- }
1437
- }
1438
- function min(...values) { return values.reduce((a, b) => a < b ? a : b); }
1439
- function max(...values) { return values.reduce((a, b) => a > b ? a : b); }
1440
- for (const ctor of [VerifiedPoolSpendFacts, VerifiedCredentialClosure, CredentialSessionBinding, TunnelCredentialPreparation]) {
1441
- Object.freeze(ctor.prototype);
1442
- Object.freeze(ctor);
1443
- }