@decionis/agentsafe 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (436) hide show
  1. package/LICENSE +202 -0
  2. package/NOTICE +4 -0
  3. package/README.md +909 -0
  4. package/dist/Cli.d.ts +3 -0
  5. package/dist/Cli.d.ts.map +1 -0
  6. package/dist/Cli.js +150 -0
  7. package/dist/Cli.js.map +1 -0
  8. package/dist/Index.d.ts +104 -0
  9. package/dist/Index.d.ts.map +1 -0
  10. package/dist/Index.js +102 -0
  11. package/dist/Index.js.map +1 -0
  12. package/dist/Serve.d.ts +26 -0
  13. package/dist/Serve.d.ts.map +1 -0
  14. package/dist/Serve.js +143 -0
  15. package/dist/Serve.js.map +1 -0
  16. package/dist/TrustedExecutor.d.ts +66 -0
  17. package/dist/TrustedExecutor.d.ts.map +1 -0
  18. package/dist/TrustedExecutor.js +170 -0
  19. package/dist/TrustedExecutor.js.map +1 -0
  20. package/dist/Version.d.ts +6 -0
  21. package/dist/Version.d.ts.map +1 -0
  22. package/dist/Version.js +21 -0
  23. package/dist/Version.js.map +1 -0
  24. package/dist/adapters/AdapterActionHandler.d.ts +48 -0
  25. package/dist/adapters/AdapterActionHandler.d.ts.map +1 -0
  26. package/dist/adapters/AdapterActionHandler.js +148 -0
  27. package/dist/adapters/AdapterActionHandler.js.map +1 -0
  28. package/dist/adapters/EffectAdapter.d.ts +96 -0
  29. package/dist/adapters/EffectAdapter.d.ts.map +1 -0
  30. package/dist/adapters/EffectAdapter.js +16 -0
  31. package/dist/adapters/EffectAdapter.js.map +1 -0
  32. package/dist/adapters/EffectAwareGrantVerifier.d.ts +30 -0
  33. package/dist/adapters/EffectAwareGrantVerifier.d.ts.map +1 -0
  34. package/dist/adapters/EffectAwareGrantVerifier.js +38 -0
  35. package/dist/adapters/EffectAwareGrantVerifier.js.map +1 -0
  36. package/dist/adapters/EffectComparison.d.ts +20 -0
  37. package/dist/adapters/EffectComparison.d.ts.map +1 -0
  38. package/dist/adapters/EffectComparison.js +48 -0
  39. package/dist/adapters/EffectComparison.js.map +1 -0
  40. package/dist/adapters/EffectEvidenceBuilder.d.ts +60 -0
  41. package/dist/adapters/EffectEvidenceBuilder.d.ts.map +1 -0
  42. package/dist/adapters/EffectEvidenceBuilder.js +127 -0
  43. package/dist/adapters/EffectEvidenceBuilder.js.map +1 -0
  44. package/dist/adapters/EffectEvidenceRegister.d.ts +31 -0
  45. package/dist/adapters/EffectEvidenceRegister.d.ts.map +1 -0
  46. package/dist/adapters/EffectEvidenceRegister.js +21 -0
  47. package/dist/adapters/EffectEvidenceRegister.js.map +1 -0
  48. package/dist/adapters/JcsDigest.d.ts +43 -0
  49. package/dist/adapters/JcsDigest.d.ts.map +1 -0
  50. package/dist/adapters/JcsDigest.js +86 -0
  51. package/dist/adapters/JcsDigest.js.map +1 -0
  52. package/dist/adapters/banking/BankingAction.d.ts +146 -0
  53. package/dist/adapters/banking/BankingAction.d.ts.map +1 -0
  54. package/dist/adapters/banking/BankingAction.js +102 -0
  55. package/dist/adapters/banking/BankingAction.js.map +1 -0
  56. package/dist/adapters/banking/BankingAdapter.d.ts +60 -0
  57. package/dist/adapters/banking/BankingAdapter.d.ts.map +1 -0
  58. package/dist/adapters/banking/BankingAdapter.js +107 -0
  59. package/dist/adapters/banking/BankingAdapter.js.map +1 -0
  60. package/dist/adapters/banking/BankingHandlers.d.ts +24 -0
  61. package/dist/adapters/banking/BankingHandlers.d.ts.map +1 -0
  62. package/dist/adapters/banking/BankingHandlers.js +47 -0
  63. package/dist/adapters/banking/BankingHandlers.js.map +1 -0
  64. package/dist/adapters/banking/BankingIntentBinder.d.ts +47 -0
  65. package/dist/adapters/banking/BankingIntentBinder.d.ts.map +1 -0
  66. package/dist/adapters/banking/BankingIntentBinder.js +64 -0
  67. package/dist/adapters/banking/BankingIntentBinder.js.map +1 -0
  68. package/dist/adapters/banking/CoreBankingHttpAdapter.d.ts +55 -0
  69. package/dist/adapters/banking/CoreBankingHttpAdapter.d.ts.map +1 -0
  70. package/dist/adapters/banking/CoreBankingHttpAdapter.js +248 -0
  71. package/dist/adapters/banking/CoreBankingHttpAdapter.js.map +1 -0
  72. package/dist/adapters/banking/Currency.d.ts +10 -0
  73. package/dist/adapters/banking/Currency.d.ts.map +1 -0
  74. package/dist/adapters/banking/Currency.js +91 -0
  75. package/dist/adapters/banking/Currency.js.map +1 -0
  76. package/dist/adapters/banking/EffectProjections.d.ts +52 -0
  77. package/dist/adapters/banking/EffectProjections.d.ts.map +1 -0
  78. package/dist/adapters/banking/EffectProjections.js +140 -0
  79. package/dist/adapters/banking/EffectProjections.js.map +1 -0
  80. package/dist/adapters/banking/Iban.d.ts +18 -0
  81. package/dist/adapters/banking/Iban.d.ts.map +1 -0
  82. package/dist/adapters/banking/Iban.js +38 -0
  83. package/dist/adapters/banking/Iban.js.map +1 -0
  84. package/dist/adapters/banking/Money.d.ts +32 -0
  85. package/dist/adapters/banking/Money.d.ts.map +1 -0
  86. package/dist/adapters/banking/Money.js +81 -0
  87. package/dist/adapters/banking/Money.js.map +1 -0
  88. package/dist/adapters/banking/ReasonCodes.d.ts +19 -0
  89. package/dist/adapters/banking/ReasonCodes.d.ts.map +1 -0
  90. package/dist/adapters/banking/ReasonCodes.js +35 -0
  91. package/dist/adapters/banking/ReasonCodes.js.map +1 -0
  92. package/dist/audit/ChainJournal.d.ts +38 -0
  93. package/dist/audit/ChainJournal.d.ts.map +1 -0
  94. package/dist/audit/ChainJournal.js +97 -0
  95. package/dist/audit/ChainJournal.js.map +1 -0
  96. package/dist/audit/HashChain.d.ts +39 -0
  97. package/dist/audit/HashChain.d.ts.map +1 -0
  98. package/dist/audit/HashChain.js +63 -0
  99. package/dist/audit/HashChain.js.map +1 -0
  100. package/dist/audit/HashChainedAuditSink.d.ts +22 -0
  101. package/dist/audit/HashChainedAuditSink.d.ts.map +1 -0
  102. package/dist/audit/HashChainedAuditSink.js +26 -0
  103. package/dist/audit/HashChainedAuditSink.js.map +1 -0
  104. package/dist/audit/LineAuditSink.d.ts +19 -0
  105. package/dist/audit/LineAuditSink.d.ts.map +1 -0
  106. package/dist/audit/LineAuditSink.js +35 -0
  107. package/dist/audit/LineAuditSink.js.map +1 -0
  108. package/dist/cli/Arguments.d.ts +26 -0
  109. package/dist/cli/Arguments.d.ts.map +1 -0
  110. package/dist/cli/Arguments.js +66 -0
  111. package/dist/cli/Arguments.js.map +1 -0
  112. package/dist/cli/CliProcess.d.ts +29 -0
  113. package/dist/cli/CliProcess.d.ts.map +1 -0
  114. package/dist/cli/CliProcess.js +78 -0
  115. package/dist/cli/CliProcess.js.map +1 -0
  116. package/dist/cli/Commands.d.ts +8 -0
  117. package/dist/cli/Commands.d.ts.map +1 -0
  118. package/dist/cli/Commands.js +67 -0
  119. package/dist/cli/Commands.js.map +1 -0
  120. package/dist/cli/ConfigCommand.d.ts +7 -0
  121. package/dist/cli/ConfigCommand.d.ts.map +1 -0
  122. package/dist/cli/ConfigCommand.js +77 -0
  123. package/dist/cli/ConfigCommand.js.map +1 -0
  124. package/dist/cli/ConfigFile.d.ts +21 -0
  125. package/dist/cli/ConfigFile.d.ts.map +1 -0
  126. package/dist/cli/ConfigFile.js +57 -0
  127. package/dist/cli/ConfigFile.js.map +1 -0
  128. package/dist/cli/Credentials.d.ts +15 -0
  129. package/dist/cli/Credentials.d.ts.map +1 -0
  130. package/dist/cli/Credentials.js +51 -0
  131. package/dist/cli/Credentials.js.map +1 -0
  132. package/dist/cli/Doctor.d.ts +25 -0
  133. package/dist/cli/Doctor.d.ts.map +1 -0
  134. package/dist/cli/Doctor.js +211 -0
  135. package/dist/cli/Doctor.js.map +1 -0
  136. package/dist/cli/Help.d.ts +3 -0
  137. package/dist/cli/Help.d.ts.map +1 -0
  138. package/dist/cli/Help.js +38 -0
  139. package/dist/cli/Help.js.map +1 -0
  140. package/dist/cli/Init.d.ts +32 -0
  141. package/dist/cli/Init.d.ts.map +1 -0
  142. package/dist/cli/Init.js +163 -0
  143. package/dist/cli/Init.js.map +1 -0
  144. package/dist/cli/Login.d.ts +16 -0
  145. package/dist/cli/Login.d.ts.map +1 -0
  146. package/dist/cli/Login.js +74 -0
  147. package/dist/cli/Login.js.map +1 -0
  148. package/dist/cli/Proxy.d.ts +41 -0
  149. package/dist/cli/Proxy.d.ts.map +1 -0
  150. package/dist/cli/Proxy.js +161 -0
  151. package/dist/cli/Proxy.js.map +1 -0
  152. package/dist/cli/Status.d.ts +7 -0
  153. package/dist/cli/Status.d.ts.map +1 -0
  154. package/dist/cli/Status.js +64 -0
  155. package/dist/cli/Status.js.map +1 -0
  156. package/dist/cli/TestCommand.d.ts +36 -0
  157. package/dist/cli/TestCommand.d.ts.map +1 -0
  158. package/dist/cli/TestCommand.js +173 -0
  159. package/dist/cli/TestCommand.js.map +1 -0
  160. package/dist/config/ConfigKeys.d.ts +10 -0
  161. package/dist/config/ConfigKeys.d.ts.map +1 -0
  162. package/dist/config/ConfigKeys.js +105 -0
  163. package/dist/config/ConfigKeys.js.map +1 -0
  164. package/dist/config/ExecutorConfig.d.ts +254 -0
  165. package/dist/config/ExecutorConfig.d.ts.map +1 -0
  166. package/dist/config/ExecutorConfig.js +637 -0
  167. package/dist/config/ExecutorConfig.js.map +1 -0
  168. package/dist/containment/ContainmentProbe.d.ts +87 -0
  169. package/dist/containment/ContainmentProbe.d.ts.map +1 -0
  170. package/dist/containment/ContainmentProbe.js +103 -0
  171. package/dist/containment/ContainmentProbe.js.map +1 -0
  172. package/dist/credential/CredentialError.d.ts +6 -0
  173. package/dist/credential/CredentialError.d.ts.map +1 -0
  174. package/dist/credential/CredentialError.js +10 -0
  175. package/dist/credential/CredentialError.js.map +1 -0
  176. package/dist/credential/DownstreamCredential.d.ts +38 -0
  177. package/dist/credential/DownstreamCredential.d.ts.map +1 -0
  178. package/dist/credential/DownstreamCredential.js +2 -0
  179. package/dist/credential/DownstreamCredential.js.map +1 -0
  180. package/dist/credential/GrantOf.d.ts +10 -0
  181. package/dist/credential/GrantOf.d.ts.map +1 -0
  182. package/dist/credential/GrantOf.js +16 -0
  183. package/dist/credential/GrantOf.js.map +1 -0
  184. package/dist/credential/PrivateKeyJwtCredential.d.ts +43 -0
  185. package/dist/credential/PrivateKeyJwtCredential.d.ts.map +1 -0
  186. package/dist/credential/PrivateKeyJwtCredential.js +126 -0
  187. package/dist/credential/PrivateKeyJwtCredential.js.map +1 -0
  188. package/dist/credential/SignedRequestCredential.d.ts +112 -0
  189. package/dist/credential/SignedRequestCredential.d.ts.map +1 -0
  190. package/dist/credential/SignedRequestCredential.js +255 -0
  191. package/dist/credential/SignedRequestCredential.js.map +1 -0
  192. package/dist/credential/StaticHeaderCredential.d.ts +16 -0
  193. package/dist/credential/StaticHeaderCredential.d.ts.map +1 -0
  194. package/dist/credential/StaticHeaderCredential.js +21 -0
  195. package/dist/credential/StaticHeaderCredential.js.map +1 -0
  196. package/dist/egress/EgressError.d.ts +13 -0
  197. package/dist/egress/EgressError.d.ts.map +1 -0
  198. package/dist/egress/EgressError.js +16 -0
  199. package/dist/egress/EgressError.js.map +1 -0
  200. package/dist/egress/EgressPolicy.d.ts +55 -0
  201. package/dist/egress/EgressPolicy.d.ts.map +1 -0
  202. package/dist/egress/EgressPolicy.js +137 -0
  203. package/dist/egress/EgressPolicy.js.map +1 -0
  204. package/dist/egress/GlobalFetchLock.d.ts +16 -0
  205. package/dist/egress/GlobalFetchLock.d.ts.map +1 -0
  206. package/dist/egress/GlobalFetchLock.js +34 -0
  207. package/dist/egress/GlobalFetchLock.js.map +1 -0
  208. package/dist/egress/GuardedFetch.d.ts +56 -0
  209. package/dist/egress/GuardedFetch.d.ts.map +1 -0
  210. package/dist/egress/GuardedFetch.js +300 -0
  211. package/dist/egress/GuardedFetch.js.map +1 -0
  212. package/dist/egress/TcpProbe.d.ts +35 -0
  213. package/dist/egress/TcpProbe.d.ts.map +1 -0
  214. package/dist/egress/TcpProbe.js +45 -0
  215. package/dist/egress/TcpProbe.js.map +1 -0
  216. package/dist/gateway/Activation.d.ts +39 -0
  217. package/dist/gateway/Activation.d.ts.map +1 -0
  218. package/dist/gateway/Activation.js +61 -0
  219. package/dist/gateway/Activation.js.map +1 -0
  220. package/dist/gateway/BoundaryTest.d.ts +92 -0
  221. package/dist/gateway/BoundaryTest.d.ts.map +1 -0
  222. package/dist/gateway/BoundaryTest.js +349 -0
  223. package/dist/gateway/BoundaryTest.js.map +1 -0
  224. package/dist/gateway/DemoAuthority.d.ts +41 -0
  225. package/dist/gateway/DemoAuthority.d.ts.map +1 -0
  226. package/dist/gateway/DemoAuthority.js +66 -0
  227. package/dist/gateway/DemoAuthority.js.map +1 -0
  228. package/dist/gateway/ForwardHandler.d.ts +56 -0
  229. package/dist/gateway/ForwardHandler.d.ts.map +1 -0
  230. package/dist/gateway/ForwardHandler.js +111 -0
  231. package/dist/gateway/ForwardHandler.js.map +1 -0
  232. package/dist/gateway/Gateway.d.ts +142 -0
  233. package/dist/gateway/Gateway.d.ts.map +1 -0
  234. package/dist/gateway/Gateway.js +819 -0
  235. package/dist/gateway/Gateway.js.map +1 -0
  236. package/dist/gateway/GatewayConfig.d.ts +237 -0
  237. package/dist/gateway/GatewayConfig.d.ts.map +1 -0
  238. package/dist/gateway/GatewayConfig.js +706 -0
  239. package/dist/gateway/GatewayConfig.js.map +1 -0
  240. package/dist/gateway/GatewayMetrics.d.ts +26 -0
  241. package/dist/gateway/GatewayMetrics.d.ts.map +1 -0
  242. package/dist/gateway/GatewayMetrics.js +28 -0
  243. package/dist/gateway/GatewayMetrics.js.map +1 -0
  244. package/dist/gateway/GatewayReport.d.ts +74 -0
  245. package/dist/gateway/GatewayReport.d.ts.map +1 -0
  246. package/dist/gateway/GatewayReport.js +109 -0
  247. package/dist/gateway/GatewayReport.js.map +1 -0
  248. package/dist/gateway/InterceptedRequest.d.ts +53 -0
  249. package/dist/gateway/InterceptedRequest.d.ts.map +1 -0
  250. package/dist/gateway/InterceptedRequest.js +80 -0
  251. package/dist/gateway/InterceptedRequest.js.map +1 -0
  252. package/dist/gateway/RouteTable.d.ts +28 -0
  253. package/dist/gateway/RouteTable.d.ts.map +1 -0
  254. package/dist/gateway/RouteTable.js +72 -0
  255. package/dist/gateway/RouteTable.js.map +1 -0
  256. package/dist/gateway/Upstream.d.ts +46 -0
  257. package/dist/gateway/Upstream.d.ts.map +1 -0
  258. package/dist/gateway/Upstream.js +158 -0
  259. package/dist/gateway/Upstream.js.map +1 -0
  260. package/dist/handlers/ForwardRequestHandler.d.ts +26 -0
  261. package/dist/handlers/ForwardRequestHandler.d.ts.map +1 -0
  262. package/dist/handlers/ForwardRequestHandler.js +98 -0
  263. package/dist/handlers/ForwardRequestHandler.js.map +1 -0
  264. package/dist/handlers/HandlerRegistration.d.ts +37 -0
  265. package/dist/handlers/HandlerRegistration.d.ts.map +1 -0
  266. package/dist/handlers/HandlerRegistration.js +2 -0
  267. package/dist/handlers/HandlerRegistration.js.map +1 -0
  268. package/dist/handlers/JournaledActionHandler.d.ts +31 -0
  269. package/dist/handlers/JournaledActionHandler.d.ts.map +1 -0
  270. package/dist/handlers/JournaledActionHandler.js +63 -0
  271. package/dist/handlers/JournaledActionHandler.js.map +1 -0
  272. package/dist/http/ExecutorHttpServer.d.ts +33 -0
  273. package/dist/http/ExecutorHttpServer.d.ts.map +1 -0
  274. package/dist/http/ExecutorHttpServer.js +176 -0
  275. package/dist/http/ExecutorHttpServer.js.map +1 -0
  276. package/dist/http/GatewayHttpServer.d.ts +42 -0
  277. package/dist/http/GatewayHttpServer.d.ts.map +1 -0
  278. package/dist/http/GatewayHttpServer.js +195 -0
  279. package/dist/http/GatewayHttpServer.js.map +1 -0
  280. package/dist/http/RecordingTarget.d.ts +18 -0
  281. package/dist/http/RecordingTarget.d.ts.map +1 -0
  282. package/dist/http/RecordingTarget.js +71 -0
  283. package/dist/http/RecordingTarget.js.map +1 -0
  284. package/dist/http/RequestContext.d.ts +17 -0
  285. package/dist/http/RequestContext.d.ts.map +1 -0
  286. package/dist/http/RequestContext.js +19 -0
  287. package/dist/http/RequestContext.js.map +1 -0
  288. package/dist/http/Routes.d.ts +93 -0
  289. package/dist/http/Routes.d.ts.map +1 -0
  290. package/dist/http/Routes.js +46 -0
  291. package/dist/http/Routes.js.map +1 -0
  292. package/dist/http/TlsListener.d.ts +38 -0
  293. package/dist/http/TlsListener.d.ts.map +1 -0
  294. package/dist/http/TlsListener.js +52 -0
  295. package/dist/http/TlsListener.js.map +1 -0
  296. package/dist/identity/Authenticator.d.ts +58 -0
  297. package/dist/identity/Authenticator.d.ts.map +1 -0
  298. package/dist/identity/Authenticator.js +170 -0
  299. package/dist/identity/Authenticator.js.map +1 -0
  300. package/dist/identity/PeerIdentity.d.ts +24 -0
  301. package/dist/identity/PeerIdentity.d.ts.map +1 -0
  302. package/dist/identity/PeerIdentity.js +29 -0
  303. package/dist/identity/PeerIdentity.js.map +1 -0
  304. package/dist/identity/PrincipalRegistry.d.ts +102 -0
  305. package/dist/identity/PrincipalRegistry.d.ts.map +1 -0
  306. package/dist/identity/PrincipalRegistry.js +191 -0
  307. package/dist/identity/PrincipalRegistry.js.map +1 -0
  308. package/dist/identity/PrincipalsFile.d.ts +152 -0
  309. package/dist/identity/PrincipalsFile.d.ts.map +1 -0
  310. package/dist/identity/PrincipalsFile.js +125 -0
  311. package/dist/identity/PrincipalsFile.js.map +1 -0
  312. package/dist/identity/RateLimiter.d.ts +43 -0
  313. package/dist/identity/RateLimiter.d.ts.map +1 -0
  314. package/dist/identity/RateLimiter.js +84 -0
  315. package/dist/identity/RateLimiter.js.map +1 -0
  316. package/dist/identity/SeparationOfDuties.d.ts +11 -0
  317. package/dist/identity/SeparationOfDuties.d.ts.map +1 -0
  318. package/dist/identity/SeparationOfDuties.js +25 -0
  319. package/dist/identity/SeparationOfDuties.js.map +1 -0
  320. package/dist/identity/WorkloadJwtVerifier.d.ts +57 -0
  321. package/dist/identity/WorkloadJwtVerifier.d.ts.map +1 -0
  322. package/dist/identity/WorkloadJwtVerifier.js +145 -0
  323. package/dist/identity/WorkloadJwtVerifier.js.map +1 -0
  324. package/dist/incident/EvidenceExport.d.ts +128 -0
  325. package/dist/incident/EvidenceExport.d.ts.map +1 -0
  326. package/dist/incident/EvidenceExport.js +187 -0
  327. package/dist/incident/EvidenceExport.js.map +1 -0
  328. package/dist/incident/FileProbe.d.ts +22 -0
  329. package/dist/incident/FileProbe.d.ts.map +1 -0
  330. package/dist/incident/FileProbe.js +31 -0
  331. package/dist/incident/FileProbe.js.map +1 -0
  332. package/dist/incident/HaltSwitch.d.ts +95 -0
  333. package/dist/incident/HaltSwitch.d.ts.map +1 -0
  334. package/dist/incident/HaltSwitch.js +171 -0
  335. package/dist/incident/HaltSwitch.js.map +1 -0
  336. package/dist/incident/Metrics.d.ts +71 -0
  337. package/dist/incident/Metrics.d.ts.map +1 -0
  338. package/dist/incident/Metrics.js +146 -0
  339. package/dist/incident/Metrics.js.map +1 -0
  340. package/dist/incident/SecurityEvents.d.ts +182 -0
  341. package/dist/incident/SecurityEvents.d.ts.map +1 -0
  342. package/dist/incident/SecurityEvents.js +167 -0
  343. package/dist/incident/SecurityEvents.js.map +1 -0
  344. package/dist/journal/ExecutionJournal.d.ts +96 -0
  345. package/dist/journal/ExecutionJournal.d.ts.map +1 -0
  346. package/dist/journal/ExecutionJournal.js +100 -0
  347. package/dist/journal/ExecutionJournal.js.map +1 -0
  348. package/dist/journal/FileExecutionJournal.d.ts +38 -0
  349. package/dist/journal/FileExecutionJournal.d.ts.map +1 -0
  350. package/dist/journal/FileExecutionJournal.js +137 -0
  351. package/dist/journal/FileExecutionJournal.js.map +1 -0
  352. package/dist/journal/InMemoryExecutionJournal.d.ts +23 -0
  353. package/dist/journal/InMemoryExecutionJournal.d.ts.map +1 -0
  354. package/dist/journal/InMemoryExecutionJournal.js +47 -0
  355. package/dist/journal/InMemoryExecutionJournal.js.map +1 -0
  356. package/dist/journal/StartupReconciler.d.ts +47 -0
  357. package/dist/journal/StartupReconciler.d.ts.map +1 -0
  358. package/dist/journal/StartupReconciler.js +89 -0
  359. package/dist/journal/StartupReconciler.js.map +1 -0
  360. package/dist/limits/HardLimits.d.ts +63 -0
  361. package/dist/limits/HardLimits.d.ts.map +1 -0
  362. package/dist/limits/HardLimits.js +120 -0
  363. package/dist/limits/HardLimits.js.map +1 -0
  364. package/dist/logging/LineEmitter.d.ts +26 -0
  365. package/dist/logging/LineEmitter.d.ts.map +1 -0
  366. package/dist/logging/LineEmitter.js +36 -0
  367. package/dist/logging/LineEmitter.js.map +1 -0
  368. package/dist/posture/HostPosture.d.ts +60 -0
  369. package/dist/posture/HostPosture.d.ts.map +1 -0
  370. package/dist/posture/HostPosture.js +104 -0
  371. package/dist/posture/HostPosture.js.map +1 -0
  372. package/dist/posture/PostureChecks.d.ts +52 -0
  373. package/dist/posture/PostureChecks.d.ts.map +1 -0
  374. package/dist/posture/PostureChecks.js +172 -0
  375. package/dist/posture/PostureChecks.js.map +1 -0
  376. package/dist/secrets/CompositeSecretStore.d.ts +37 -0
  377. package/dist/secrets/CompositeSecretStore.d.ts.map +1 -0
  378. package/dist/secrets/CompositeSecretStore.js +99 -0
  379. package/dist/secrets/CompositeSecretStore.js.map +1 -0
  380. package/dist/secrets/EnvSecretStore.d.ts +18 -0
  381. package/dist/secrets/EnvSecretStore.d.ts.map +1 -0
  382. package/dist/secrets/EnvSecretStore.js +46 -0
  383. package/dist/secrets/EnvSecretStore.js.map +1 -0
  384. package/dist/secrets/FileSecretStore.d.ts +60 -0
  385. package/dist/secrets/FileSecretStore.d.ts.map +1 -0
  386. package/dist/secrets/FileSecretStore.js +180 -0
  387. package/dist/secrets/FileSecretStore.js.map +1 -0
  388. package/dist/secrets/Redactor.d.ts +32 -0
  389. package/dist/secrets/Redactor.d.ts.map +1 -0
  390. package/dist/secrets/Redactor.js +108 -0
  391. package/dist/secrets/Redactor.js.map +1 -0
  392. package/dist/secrets/SecretHandle.d.ts +34 -0
  393. package/dist/secrets/SecretHandle.d.ts.map +1 -0
  394. package/dist/secrets/SecretHandle.js +71 -0
  395. package/dist/secrets/SecretHandle.js.map +1 -0
  396. package/dist/secrets/SecretStore.d.ts +37 -0
  397. package/dist/secrets/SecretStore.d.ts.map +1 -0
  398. package/dist/secrets/SecretStore.js +12 -0
  399. package/dist/secrets/SecretStore.js.map +1 -0
  400. package/dist/service/AuthorityClients.d.ts +50 -0
  401. package/dist/service/AuthorityClients.d.ts.map +1 -0
  402. package/dist/service/AuthorityClients.js +83 -0
  403. package/dist/service/AuthorityClients.js.map +1 -0
  404. package/dist/service/EscalationResolver.d.ts +97 -0
  405. package/dist/service/EscalationResolver.d.ts.map +1 -0
  406. package/dist/service/EscalationResolver.js +196 -0
  407. package/dist/service/EscalationResolver.js.map +1 -0
  408. package/dist/service/Requests.d.ts +99 -0
  409. package/dist/service/Requests.d.ts.map +1 -0
  410. package/dist/service/Requests.js +42 -0
  411. package/dist/service/Requests.js.map +1 -0
  412. package/dist/service/ServiceError.d.ts +20 -0
  413. package/dist/service/ServiceError.d.ts.map +1 -0
  414. package/dist/service/ServiceError.js +25 -0
  415. package/dist/service/ServiceError.js.map +1 -0
  416. package/dist/service/TrustedExecutorService.d.ts +221 -0
  417. package/dist/service/TrustedExecutorService.d.ts.map +1 -0
  418. package/dist/service/TrustedExecutorService.js +1066 -0
  419. package/dist/service/TrustedExecutorService.js.map +1 -0
  420. package/dist/time/ClockSkewGuard.d.ts +25 -0
  421. package/dist/time/ClockSkewGuard.d.ts.map +1 -0
  422. package/dist/time/ClockSkewGuard.js +35 -0
  423. package/dist/time/ClockSkewGuard.js.map +1 -0
  424. package/dist/time/MonotonicClock.d.ts +35 -0
  425. package/dist/time/MonotonicClock.d.ts.map +1 -0
  426. package/dist/time/MonotonicClock.js +52 -0
  427. package/dist/time/MonotonicClock.js.map +1 -0
  428. package/dist/verify/VerifyAuditChain.d.ts +36 -0
  429. package/dist/verify/VerifyAuditChain.d.ts.map +1 -0
  430. package/dist/verify/VerifyAuditChain.js +109 -0
  431. package/dist/verify/VerifyAuditChain.js.map +1 -0
  432. package/dist/verify/VerifyEvidenceBundle.d.ts +50 -0
  433. package/dist/verify/VerifyEvidenceBundle.d.ts.map +1 -0
  434. package/dist/verify/VerifyEvidenceBundle.js +157 -0
  435. package/dist/verify/VerifyEvidenceBundle.js.map +1 -0
  436. package/package.json +80 -0
@@ -0,0 +1,112 @@
1
+ import type { SecretHandle } from "../secrets/SecretHandle.js";
2
+ import type { DownstreamCredential, DownstreamRequest } from "./DownstreamCredential.js";
3
+ export type SignedRequestAlgorithm = "ed25519" | "hmac-sha256";
4
+ export interface SignedRequestOptions {
5
+ readonly algorithm: SignedRequestAlgorithm;
6
+ readonly keyId: string;
7
+ }
8
+ /** Covered on every request: what was sent, to where, for which intent. */
9
+ export declare const BASE_COMPONENTS: readonly ["@method", "@path", "content-digest", "idempotency-key", "x-agent-safe-intent-hash"];
10
+ /** Covered on a dispatch: which grant, and which decision, this request executes under. */
11
+ export declare const GRANT_COMPONENTS: readonly ["x-agent-safe-grant-id", "x-agent-safe-decision-id"];
12
+ /** Covered when the authority attested the claim: its proof, bound to this request. */
13
+ export declare const ATTESTATION_COMPONENT: "x-agent-safe-claim-attestation";
14
+ /** Every component this credential can cover, in the order the base lists them. */
15
+ export declare const SIGNED_COMPONENTS: readonly ["@method", "@path", "content-digest", "idempotency-key", "x-agent-safe-intent-hash", "x-agent-safe-grant-id", "x-agent-safe-decision-id", "x-agent-safe-claim-attestation"];
16
+ export type SignedComponent = (typeof SIGNED_COMPONENTS)[number];
17
+ export declare const SIGNATURE_LABEL = "agentsafe";
18
+ /** What a verifier on the downstream side needs to rebuild the base. */
19
+ export interface SignedRequestMaterial {
20
+ readonly method: string;
21
+ readonly path: string;
22
+ readonly body: string | null;
23
+ readonly idempotencyKey: string;
24
+ readonly intentHash: string;
25
+ readonly grantId?: string;
26
+ readonly decisionId?: string;
27
+ readonly claimAttestation?: string;
28
+ }
29
+ /** What a downstream may insist the signature cover before it acts. */
30
+ export interface SignedRequestVerification {
31
+ /**
32
+ * Components that must be among the covered ones. A system of record that
33
+ * effects anything requires the grant pair and the attestation; a read that
34
+ * effects nothing may accept the base alone. The base is always required.
35
+ */
36
+ readonly require?: readonly SignedComponent[];
37
+ }
38
+ /**
39
+ * RFC 9421 HTTP message signatures with an RFC 9530 content digest. The base
40
+ * always covers the method, the path, the body's digest, the idempotency key
41
+ * and the intent hash, so the downstream can prove that this process,
42
+ * holding this key, sent this request for this intent. A dispatch also
43
+ * covers the grant id and the decision id, and, when the authority attested
44
+ * the claim, the attestation itself: then the downstream can prove that the
45
+ * authority claimed this grant for this intent, which is the difference
46
+ * between refusing an unsigned instruction and refusing an unauthorized one.
47
+ *
48
+ * `signature-input` names exactly what was covered, and the verifier rebuilds
49
+ * from that rather than from a fixed list: a request that carries a grant
50
+ * header the signature does not cover proves nothing about that grant. The
51
+ * handler must send every covered header with the value it asked the
52
+ * credential to sign; the reference handlers do. Ed25519 or HMAC-SHA256;
53
+ * the key is a secret handle read at each request.
54
+ */
55
+ export declare class SignedRequestCredential implements DownstreamCredential {
56
+ private readonly options;
57
+ private readonly key;
58
+ private readonly clock;
59
+ readonly kind: "SIGNED_REQUEST";
60
+ constructor(options: SignedRequestOptions, key: () => SecretHandle, clock?: () => number);
61
+ /** The RFC 9530 digest of a body, the empty body included. */
62
+ static contentDigest(body: string | null): string;
63
+ /** The components this material can cover, in base order. */
64
+ static componentsFor(material: SignedRequestMaterial): readonly SignedComponent[];
65
+ /** The signature parameters, as they appear in `signature-input` and at the base's end. */
66
+ static parameters(created: number, keyId: string, algorithm: SignedRequestAlgorithm, components?: readonly SignedComponent[]): string;
67
+ /** The covered components a `signature-input` names, or null when it names one this credential does not know. */
68
+ static coveredComponents(parameters: string): readonly SignedComponent[] | null;
69
+ /** One line of the base, or null when the material cannot supply the component. */
70
+ private static line;
71
+ /**
72
+ * The signature base, exactly as both sides must build it: one line per
73
+ * covered component in the order `parameters` lists them, then the
74
+ * parameters. Null when the parameters name a component the material does
75
+ * not have, which on the signing side is a bug and on the verifying side
76
+ * is a request that does not carry what its signature claims to cover.
77
+ */
78
+ static base(material: SignedRequestMaterial, parameters: string): string | null;
79
+ /**
80
+ * What the downstream runs: read which components the signature covers,
81
+ * refuse if any it requires is missing, rebuild the base from the request
82
+ * it received, then check the signature with the public key (Ed25519) or
83
+ * the shared secret (HMAC-SHA256). The base five are always required; a
84
+ * system of record passes the grant pair and the attestation too.
85
+ *
86
+ * The base is built from `material`, which is what the downstream will act
87
+ * on. A header that says something else is not checked separately: if the
88
+ * two disagree, the base differs from the one that was signed and the
89
+ * signature fails, which is the refusal that matters.
90
+ */
91
+ static verify(material: SignedRequestMaterial, headers: Readonly<Record<string, string>>, verifier: {
92
+ readonly publicKeyPem: string;
93
+ } | {
94
+ readonly secret: Uint8Array;
95
+ }, verification?: SignedRequestVerification): boolean;
96
+ /**
97
+ * The material a downstream rebuilds from the request it received. The
98
+ * grant fields come from the headers only when present, so a request that
99
+ * carries none is verified against the base and refused by a downstream
100
+ * that requires more.
101
+ */
102
+ static materialFrom(received: {
103
+ readonly method: string;
104
+ readonly path: string;
105
+ readonly body: string | null;
106
+ readonly headers: Readonly<Record<string, string>>;
107
+ }): SignedRequestMaterial;
108
+ /** The headers a handler must send beside the signature, with the values the signature covers. */
109
+ static coveredHeaders(request: DownstreamRequest): Readonly<Record<string, string>>;
110
+ headersFor(request: DownstreamRequest): Promise<Readonly<Record<string, string>>>;
111
+ }
112
+ //# sourceMappingURL=SignedRequestCredential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SignedRequestCredential.d.ts","sourceRoot":"","sources":["../../src/credential/SignedRequestCredential.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAEzF,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,aAAa,CAAC;AAE/D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,C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AkG;WACpF,cAAc,CAAC,OAAO,EAAE,iBAAiB,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAgB7E,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAmC/F"}
@@ -0,0 +1,255 @@
1
+ import { createHash, createHmac, createPrivateKey, createPublicKey, sign, timingSafeEqual, verify, } from "node:crypto";
2
+ /** Covered on every request: what was sent, to where, for which intent. */
3
+ export const BASE_COMPONENTS = [
4
+ "@method",
5
+ "@path",
6
+ "content-digest",
7
+ "idempotency-key",
8
+ "x-agent-safe-intent-hash",
9
+ ];
10
+ /** Covered on a dispatch: which grant, and which decision, this request executes under. */
11
+ export const GRANT_COMPONENTS = ["x-agent-safe-grant-id", "x-agent-safe-decision-id"];
12
+ /** Covered when the authority attested the claim: its proof, bound to this request. */
13
+ export const ATTESTATION_COMPONENT = "x-agent-safe-claim-attestation";
14
+ /** Every component this credential can cover, in the order the base lists them. */
15
+ export const SIGNED_COMPONENTS = [
16
+ ...BASE_COMPONENTS,
17
+ ...GRANT_COMPONENTS,
18
+ ATTESTATION_COMPONENT,
19
+ ];
20
+ export const SIGNATURE_LABEL = "agentsafe";
21
+ const COMPONENT_LIST = /^\(((?:"[^"]+"(?: |(?=\))))*)\)/;
22
+ /** `signature-input`: this credential's label, then the parameters from their opening parenthesis. */
23
+ const SIGNATURE_INPUT = /^agentsafe=(\(.*)/;
24
+ /** `signature`: this credential's label, then the base64 signature between colons. */
25
+ const SIGNATURE = /^agentsafe=:(.*):$/;
26
+ /**
27
+ * RFC 9421 HTTP message signatures with an RFC 9530 content digest. The base
28
+ * always covers the method, the path, the body's digest, the idempotency key
29
+ * and the intent hash, so the downstream can prove that this process,
30
+ * holding this key, sent this request for this intent. A dispatch also
31
+ * covers the grant id and the decision id, and, when the authority attested
32
+ * the claim, the attestation itself: then the downstream can prove that the
33
+ * authority claimed this grant for this intent, which is the difference
34
+ * between refusing an unsigned instruction and refusing an unauthorized one.
35
+ *
36
+ * `signature-input` names exactly what was covered, and the verifier rebuilds
37
+ * from that rather than from a fixed list: a request that carries a grant
38
+ * header the signature does not cover proves nothing about that grant. The
39
+ * handler must send every covered header with the value it asked the
40
+ * credential to sign; the reference handlers do. Ed25519 or HMAC-SHA256;
41
+ * the key is a secret handle read at each request.
42
+ */
43
+ export class SignedRequestCredential {
44
+ options;
45
+ key;
46
+ clock;
47
+ kind = "SIGNED_REQUEST";
48
+ constructor(options, key, clock = () => Date.now()) {
49
+ this.options = options;
50
+ this.key = key;
51
+ this.clock = clock;
52
+ }
53
+ /** The RFC 9530 digest of a body, the empty body included. */
54
+ static contentDigest(body) {
55
+ return `sha-256=:${createHash("sha256")
56
+ .update(body ?? "")
57
+ .digest("base64")}:`;
58
+ }
59
+ /** The components this material can cover, in base order. */
60
+ static componentsFor(material) {
61
+ const covered = [...BASE_COMPONENTS];
62
+ if (material.grantId !== undefined && material.decisionId !== undefined) {
63
+ covered.push(...GRANT_COMPONENTS);
64
+ if (material.claimAttestation !== undefined)
65
+ covered.push(ATTESTATION_COMPONENT);
66
+ }
67
+ return covered;
68
+ }
69
+ /** The signature parameters, as they appear in `signature-input` and at the base's end. */
70
+ static parameters(created, keyId, algorithm, components = BASE_COMPONENTS) {
71
+ const list = components.map((component) => `"${component}"`).join(" ");
72
+ return `(${list});created=${created};keyid="${keyId}";alg="${algorithm}"`;
73
+ }
74
+ /** The covered components a `signature-input` names, or null when it names one this credential does not know. */
75
+ static coveredComponents(parameters) {
76
+ const list = COMPONENT_LIST.exec(parameters)?.[1];
77
+ if (list === undefined)
78
+ return null;
79
+ const names = list.length === 0 ? [] : list.split(" ").map((quoted) => quoted.slice(1, -1));
80
+ const known = new Set(SIGNED_COMPONENTS);
81
+ if (names.some((name) => !known.has(name)) || new Set(names).size !== names.length)
82
+ return null;
83
+ return names;
84
+ }
85
+ /** One line of the base, or null when the material cannot supply the component. */
86
+ static line(component, material) {
87
+ switch (component) {
88
+ case "@method":
89
+ return `"@method": ${material.method.toUpperCase()}`;
90
+ case "@path":
91
+ return `"@path": ${material.path}`;
92
+ case "content-digest":
93
+ return `"content-digest": ${SignedRequestCredential.contentDigest(material.body)}`;
94
+ case "idempotency-key":
95
+ return `"idempotency-key": ${material.idempotencyKey}`;
96
+ case "x-agent-safe-intent-hash":
97
+ return `"x-agent-safe-intent-hash": ${material.intentHash}`;
98
+ case "x-agent-safe-grant-id":
99
+ return material.grantId === undefined
100
+ ? null
101
+ : `"x-agent-safe-grant-id": ${material.grantId}`;
102
+ case "x-agent-safe-decision-id":
103
+ return material.decisionId === undefined
104
+ ? null
105
+ : `"x-agent-safe-decision-id": ${material.decisionId}`;
106
+ case "x-agent-safe-claim-attestation":
107
+ return material.claimAttestation === undefined
108
+ ? null
109
+ : `"x-agent-safe-claim-attestation": ${material.claimAttestation}`;
110
+ }
111
+ }
112
+ /**
113
+ * The signature base, exactly as both sides must build it: one line per
114
+ * covered component in the order `parameters` lists them, then the
115
+ * parameters. Null when the parameters name a component the material does
116
+ * not have, which on the signing side is a bug and on the verifying side
117
+ * is a request that does not carry what its signature claims to cover.
118
+ */
119
+ static base(material, parameters) {
120
+ const components = SignedRequestCredential.coveredComponents(parameters);
121
+ if (components === null)
122
+ return null;
123
+ const lines = [];
124
+ for (const component of components) {
125
+ const line = SignedRequestCredential.line(component, material);
126
+ if (line === null)
127
+ return null;
128
+ lines.push(line);
129
+ }
130
+ lines.push(`"@signature-params": ${parameters}`);
131
+ return lines.join("\n");
132
+ }
133
+ /**
134
+ * What the downstream runs: read which components the signature covers,
135
+ * refuse if any it requires is missing, rebuild the base from the request
136
+ * it received, then check the signature with the public key (Ed25519) or
137
+ * the shared secret (HMAC-SHA256). The base five are always required; a
138
+ * system of record passes the grant pair and the attestation too.
139
+ *
140
+ * The base is built from `material`, which is what the downstream will act
141
+ * on. A header that says something else is not checked separately: if the
142
+ * two disagree, the base differs from the one that was signed and the
143
+ * signature fails, which is the refusal that matters.
144
+ */
145
+ static verify(material, headers, verifier, verification = {}) {
146
+ // Stryker disable next-line StringLiteral: an absent header and a string that is not this credential's parse the same, to nothing; the fallback satisfies the type.
147
+ const header = (name) => headers[name] ?? "";
148
+ // A `signature-input` that does not carry the label yields no covered
149
+ // list, which is the refusal below; the parameters need no check of
150
+ // their own.
151
+ // Stryker disable next-line StringLiteral: a non-match and any string that is not a component list parse the same, to nothing; the fallback satisfies the type.
152
+ const parameters = SIGNATURE_INPUT.exec(header("signature-input"))?.[1] ?? "";
153
+ const encoded = SIGNATURE.exec(header("signature"))?.[1];
154
+ if (encoded === undefined)
155
+ return false;
156
+ if (header("content-digest") !== SignedRequestCredential.contentDigest(material.body)) {
157
+ return false;
158
+ }
159
+ const covered = SignedRequestCredential.coveredComponents(parameters);
160
+ if (covered === null)
161
+ return false;
162
+ for (const component of [...BASE_COMPONENTS, ...(verification.require ?? [])]) {
163
+ if (!covered.includes(component))
164
+ return false;
165
+ }
166
+ const built = SignedRequestCredential.base(material, parameters);
167
+ if (built === null)
168
+ return false;
169
+ const base = Buffer.from(built);
170
+ const bytes = Buffer.from(encoded, "base64");
171
+ switch (/;alg="([a-z0-9-]+)"/.exec(parameters)?.[1]) {
172
+ case "ed25519":
173
+ return ("publicKeyPem" in verifier &&
174
+ verify(null, base, createPublicKey(verifier.publicKeyPem), bytes));
175
+ case "hmac-sha256": {
176
+ if (!("secret" in verifier))
177
+ return false;
178
+ const expected = createHmac("sha256", verifier.secret).update(base).digest();
179
+ // A MAC is compared in constant time, and only at its own length: a
180
+ // signature of another length is not a MAC over this base at all.
181
+ return bytes.length === expected.length && timingSafeEqual(expected, bytes);
182
+ }
183
+ default:
184
+ return false;
185
+ }
186
+ }
187
+ /**
188
+ * The material a downstream rebuilds from the request it received. The
189
+ * grant fields come from the headers only when present, so a request that
190
+ * carries none is verified against the base and refused by a downstream
191
+ * that requires more.
192
+ */
193
+ static materialFrom(received) {
194
+ const { headers } = received;
195
+ const grantId = headers["x-agent-safe-grant-id"];
196
+ const decisionId = headers["x-agent-safe-decision-id"];
197
+ const claimAttestation = headers["x-agent-safe-claim-attestation"];
198
+ return {
199
+ method: received.method,
200
+ path: received.path,
201
+ body: received.body,
202
+ idempotencyKey: headers["idempotency-key"] ?? "",
203
+ intentHash: headers["x-agent-safe-intent-hash"] ?? "",
204
+ ...(grantId === undefined ? {} : { grantId }),
205
+ ...(decisionId === undefined ? {} : { decisionId }),
206
+ ...(claimAttestation === undefined ? {} : { claimAttestation }),
207
+ };
208
+ }
209
+ /** The headers a handler must send beside the signature, with the values the signature covers. */
210
+ static coveredHeaders(request) {
211
+ return {
212
+ "idempotency-key": request.idempotencyKey,
213
+ "x-agent-safe-intent-hash": request.intentHash,
214
+ ...(request.grant === undefined
215
+ ? {}
216
+ : {
217
+ "x-agent-safe-grant-id": request.grant.id,
218
+ "x-agent-safe-decision-id": request.grant.decisionId,
219
+ ...(request.grant.claimAttestation === undefined
220
+ ? {}
221
+ : { "x-agent-safe-claim-attestation": request.grant.claimAttestation }),
222
+ }),
223
+ };
224
+ }
225
+ async headersFor(request) {
226
+ const created = Math.floor(this.clock() / 1_000);
227
+ // The material is exactly what the covered headers will say, read the way
228
+ // a downstream reads them, so the two sides cannot drift.
229
+ const covered = SignedRequestCredential.coveredHeaders(request);
230
+ const material = SignedRequestCredential.materialFrom({
231
+ method: request.method,
232
+ path: new URL(request.url).pathname,
233
+ body: request.body,
234
+ headers: covered,
235
+ });
236
+ const parameters = SignedRequestCredential.parameters(created, this.options.keyId, this.options.algorithm, SignedRequestCredential.componentsFor(material));
237
+ // The components were chosen from this material one line up, so every one
238
+ // resolves; the branch exists so the type narrows, not because it can run.
239
+ const built = SignedRequestCredential.base(material, parameters);
240
+ // Stryker disable next-line all: unreachable by construction, and a test that reached it would be testing the type checker.
241
+ if (built === null)
242
+ throw new Error("SIGNED_REQUEST_BASE_UNBUILDABLE");
243
+ const base = Buffer.from(built);
244
+ const signature = this.key().use((material) => this.options.algorithm === "ed25519"
245
+ ? sign(null, base, createPrivateKey(material))
246
+ : createHmac("sha256", material).update(base).digest());
247
+ return await Promise.resolve({
248
+ ...covered,
249
+ "content-digest": SignedRequestCredential.contentDigest(request.body),
250
+ "signature-input": `${SIGNATURE_LABEL}=${parameters}`,
251
+ signature: `${SIGNATURE_LABEL}=:${signature.toString("base64")}:`,
252
+ });
253
+ }
254
+ }
255
+ //# sourceMappingURL=SignedRequestCredential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SignedRequestCredential.js","sourceRoot":"","sources":["../../src/credential/SignedRequestCredential.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,eAAe,EACf,IAAI,EACJ,eAAe,EACf,MAAM,GACP,MAAM,aAAa,CAAC;AAWrB,2EAA2E;AAC3E,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,SAAS;IACT,OAAO;IACP,gBAAgB;IAChB,iBAAiB;IACjB,0BAA0B;CAClB,CAAC;AAEX,2FAA2F;AAC3F,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,uBAAuB,EAAE,0BAA0B,CAAU,CAAC;AAE/F,uFAAuF;AACvF,MAAM,CAAC,MAAM,qBAAqB,GAAG,gCAAyC,CAAC;AAE/E,mFAAmF;AACnF,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,GAAG,eAAe;IAClB,GAAG,gBAAgB;IACnB,qBAAqB;CACb,CAAC;AAIX,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAwB3C,MAAM,cAAc,GAAG,iCAAiC,CAAC;AACzD,sGAAsG;AACtG,MAAM,eAAe,GAAG,mBAAmB,CAAC;AAC5C,sFAAsF;AACtF,MAAM,SAAS,GAAG,oBAAoB,CAAC;AAEvC;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,OAAO,uBAAuB;IAIf;IACA;IACA;IALH,IAAI,GAAG,gBAAyB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UAAU,CACnD,OAAO,EACP,IAAI,CAAC,OAAO,CAAC,KAAK,EAClB,IAAI,CAAC,OAAO,CAAC,SAAS,EACtB,uBAAuB,CAAC,aAAa,CAAC,QAAQ,CAAC,CAChD,CAAC;QACF,0EAA0E;QAC1E,2EAA2E;QAC3E,MAAM,KAAK,GAAG,uBAAuB,CAAC,IAAI,CAAC,QAAQ,EAAE,UAAU,CAAC,CAAC;QACjE,4HAA4H;QAC5H,IAAI,KAAK,KAAK,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;QACvE,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAChC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAC5C,IAAI,CAAC,OAAO,CAAC,SAAS,KAAK,SAAS;YAClC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,gBAAgB,CAAC,QAAQ,CAAC,CAAC;YAC9C,CAAC,CAAC,UAAU,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,CACzD,CAAC;QACF,OAAO,MAAM,OAAO,CAAC,OAAO,CAAC;YAC3B,GAAG,OAAO;YACV,gBAAgB,EAAE,uBAAuB,CAAC,aAAa,CAAC,OAAO,CAAC,IAAI,CAAC;YACrE,iBAAiB,EAAE,GAAG,eAAe,IAAI,UAAU,EAAE;YACrD,SAAS,EAAE,GAAG,eAAe,KAAK,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAAG;SAClE,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,16 @@
1
+ import type { SecretHandle } from "../secrets/SecretHandle.js";
2
+ import type { DownstreamCredential } from "./DownstreamCredential.js";
3
+ /**
4
+ * The downstream expects one header carrying a static value, prefix included,
5
+ * as the reference deployment does. The value is read from the current
6
+ * handle at each dispatch, so a rotated credential is used from the next
7
+ * request on, and the string exists only for the request that carries it.
8
+ */
9
+ export declare class StaticHeaderCredential implements DownstreamCredential {
10
+ private readonly headerName;
11
+ private readonly secret;
12
+ readonly kind = "STATIC_HEADER";
13
+ constructor(headerName: string, secret: () => SecretHandle);
14
+ headersFor(): Promise<Readonly<Record<string, string>>>;
15
+ }
16
+ //# sourceMappingURL=StaticHeaderCredential.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StaticHeaderCredential.d.ts","sourceRoot":"","sources":["../../src/credential/StaticHeaderCredential.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAEtE;;;;;GAKG;AACH,qBAAa,sBAAuB,YAAW,oBAAoB;IAI/D,OAAO,CAAC,QAAQ,CAAC,UAAU;IAC3B,OAAO,CAAC,QAAQ,CAAC,MAAM;IAJzB,SAAgB,IAAI,mBAAmB;gBAGpB,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,YAAY;IAGtC,UAAU,IAAI,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CAK/D"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The downstream expects one header carrying a static value, prefix included,
3
+ * as the reference deployment does. The value is read from the current
4
+ * handle at each dispatch, so a rotated credential is used from the next
5
+ * request on, and the string exists only for the request that carries it.
6
+ */
7
+ export class StaticHeaderCredential {
8
+ headerName;
9
+ secret;
10
+ kind = "STATIC_HEADER";
11
+ constructor(headerName, secret) {
12
+ this.headerName = headerName;
13
+ this.secret = secret;
14
+ }
15
+ headersFor() {
16
+ return Promise.resolve({
17
+ [this.headerName]: this.secret().use((value) => value.toString("utf8")),
18
+ });
19
+ }
20
+ }
21
+ //# sourceMappingURL=StaticHeaderCredential.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"StaticHeaderCredential.js","sourceRoot":"","sources":["../../src/credential/StaticHeaderCredential.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,MAAM,OAAO,sBAAsB;IAId;IACA;IAJH,IAAI,GAAG,eAAe,CAAC;IAEvC,YACmB,UAAkB,EAClB,MAA0B;QAD1B,eAAU,GAAV,UAAU,CAAQ;QAClB,WAAM,GAAN,MAAM,CAAoB;IAC1C,CAAC;IAEG,UAAU;QACf,OAAO,OAAO,CAAC,OAAO,CAAC;YACrB,CAAC,IAAI,CAAC,UAAU,CAAC,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;SACxE,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,13 @@
1
+ /** Every way the sealed egress refuses a request, as a stable code. */
2
+ export type EgressCode = "EGRESS_SCHEME_NOT_ALLOWED" | "EGRESS_ORIGIN_NOT_ALLOWED" | "EGRESS_PATH_NOT_ALLOWED" | "EGRESS_ADDRESS_REFUSED" | "EGRESS_TLS_REJECTED" | "EGRESS_TLS_PIN_MISMATCH" | "EGRESS_BODY_TOO_LARGE" | "EGRESS_TIMEOUT" | "EGRESS_REDIRECT_REFUSED" | "EGRESS_RESPONSE_INVALID" | "EGRESS_INIT_UNSUPPORTED" | "EGRESS_GLOBAL_FETCH_LOCKED";
3
+ /**
4
+ * A refusal by the executor's own egress policy: the code, and the origin it
5
+ * concerned. Never the path, the headers, or anything from the request or
6
+ * the response.
7
+ */
8
+ export declare class EgressError extends Error {
9
+ readonly code: EgressCode;
10
+ readonly origin: string | null;
11
+ constructor(code: EgressCode, origin?: string | null);
12
+ }
13
+ //# sourceMappingURL=EgressError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EgressError.d.ts","sourceRoot":"","sources":["../../src/egress/EgressError.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,MAAM,MAAM,UAAU,GAClB,2BAA2B,GAC3B,2BAA2B,GAC3B,yBAAyB,GACzB,wBAAwB,GACxB,qBAAqB,GACrB,yBAAyB,GACzB,uBAAuB,GACvB,gBAAgB,GAChB,yBAAyB,GACzB,yBAAyB,GACzB,yBAAyB,GACzB,4BAA4B,CAAC;AAEjC;;;;GAIG;AACH,qBAAa,WAAY,SAAQ,KAAK;aAElB,IAAI,EAAE,UAAU;aAChB,MAAM,EAAE,MAAM,GAAG,IAAI;gBADrB,IAAI,EAAE,UAAU,EAChB,MAAM,GAAE,MAAM,GAAG,IAAW;CAK/C"}
@@ -0,0 +1,16 @@
1
+ /**
2
+ * A refusal by the executor's own egress policy: the code, and the origin it
3
+ * concerned. Never the path, the headers, or anything from the request or
4
+ * the response.
5
+ */
6
+ export class EgressError extends Error {
7
+ code;
8
+ origin;
9
+ constructor(code, origin = null) {
10
+ super(code);
11
+ this.code = code;
12
+ this.origin = origin;
13
+ this.name = "EgressError";
14
+ }
15
+ }
16
+ //# sourceMappingURL=EgressError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EgressError.js","sourceRoot":"","sources":["../../src/egress/EgressError.ts"],"names":[],"mappings":"AAeA;;;;GAIG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAElB;IACA;IAFlB,YACkB,IAAgB,EAChB,SAAwB,IAAI;QAE5C,KAAK,CAAC,IAAI,CAAC,CAAC;QAHI,SAAI,GAAJ,IAAI,CAAY;QAChB,WAAM,GAAN,MAAM,CAAsB;QAG5C,IAAI,CAAC,IAAI,GAAG,aAAa,CAAC;IAC5B,CAAC;CACF"}
@@ -0,0 +1,55 @@
1
+ import type { ExecutorConfig } from "../config/ExecutorConfig.js";
2
+ import type { EgressCode } from "./EgressError.js";
3
+ /** One origin this process may reach, the paths under it, and how it is trusted. */
4
+ export interface EgressDestination {
5
+ readonly origin: string;
6
+ readonly pathPrefixes: readonly string[];
7
+ /** The PEM bundle to verify the peer against; the platform's store when null. */
8
+ readonly ca: string | null;
9
+ readonly pins: readonly string[];
10
+ }
11
+ export type EgressCheck = {
12
+ readonly allowed: true;
13
+ readonly destination: EgressDestination;
14
+ } | {
15
+ readonly allowed: false;
16
+ readonly code: EgressCode;
17
+ };
18
+ /**
19
+ * The sealed allowlist of where this process may open a connection: the
20
+ * authority, the Presence service when this process holds that credential,
21
+ * and the downstream and its lookup, each with the path prefix the
22
+ * configuration named and the trust anchor it declared. Nothing is added at
23
+ * run time; a handler that reaches elsewhere is refused before a socket
24
+ * exists. Private address ranges are allowed by design, because that is
25
+ * where an institution's systems live; what a configured name must never
26
+ * resolve to is this host, the link, multicast, or nowhere.
27
+ */
28
+ export declare class EgressPolicy {
29
+ private readonly destinations;
30
+ constructor(destinations: readonly EgressDestination[]);
31
+ /** The policy a configuration implies; CA bundles are read once, here. */
32
+ static fromConfig(config: ExecutorConfig, readFile: (path: string) => string): EgressPolicy;
33
+ get origins(): readonly string[];
34
+ /** Scheme, origin, then path, in that order; the first failure is the answer. */
35
+ check(url: URL): EgressCheck;
36
+ /** The prefix itself, or anything below it as a path segment; never a sibling that merely shares characters. */
37
+ static underPrefix(pathname: string, prefix: string): boolean;
38
+ /**
39
+ * Whether a resolved address may be connected to for an origin. A loopback
40
+ * origin must stay on this host; any other must never resolve to this
41
+ * host, the link, multicast, or nowhere. The lists are built per call so
42
+ * that nothing about them is decided at module load.
43
+ */
44
+ static addressRefused(address: string, loopbackOrigin: boolean): boolean;
45
+ /** The three loopback spellings the configuration accepts. */
46
+ static isLoopbackHost(hostname: string): boolean;
47
+ /** The origin the configuration named, exactly as the URL class spells it. */
48
+ static originOf(url: string): string;
49
+ /** The path the configuration named, cut at a placeholder such as `{idempotency_key}`. */
50
+ static prefixOf(url: string): string;
51
+ /** `sha256/<base64>` over a DER SubjectPublicKeyInfo: the pin form the configuration takes. */
52
+ static spkiPin(spki: Uint8Array): string;
53
+ private static bundle;
54
+ }
55
+ //# sourceMappingURL=EgressPolicy.d.ts.map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