@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,93 @@
1
+ import type { OperatorScope } from "../identity/PrincipalsFile.js";
2
+ import type { Role } from "../identity/PrincipalRegistry.js";
3
+ /** The payload limit on every route, in bytes. */
4
+ export declare const MAX_BODY_BYTES: number;
5
+ export interface RouteDefinition {
6
+ readonly method: "GET" | "POST";
7
+ readonly path: string;
8
+ /** Public routes answer without a principal; they carry no state. */
9
+ readonly public: boolean;
10
+ /** The role a principal must hold to reach the route; absent on public routes. */
11
+ readonly role?: Role;
12
+ /** The scope an operator must hold, on control routes. */
13
+ readonly scope?: OperatorScope;
14
+ }
15
+ /** The whole surface. The README's table is checked against this list. */
16
+ export declare const ROUTES: readonly [{
17
+ readonly method: "GET";
18
+ readonly path: "/health";
19
+ readonly public: true;
20
+ }, {
21
+ readonly method: "GET";
22
+ readonly path: "/ready";
23
+ readonly public: true;
24
+ }, {
25
+ readonly method: "POST";
26
+ readonly path: "/v1/actions";
27
+ readonly public: false;
28
+ readonly role: "PROPOSER";
29
+ }, {
30
+ readonly method: "POST";
31
+ readonly path: "/v1/reconciliations";
32
+ readonly public: false;
33
+ readonly role: "PROPOSER";
34
+ }, {
35
+ readonly method: "POST";
36
+ readonly path: "/v1/escalations";
37
+ readonly public: false;
38
+ readonly role: "PROPOSER";
39
+ }, {
40
+ readonly method: "GET";
41
+ readonly path: "/v1/control/status";
42
+ readonly public: false;
43
+ readonly role: "OPERATOR";
44
+ readonly scope: "status";
45
+ }, {
46
+ readonly method: "POST";
47
+ readonly path: "/v1/control/halt";
48
+ readonly public: false;
49
+ readonly role: "OPERATOR";
50
+ readonly scope: "halt";
51
+ }, {
52
+ readonly method: "POST";
53
+ readonly path: "/v1/control/resume";
54
+ readonly public: false;
55
+ readonly role: "OPERATOR";
56
+ readonly scope: "resume";
57
+ }, {
58
+ readonly method: "GET";
59
+ readonly path: "/v1/control/open-attempts";
60
+ readonly public: false;
61
+ readonly role: "OPERATOR";
62
+ readonly scope: "status";
63
+ }, {
64
+ readonly method: "POST";
65
+ readonly path: "/v1/control/secrets/reload";
66
+ readonly public: false;
67
+ readonly role: "OPERATOR";
68
+ readonly scope: "secrets.reload";
69
+ }, {
70
+ readonly method: "POST";
71
+ readonly path: "/v1/control/evidence-export";
72
+ readonly public: false;
73
+ readonly role: "OPERATOR";
74
+ readonly scope: "evidence";
75
+ }, {
76
+ readonly method: "GET";
77
+ readonly path: "/metrics";
78
+ readonly public: false;
79
+ readonly role: "OPERATOR";
80
+ readonly scope: "metrics";
81
+ }];
82
+ export type RoutePath = (typeof ROUTES)[number]["path"];
83
+ /** The exposition's content type; every other response is JSON. */
84
+ export declare const METRICS_CONTENT_TYPE = "application/openmetrics-text; version=1.0.0; charset=utf-8";
85
+ /** Every response, success or refusal, carries the same protective headers. */
86
+ export declare const RESPONSE_HEADERS: {
87
+ readonly "content-type": "application/json; charset=utf-8";
88
+ readonly "cache-control": "no-store";
89
+ readonly "x-content-type-options": "nosniff";
90
+ readonly "content-security-policy": "default-src 'none'; frame-ancestors 'none'";
91
+ readonly "x-frame-options": "DENY";
92
+ };
93
+ //# sourceMappingURL=Routes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Routes.d.ts","sourceRoot":"","sources":["../../src/http/Routes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAC;AACnE,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,kCAAkC,CAAC;AAE7D,kDAAkD;AAClD,eAAO,MAAM,cAAc,QAAa,CAAC;AAEzC,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,MAAM,EAAE,KAAK,GAAG,MAAM,CAAC;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qEAAqE;IACrE,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC;IACzB,kFAAkF;IAClF,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,CAAC;IACrB,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,CAAC,EAAE,aAAa,CAAC;CAChC;AAED,0EAA0E;AAC1E,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA+B4B,CAAC;AAEhD,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC;AAExD,mEAAmE;AACnE,eAAO,MAAM,oBAAoB,+DAA+D,CAAC;AAEjG,+EAA+E;AAC/E,eAAO,MAAM,gBAAgB;;;;;;CAMnB,CAAC"}
@@ -0,0 +1,46 @@
1
+ /** The payload limit on every route, in bytes. */
2
+ export const MAX_BODY_BYTES = 100 * 1024;
3
+ /** The whole surface. The README's table is checked against this list. */
4
+ export const ROUTES = [
5
+ { method: "GET", path: "/health", public: true },
6
+ { method: "GET", path: "/ready", public: true },
7
+ { method: "POST", path: "/v1/actions", public: false, role: "PROPOSER" },
8
+ { method: "POST", path: "/v1/reconciliations", public: false, role: "PROPOSER" },
9
+ { method: "POST", path: "/v1/escalations", public: false, role: "PROPOSER" },
10
+ { method: "GET", path: "/v1/control/status", public: false, role: "OPERATOR", scope: "status" },
11
+ { method: "POST", path: "/v1/control/halt", public: false, role: "OPERATOR", scope: "halt" },
12
+ { method: "POST", path: "/v1/control/resume", public: false, role: "OPERATOR", scope: "resume" },
13
+ {
14
+ method: "GET",
15
+ path: "/v1/control/open-attempts",
16
+ public: false,
17
+ role: "OPERATOR",
18
+ scope: "status",
19
+ },
20
+ {
21
+ method: "POST",
22
+ path: "/v1/control/secrets/reload",
23
+ public: false,
24
+ role: "OPERATOR",
25
+ scope: "secrets.reload",
26
+ },
27
+ {
28
+ method: "POST",
29
+ path: "/v1/control/evidence-export",
30
+ public: false,
31
+ role: "OPERATOR",
32
+ scope: "evidence",
33
+ },
34
+ { method: "GET", path: "/metrics", public: false, role: "OPERATOR", scope: "metrics" },
35
+ ];
36
+ /** The exposition's content type; every other response is JSON. */
37
+ export const METRICS_CONTENT_TYPE = "application/openmetrics-text; version=1.0.0; charset=utf-8";
38
+ /** Every response, success or refusal, carries the same protective headers. */
39
+ export const RESPONSE_HEADERS = {
40
+ "content-type": "application/json; charset=utf-8",
41
+ "cache-control": "no-store",
42
+ "x-content-type-options": "nosniff",
43
+ "content-security-policy": "default-src 'none'; frame-ancestors 'none'",
44
+ "x-frame-options": "DENY",
45
+ };
46
+ //# sourceMappingURL=Routes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Routes.js","sourceRoot":"","sources":["../../src/http/Routes.ts"],"names":[],"mappings":"AAGA,kDAAkD;AAClD,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,GAAG,IAAI,CAAC;AAazC,0EAA0E;AAC1E,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE;IAChD,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE;IAC/C,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE;IACxE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE;IAChF,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,UAAU,EAAE;IAC5E,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,oBAAoB,EA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{ SecurityEvents } from "../incident/SecurityEvents.js";
4
+ import type { SecretHandle } from "../secrets/SecretHandle.js";
5
+ export type TlsMinVersion = "TLSv1.2" | "TLSv1.3";
6
+ /** What the listener presents and, when a client CA is set, what it asks for. */
7
+ export interface TlsMaterial {
8
+ readonly cert: string;
9
+ readonly key: SecretHandle;
10
+ readonly clientCa: string | null;
11
+ }
12
+ export interface TlsListenerOptions {
13
+ readonly minVersion: TlsMinVersion;
14
+ /** Read at construction and at every rotation: the certificate, the key handle, the client CA. */
15
+ readonly material: () => TlsMaterial;
16
+ readonly events: SecurityEvents;
17
+ }
18
+ /** For TLS 1.2 only: ECDHE with an AEAD cipher; TLS 1.3 has nothing else to offer. */
19
+ export declare const TLS12_CIPHERS: string;
20
+ /**
21
+ * The TLS listener: TLS 1.3 by default, 1.2 only with AEAD ciphers, no
22
+ * renegotiation, HTTP/1.1 only. When a client CA is configured every
23
+ * connection is asked for a certificate, but the handshake admits a client
24
+ * without one deliberately, because the kubelet's HTTPS probes present
25
+ * none; the door then requires `socket.authorized` on every route that is
26
+ * not public, so a probe reaches `/health` and nothing else. The context is
27
+ * replaced in place when the key rotates, and connections already open keep
28
+ * the context they negotiated.
29
+ */
30
+ export declare class TlsListener {
31
+ private readonly options;
32
+ readonly mutual: boolean;
33
+ constructor(options: TlsListenerOptions);
34
+ createServer(handler: RequestListener): Server;
35
+ rotate(server: Server): void;
36
+ private context;
37
+ }
38
+ //# sourceMappingURL=TlsListener.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TlsListener.d.ts","sourceRoot":"","sources":["../../src/http/TlsListener.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAgB,KAAK,MAAM,EAAsB,MAAM,YAAY,CAAC;AAC3E,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAE/D,MAAM,MAAM,aAAa,GAAG,SAAS,GAAG,SAAS,CAAC;AAElD,iFAAiF;AACjF,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,EAAE,YAAY,CAAC;IAC3B,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,UAAU,EAAE,aAAa,CAAC;IACnC,kGAAkG;IAClG,QAAQ,CAAC,QAAQ,EAAE,MAAM,WAAW,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CACjC;AAED,sFAAsF;AACtF,eAAO,MAAM,aAAa,QAOf,CAAC;AAEZ;;;;;;;;;GASG;AACH,qBAAa,WAAW;IAGH,OAAO,CAAC,QAAQ,CAAC,OAAO;IAF3C,SAAgB,MAAM,EAAE,OAAO,CAAC;gBAEI,OAAO,EAAE,kBAAkB;IAIxD,YAAY,CAAC,OAAO,EAAE,eAAe,GAAG,MAAM;IAI9C,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAKnC,OAAO,CAAC,OAAO;CAehB"}
@@ -0,0 +1,52 @@
1
+ import { constants } from "node:crypto";
2
+ import { createServer } from "node:https";
3
+ /** For TLS 1.2 only: ECDHE with an AEAD cipher; TLS 1.3 has nothing else to offer. */
4
+ export const TLS12_CIPHERS = [
5
+ "ECDHE-ECDSA-AES256-GCM-SHA384",
6
+ "ECDHE-RSA-AES256-GCM-SHA384",
7
+ "ECDHE-ECDSA-CHACHA20-POLY1305",
8
+ "ECDHE-RSA-CHACHA20-POLY1305",
9
+ "ECDHE-ECDSA-AES128-GCM-SHA256",
10
+ "ECDHE-RSA-AES128-GCM-SHA256",
11
+ ].join(":");
12
+ /**
13
+ * The TLS listener: TLS 1.3 by default, 1.2 only with AEAD ciphers, no
14
+ * renegotiation, HTTP/1.1 only. When a client CA is configured every
15
+ * connection is asked for a certificate, but the handshake admits a client
16
+ * without one deliberately, because the kubelet's HTTPS probes present
17
+ * none; the door then requires `socket.authorized` on every route that is
18
+ * not public, so a probe reaches `/health` and nothing else. The context is
19
+ * replaced in place when the key rotates, and connections already open keep
20
+ * the context they negotiated.
21
+ */
22
+ export class TlsListener {
23
+ options;
24
+ mutual;
25
+ constructor(options) {
26
+ this.options = options;
27
+ this.mutual = options.material().clientCa !== null;
28
+ }
29
+ createServer(handler) {
30
+ return createServer(this.context(), handler);
31
+ }
32
+ rotate(server) {
33
+ server.setSecureContext(this.context());
34
+ this.options.events.emit({ event: "TLS_CONTEXT_ROTATED" });
35
+ }
36
+ context() {
37
+ const material = this.options.material();
38
+ return material.key.use((key) => ({
39
+ cert: material.cert,
40
+ key,
41
+ ...(material.clientCa === null ? {} : { ca: material.clientCa, requestCert: true }),
42
+ rejectUnauthorized: false,
43
+ minVersion: this.options.minVersion,
44
+ maxVersion: "TLSv1.3",
45
+ ciphers: TLS12_CIPHERS,
46
+ honorCipherOrder: true,
47
+ secureOptions: constants.SSL_OP_NO_RENEGOTIATION,
48
+ ALPNProtocols: ["http/1.1"],
49
+ }));
50
+ }
51
+ }
52
+ //# sourceMappingURL=TlsListener.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TlsListener.js","sourceRoot":"","sources":["../../src/http/TlsListener.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,YAAY,EAAmC,MAAM,YAAY,CAAC;AAoB3E,sFAAsF;AACtF,MAAM,CAAC,MAAM,aAAa,GAAG;IAC3B,+BAA+B;IAC/B,6BAA6B;IAC7B,+BAA+B;IAC/B,6BAA6B;IAC7B,+BAA+B;IAC/B,6BAA6B;CAC9B,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAEZ;;;;;;;;;GASG;AACH,MAAM,OAAO,WAAW;IAGc;IAFpB,MAAM,CAAU;IAEhC,YAAoC,OAA2B;QAA3B,YAAO,GAAP,OAAO,CAAoB;QAC7D,IAAI,CAAC,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC,QAAQ,KAAK,IAAI,CAAC;IACrD,CAAC;IAEM,YAAY,CAAC,OAAwB;QAC1C,OAAO,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,OAAO,CAAC,CAAC;IAC/C,CAAC;IAEM,MAAM,CAAC,MAAc;QAC1B,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;QACxC,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,qBAAqB,EAAE,CAAC,CAAC;IAC7D,CAAC;IAEO,OAAO;QACb,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzC,OAAO,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;YAChC,IAAI,EAAE,QAAQ,CAAC,IAAI;YACnB,GAAG;YACH,GAAG,CAAC,QAAQ,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,EAAE,QAAQ,CAAC,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,CAAC;YACnF,kBAAkB,EAAE,KAAK;YACzB,UAAU,EAAE,IAAI,CAAC,OAAO,CAAC,UAAU;YACnC,UAAU,EAAE,SAAS;YACrB,OAAO,EAAE,aAAa;YACtB,gBAAgB,EAAE,IAAI;YACtB,aAAa,EAAE,SAAS,CAAC,uBAAuB;YAChD,aAAa,EAAE,CAAC,UAAU,CAAC;SAC5B,CAAC,CAAC,CAAC;IACN,CAAC;CACF"}
@@ -0,0 +1,58 @@
1
+ import type { RouteDefinition } from "../http/Routes.js";
2
+ import type { SecurityEvents } from "../incident/SecurityEvents.js";
3
+ import type { PeerIdentity } from "./PeerIdentity.js";
4
+ import type { Principal, PrincipalRegistry } from "./PrincipalRegistry.js";
5
+ import type { LockoutRule, RateLimiter, RateLimitRule } from "./RateLimiter.js";
6
+ import { type WorkloadJwtVerifier } from "./WorkloadJwtVerifier.js";
7
+ export type AuthMethod = "bearer" | "jwt" | "mtls" | "none";
8
+ export interface AuthenticationInput {
9
+ readonly authorization: string | undefined;
10
+ /** The client certificate the connection presented, or null when it presented none. */
11
+ readonly peer: PeerIdentity | null;
12
+ readonly route: RouteDefinition;
13
+ }
14
+ export interface AuthenticatedPrincipal {
15
+ readonly principal: Principal;
16
+ readonly method: AuthMethod;
17
+ }
18
+ /** A refusal at the door: a status and a code, never a message from the request. */
19
+ export declare class AuthError extends Error {
20
+ readonly status: number;
21
+ readonly code: string;
22
+ constructor(status: number, code: string);
23
+ }
24
+ export interface AuthenticatorOptions {
25
+ readonly registry: PrincipalRegistry;
26
+ readonly jwt: WorkloadJwtVerifier | null;
27
+ /** The executor's own audience; a principal may name its own instead. */
28
+ readonly audience: string | null;
29
+ readonly limits: RateLimiter;
30
+ readonly unauthenticated: RateLimitRule;
31
+ readonly lockout: LockoutRule | null;
32
+ /** Legacy mode with a client CA: every caller must present a certificate and the token. */
33
+ readonly requireCertificate: boolean;
34
+ readonly events: SecurityEvents;
35
+ }
36
+ /** The key of the one window for requests that never became a principal. */
37
+ export declare const UNAUTHENTICATED_KEY = "*";
38
+ /**
39
+ * The one chokepoint every non-public request passes, in a fixed,
40
+ * fail-closed order: the window for failed attempts; a certificate and a
41
+ * bearer together, which is ambiguous and refused; the certificate, by SAN
42
+ * URI and optional pin; the bearer, by digest across every bearer principal
43
+ * in constant time, then as a workload token; the lock, only once the
44
+ * principal is known so no lock is an existence oracle; the principal's
45
+ * own window; the route's role; the route's scope. Every refusal is one
46
+ * `AUTH_FAILED` event with the method and the code, and nothing else.
47
+ */
48
+ export declare class Authenticator {
49
+ private readonly options;
50
+ constructor(options: AuthenticatorOptions);
51
+ authenticate(input: AuthenticationInput): Promise<AuthenticatedPrincipal>;
52
+ private identify;
53
+ /** The bearer path alone: the digest scan, and nothing after it. */
54
+ private bearer;
55
+ private workload;
56
+ private static presented;
57
+ }
58
+ //# sourceMappingURL=Authenticator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Authenticator.d.ts","sourceRoot":"","sources":["../../src/identity/Authenticator.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AACpE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAChF,OAAO,EAAY,KAAK,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE9E,MAAM,MAAM,UAAU,GAAG,QAAQ,GAAG,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;AAE5D,MAAM,WAAW,mBAAmB;IAClC,QAAQ,CAAC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAC3C,uFAAuF;IACvF,QAAQ,CAAC,IAAI,EAAE,YAAY,GAAG,IAAI,CAAC;IACnC,QAAQ,CAAC,KAAK,EAAE,eAAe,CAAC;CACjC;AAED,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAC;CAC7B;AAED,oFAAoF;AACpF,qBAAa,SAAU,SAAQ,KAAK;aAEhB,MAAM,EAAE,MAAM;aACd,IAAI,EAAE,MAAM;gBADZ,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM;CAK/B;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,QAAQ,EAAE,iBAAiB,CAAC;IACrC,QAAQ,CAAC,GAAG,EAAE,mBAAmB,GAAG,IAAI,CAAC;IACzC,yEAAyE;IACzE,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,aAAa,CAAC;IACxC,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,IAAI,CAAC;IACrC,2FAA2F;IAC3F,QAAQ,CAAC,kBAAkB,EAAE,OAAO,CAAC;IACrC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;CACjC;AAED,4EAA4E;AAC5E,eAAO,MAAM,mBAAmB,MAAM,CAAC;AAavC;;;;;;;;;GASG;AACH,qBAAa,aAAa;IACL,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,oBAAoB;IAEpD,YAAY,CAAC,KAAK,EAAE,mBAAmB,GAAG,OAAO,CAAC,sBAAsB,CAAC;YAkBxE,QAAQ;IAiDtB,oEAAoE;IACpE,OAAO,CAAC,MAAM;YAMA,QAAQ;IAqCtB,OAAO,CAAC,MAAM,CAAC,SAAS;CAMzB"}
@@ -0,0 +1,170 @@
1
+ import { JwtError } from "./WorkloadJwtVerifier.js";
2
+ /** A refusal at the door: a status and a code, never a message from the request. */
3
+ export class AuthError extends Error {
4
+ status;
5
+ code;
6
+ constructor(status, code) {
7
+ super(code);
8
+ this.status = status;
9
+ this.code = code;
10
+ this.name = "AuthError";
11
+ }
12
+ }
13
+ /** The key of the one window for requests that never became a principal. */
14
+ export const UNAUTHENTICATED_KEY = "*";
15
+ const BEARER = "Bearer ";
16
+ const COMPACT_JWS = /^[\w-]+\.[\w-]+\.[\w-]+$/;
17
+ class Refusal {
18
+ status;
19
+ code;
20
+ method;
21
+ principal;
22
+ constructor(status, code, method, principal) {
23
+ this.status = status;
24
+ this.code = code;
25
+ this.method = method;
26
+ this.principal = principal;
27
+ }
28
+ }
29
+ /**
30
+ * The one chokepoint every non-public request passes, in a fixed,
31
+ * fail-closed order: the window for failed attempts; a certificate and a
32
+ * bearer together, which is ambiguous and refused; the certificate, by SAN
33
+ * URI and optional pin; the bearer, by digest across every bearer principal
34
+ * in constant time, then as a workload token; the lock, only once the
35
+ * principal is known so no lock is an existence oracle; the principal's
36
+ * own window; the route's role; the route's scope. Every refusal is one
37
+ * `AUTH_FAILED` event with the method and the code, and nothing else.
38
+ */
39
+ export class Authenticator {
40
+ options;
41
+ constructor(options) {
42
+ this.options = options;
43
+ }
44
+ async authenticate(input) {
45
+ try {
46
+ return await this.identify(input);
47
+ }
48
+ catch (error) {
49
+ if (!(error instanceof Refusal))
50
+ throw error;
51
+ this.options.events.emit({ event: "AUTH_FAILED", method: error.method, code: error.code });
52
+ if (error.principal === null) {
53
+ this.options.limits.allow(UNAUTHENTICATED_KEY, this.options.unauthenticated);
54
+ }
55
+ else if (error.status === 401) {
56
+ const locked = this.options.limits.recordFailure(error.principal.id, this.options.lockout);
57
+ if (locked) {
58
+ this.options.events.emit({ event: "PRINCIPAL_LOCKED", principal: error.principal.id });
59
+ }
60
+ }
61
+ throw new AuthError(error.status, error.code);
62
+ }
63
+ }
64
+ async identify(input) {
65
+ const { registry, limits } = this.options;
66
+ if (limits.exhausted(UNAUTHENTICATED_KEY, this.options.unauthenticated)) {
67
+ throw new Refusal(429, "RATE_LIMITED", "none", null);
68
+ }
69
+ let principal;
70
+ let method;
71
+ if (this.options.requireCertificate) {
72
+ if (input.peer === null || !input.peer.authorized) {
73
+ throw new Refusal(401, "CALLER_NOT_AUTHENTICATED", "mtls", null);
74
+ }
75
+ principal = this.bearer(input.authorization);
76
+ method = "bearer";
77
+ }
78
+ else if (input.peer !== null) {
79
+ if (input.authorization !== undefined) {
80
+ throw new Refusal(401, "AUTH_AMBIGUOUS", "none", null);
81
+ }
82
+ if (!input.peer.authorized)
83
+ throw new Refusal(401, "CALLER_NOT_AUTHENTICATED", "mtls", null);
84
+ const found = registry.byCertificate(input.peer.sanUris, input.peer.fingerprint);
85
+ if (found === null)
86
+ throw new Refusal(401, "CALLER_NOT_AUTHENTICATED", "mtls", null);
87
+ principal = found;
88
+ method = "mtls";
89
+ }
90
+ else {
91
+ const presented = Authenticator.presented(input.authorization);
92
+ const found = registry.byBearerDigest(presented);
93
+ if (found !== null) {
94
+ principal = found;
95
+ method = "bearer";
96
+ }
97
+ else {
98
+ if (this.options.jwt === null || !COMPACT_JWS.test(presented)) {
99
+ throw new Refusal(401, "CALLER_NOT_AUTHENTICATED", "bearer", null);
100
+ }
101
+ principal = await this.workload(this.options.jwt, presented);
102
+ method = "jwt";
103
+ }
104
+ }
105
+ if (limits.locked(principal.id))
106
+ throw new Refusal(423, "PRINCIPAL_LOCKED", method, principal);
107
+ if (principal.rateLimit !== null && !limits.allow(principal.id, principal.rateLimit)) {
108
+ throw new Refusal(429, "RATE_LIMITED", method, principal);
109
+ }
110
+ if (input.route.role !== principal.role) {
111
+ throw new Refusal(403, "ROLE_FORBIDDEN", method, principal);
112
+ }
113
+ if (input.route.scope !== undefined && !principal.scopes.has(input.route.scope)) {
114
+ throw new Refusal(403, "SCOPE_FORBIDDEN", method, principal);
115
+ }
116
+ return { principal, method };
117
+ }
118
+ /** The bearer path alone: the digest scan, and nothing after it. */
119
+ bearer(authorization) {
120
+ const found = this.options.registry.byBearerDigest(Authenticator.presented(authorization));
121
+ if (found === null)
122
+ throw new Refusal(401, "CALLER_NOT_AUTHENTICATED", "bearer", null);
123
+ return found;
124
+ }
125
+ async workload(verifier, token) {
126
+ let verified;
127
+ try {
128
+ verified = await verifier.verify(token);
129
+ }
130
+ catch (error) {
131
+ const code = error instanceof JwtError ? error.code : "JWT_SIGNATURE_INVALID";
132
+ throw new Refusal(401, code, "jwt", null);
133
+ }
134
+ const { registry } = this.options;
135
+ if (!registry.issuerKnown(verified.issuer)) {
136
+ throw new Refusal(401, "JWT_ISSUER_UNKNOWN", "jwt", null);
137
+ }
138
+ const named = registry.byJwt(verified.issuer, verified.subject);
139
+ if (named === null)
140
+ throw new Refusal(401, "JWT_SUBJECT_UNKNOWN", "jwt", null);
141
+ // The registry narrowed to the workload kind, so the credential here is
142
+ // that kind and needs no second check of its own.
143
+ const { principal, credential } = named;
144
+ // A principal's own audience wins over the configured one; with neither,
145
+ // no token is accepted, because "any audience" is not a thing to accept.
146
+ const audience = credential.audience ?? this.options.audience;
147
+ // Two different operator problems, so two different codes: a deployment
148
+ // that named no audience at all accepts no token, and saying that is
149
+ // "the token's audience was wrong" would send someone to the caller.
150
+ if (audience === null) {
151
+ throw new Refusal(401, "JWT_AUDIENCE_UNCONFIGURED", "jwt", principal);
152
+ }
153
+ if (!verified.audiences.includes(audience)) {
154
+ throw new Refusal(401, "JWT_AUDIENCE_MISMATCH", "jwt", principal);
155
+ }
156
+ for (const [claim, expected] of Object.entries(credential.requiredClaims)) {
157
+ if (verified.claims[claim] !== expected) {
158
+ throw new Refusal(401, "JWT_CLAIM_MISMATCH", "jwt", principal);
159
+ }
160
+ }
161
+ return principal;
162
+ }
163
+ static presented(authorization) {
164
+ if (authorization === undefined || !authorization.startsWith(BEARER)) {
165
+ throw new Refusal(401, "CALLER_NOT_AUTHENTICATED", "bearer", null);
166
+ }
167
+ return authorization.slice(BEARER.length).trim();
168
+ }
169
+ }
170
+ //# sourceMappingURL=Authenticator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Authenticator.js","sourceRoot":"","sources":["../../src/identity/Authenticator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,QAAQ,EAA4B,MAAM,0BAA0B,CAAC;AAgB9E,oFAAoF;AACpF,MAAM,OAAO,SAAU,SAAQ,KAAK;IAEhB;IACA;IAFlB,YACkB,MAAc,EACd,IAAY;QAE5B,KAAK,CAAC,IAAI,CAAC,CAAC;QAHI,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QAG5B,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAeD,4EAA4E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,CAAC;YAC3C,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,uBAAuB,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;QACpE,CAAC;QACD,KAAK,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,EAAE,CAAC;YAC1E,IAAI,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,QAAQ,EAAE,CAAC;gBACxC,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,oBAAoB,EAAE,KAAK,EAAE,SAAS,CAAC,CAAC;YACjE,CAAC;QACH,CAAC;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,MAAM,CAAC,SAAS,CAAC,aAAiC;QACxD,IAAI,aAAa,KAAK,SAAS,IAAI,CAAC,aAAa,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,OAAO,CAAC,GAAG,EAAE,0BAA0B,EAAE,QAAQ,EAAE,IAAI,CAAC,CAAC;QACrE,CAAC;QACD,OAAO,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IACnD,CAAC;CACF"}
@@ -0,0 +1,24 @@
1
+ import type { PeerCertificate } from "node:tls";
2
+ /** What a client certificate asserts, as the door reads it off the socket. */
3
+ export interface PeerIdentity {
4
+ /** Whether the certificate chains to the configured client CA. */
5
+ readonly authorized: boolean;
6
+ readonly sanUris: readonly string[];
7
+ /** SHA-256 fingerprint, lower-case hex without separators. */
8
+ readonly fingerprint: string;
9
+ }
10
+ /** The parts of a socket the door looks at; a plain socket has neither. */
11
+ export interface PeerSocket {
12
+ readonly authorized?: boolean;
13
+ getPeerCertificate?(): PeerCertificate | object;
14
+ }
15
+ /** Normalises a Node fingerprint, `AB:CD:…`, to the form the principals file holds. */
16
+ export declare function normaliseFingerprint(value: string): string;
17
+ /**
18
+ * Reads the client certificate a connection presented, or null when it
19
+ * presented none (a plain socket, or a TLS socket the kubelet's probe
20
+ * opened). The SAN URIs are the names a workload identity travels under;
21
+ * the fingerprint pins one certificate when the file asks for that.
22
+ */
23
+ export declare function peerIdentity(socket: PeerSocket): PeerIdentity | null;
24
+ //# sourceMappingURL=PeerIdentity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PeerIdentity.d.ts","sourceRoot":"","sources":["../../src/identity/PeerIdentity.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAEhD,8EAA8E;AAC9E,MAAM,WAAW,YAAY;IAC3B,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,OAAO,CAAC;IAC7B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,8DAA8D;IAC9D,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;CAC9B;AAED,2EAA2E;AAC3E,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,UAAU,CAAC,EAAE,OAAO,CAAC;IAC9B,kBAAkB,CAAC,IAAI,eAAe,GAAG,MAAM,CAAC;CACjD;AAED,uFAAuF;AACvF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAE1D;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,YAAY,GAAG,IAAI,CAepE"}
@@ -0,0 +1,29 @@
1
+ /** Normalises a Node fingerprint, `AB:CD:…`, to the form the principals file holds. */
2
+ export function normaliseFingerprint(value) {
3
+ return value.replace(/:/g, "").toLowerCase();
4
+ }
5
+ /**
6
+ * Reads the client certificate a connection presented, or null when it
7
+ * presented none (a plain socket, or a TLS socket the kubelet's probe
8
+ * opened). The SAN URIs are the names a workload identity travels under;
9
+ * the fingerprint pins one certificate when the file asks for that.
10
+ */
11
+ export function peerIdentity(socket) {
12
+ if (socket.getPeerCertificate === undefined)
13
+ return null;
14
+ const certificate = socket.getPeerCertificate();
15
+ if (typeof certificate.fingerprint256 !== "string")
16
+ return null;
17
+ const names = certificate.subjectaltname ?? "";
18
+ const sanUris = names
19
+ .split(",")
20
+ .map((entry) => entry.trim())
21
+ .filter((entry) => entry.startsWith("URI:"))
22
+ .map((entry) => entry.slice("URI:".length));
23
+ return {
24
+ authorized: socket.authorized === true,
25
+ sanUris,
26
+ fingerprint: normaliseFingerprint(certificate.fingerprint256),
27
+ };
28
+ }
29
+ //# sourceMappingURL=PeerIdentity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PeerIdentity.js","sourceRoot":"","sources":["../../src/identity/PeerIdentity.ts"],"names":[],"mappings":"AAiBA,uFAAuF;AACvF,MAAM,UAAU,oBAAoB,CAAC,KAAa;IAChD,OAAO,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,YAAY,CAAC,MAAkB;IAC7C,IAAI,MAAM,CAAC,kBAAkB,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACzD,MAAM,WAAW,GAAG,MAAM,CAAC,kBAAkB,EAA8B,CAAC;IAC5E,IAAI,OAAO,WAAW,CAAC,cAAc,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC;IAChE,MAAM,KAAK,GAAG,WAAW,CAAC,cAAc,IAAI,EAAE,CAAC;IAC/C,MAAM,OAAO,GAAG,KAAK;SAClB,KAAK,CAAC,GAAG,CAAC;SACV,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SAC5B,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;SAC3C,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC9C,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,UAAU,KAAK,IAAI;QACtC,OAAO;QACP,WAAW,EAAE,oBAAoB,CAAC,WAAW,CAAC,cAAc,CAAC;KAC9D,CAAC;AACJ,CAAC"}