@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,30 @@
1
+ import type { AuthorizationFinalizationInput, AuthorizationVerifier, CapturedIntent, GateDecision, VerifiedAuthorization } from "@decionis/agent-safe-pipeline";
2
+ import type { EffectEvidenceRegister } from "./EffectEvidenceRegister.js";
3
+ export interface EffectAwareGrantVerifierOptions {
4
+ readonly verifier: AuthorizationVerifier;
5
+ readonly register: EffectEvidenceRegister;
6
+ readonly observer: {
7
+ readonly id: string;
8
+ readonly version: string;
9
+ };
10
+ }
11
+ /**
12
+ * The verifier the executor runs, wrapped so that the observation the
13
+ * handler made reaches the authority with the commit it belongs to. It adds
14
+ * nothing to the claim: `verifyAndConsume` is the delegate's, unchanged, and
15
+ * the grant is still consumed once by whoever the adopter configured.
16
+ *
17
+ * On `finalize` it attaches the effect record the handler registered for
18
+ * this exact authorization. The authority binds evidence by the
19
+ * expected-effect digest and the commit correlation id and refuses a
20
+ * finalization whose evidence it cannot bind, which would lose the commit
21
+ * outcome with it; so the delegate's own drop rule applies and an attempt
22
+ * with no registered observation finalizes exactly as it did before.
23
+ */
24
+ export declare class EffectAwareGrantVerifier implements AuthorizationVerifier {
25
+ private readonly options;
26
+ constructor(options: EffectAwareGrantVerifierOptions);
27
+ verifyAndConsume(captured: CapturedIntent, decision: GateDecision): Promise<VerifiedAuthorization | null>;
28
+ finalize(input: AuthorizationFinalizationInput): Promise<"RECORDED" | "PENDING">;
29
+ }
30
+ //# sourceMappingURL=EffectAwareGrantVerifier.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectAwareGrantVerifier.d.ts","sourceRoot":"","sources":["../../src/adapters/EffectAwareGrantVerifier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8BAA8B,EAC9B,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,qBAAqB,EACtB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AAE1E,MAAM,WAAW,+BAA+B;IAC9C,QAAQ,CAAC,QAAQ,EAAE,qBAAqB,CAAC;IACzC,QAAQ,CAAC,QAAQ,EAAE,sBAAsB,CAAC;IAC1C,QAAQ,CAAC,QAAQ,EAAE;QAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC;CACtE;AAED;;;;;;;;;;;;GAYG;AACH,qBAAa,wBAAyB,YAAW,qBAAqB;IACjD,OAAO,CAAC,QAAQ,CAAC,OAAO;gBAAP,OAAO,EAAE,+BAA+B;IAE/D,gBAAgB,CAC3B,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,YAAY,GACrB,OAAO,CAAC,qBAAqB,GAAG,IAAI,CAAC;IAI3B,QAAQ,CAAC,KAAK,EAAE,8BAA8B,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;CAgB9F"}
@@ -0,0 +1,38 @@
1
+ import { authorityEffectEvidence } from "./EffectEvidenceBuilder.js";
2
+ /**
3
+ * The verifier the executor runs, wrapped so that the observation the
4
+ * handler made reaches the authority with the commit it belongs to. It adds
5
+ * nothing to the claim: `verifyAndConsume` is the delegate's, unchanged, and
6
+ * the grant is still consumed once by whoever the adopter configured.
7
+ *
8
+ * On `finalize` it attaches the effect record the handler registered for
9
+ * this exact authorization. The authority binds evidence by the
10
+ * expected-effect digest and the commit correlation id and refuses a
11
+ * finalization whose evidence it cannot bind, which would lose the commit
12
+ * outcome with it; so the delegate's own drop rule applies and an attempt
13
+ * with no registered observation finalizes exactly as it did before.
14
+ */
15
+ export class EffectAwareGrantVerifier {
16
+ options;
17
+ constructor(options) {
18
+ this.options = options;
19
+ }
20
+ async verifyAndConsume(captured, decision) {
21
+ return await this.options.verifier.verifyAndConsume(captured, decision);
22
+ }
23
+ async finalize(input) {
24
+ const finalize = this.options.verifier.finalize?.bind(this.options.verifier);
25
+ if (finalize === undefined)
26
+ return "PENDING";
27
+ const effect = this.options.register.take(input.authorization);
28
+ if (effect === null)
29
+ return await finalize(input);
30
+ // The authority's binding is the commit correlation id, which this
31
+ // repository's verifier takes from the intent's own id.
32
+ return await finalize({
33
+ ...input,
34
+ effectEvidence: authorityEffectEvidence(effect, input.captured.intent.intentId, this.options.observer),
35
+ });
36
+ }
37
+ }
38
+ //# sourceMappingURL=EffectAwareGrantVerifier.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectAwareGrantVerifier.js","sourceRoot":"","sources":["../../src/adapters/EffectAwareGrantVerifier.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AASrE;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,wBAAwB;IACC;IAApC,YAAoC,OAAwC;QAAxC,YAAO,GAAP,OAAO,CAAiC;IAAG,CAAC;IAEzE,KAAK,CAAC,gBAAgB,CAC3B,QAAwB,EACxB,QAAsB;QAEtB,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;IAC1E,CAAC;IAEM,KAAK,CAAC,QAAQ,CAAC,KAAqC;QACzD,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC7E,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,SAAS,CAAC;QAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QAC/D,IAAI,MAAM,KAAK,IAAI;YAAE,OAAO,MAAM,QAAQ,CAAC,KAAK,CAAC,CAAC;QAClD,mEAAmE;QACnE,wDAAwD;QACxD,OAAO,MAAM,QAAQ,CAAC;YACpB,GAAG,KAAK;YACR,cAAc,EAAE,uBAAuB,CACrC,MAAM,EACN,KAAK,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,EAC9B,IAAI,CAAC,OAAO,CAAC,QAAQ,CACtB;SACF,CAAC,CAAC;IACL,CAAC;CACF"}
@@ -0,0 +1,20 @@
1
+ import type { JsonObject } from "@decionis/agent-safe-pipeline";
2
+ export type Comparison = "MATCH" | "MISMATCH" | "PENDING";
3
+ export interface EffectComparisonResult {
4
+ readonly comparison: Comparison;
5
+ /** The projected fields that differ, in the projection's own order. */
6
+ readonly mismatched: readonly string[];
7
+ }
8
+ /**
9
+ * The expected effect against the observed one, field by field over the
10
+ * projection and nothing else. A provider that returns more than the
11
+ * projection asks about cannot cause a mismatch, and a provider that
12
+ * returns less cannot hide one: a field the observation does not carry is a
13
+ * difference, because the projection is exactly the set of things that had
14
+ * to be true for this to be the effect that was authorised.
15
+ *
16
+ * An observation that does not exist yet is `PENDING`, which is not a
17
+ * match: an acknowledgement is not a confirmation.
18
+ */
19
+ export declare function compareEffect(expected: JsonObject, observed: JsonObject | null): EffectComparisonResult;
20
+ //# sourceMappingURL=EffectComparison.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectComparison.d.ts","sourceRoot":"","sources":["../../src/adapters/EffectComparison.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAa,MAAM,+BAA+B,CAAC;AAE3E,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;AAE1D,MAAM,WAAW,sBAAsB;IACrC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,uEAAuE;IACvE,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;CACxC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,UAAU,EACpB,QAAQ,EAAE,UAAU,GAAG,IAAI,GAC1B,sBAAsB,CASxB"}
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The expected effect against the observed one, field by field over the
3
+ * projection and nothing else. A provider that returns more than the
4
+ * projection asks about cannot cause a mismatch, and a provider that
5
+ * returns less cannot hide one: a field the observation does not carry is a
6
+ * difference, because the projection is exactly the set of things that had
7
+ * to be true for this to be the effect that was authorised.
8
+ *
9
+ * An observation that does not exist yet is `PENDING`, which is not a
10
+ * match: an acknowledgement is not a confirmation.
11
+ */
12
+ export function compareEffect(expected, observed) {
13
+ if (observed === null)
14
+ return { comparison: "PENDING", mismatched: [] };
15
+ const mismatched = Object.keys(expected).filter((field) => !sameValue(expected[field], observed[field]));
16
+ return {
17
+ comparison: mismatched.length === 0 ? "MATCH" : "MISMATCH",
18
+ mismatched,
19
+ };
20
+ }
21
+ /**
22
+ * Structural equality over JSON values, so nothing is compared by reference
23
+ * and nothing is compared by coercion. A field the observation does not
24
+ * carry arrives here as `undefined`, which equals no value the expectation
25
+ * can hold, so an absent field is a difference rather than a match. An array
26
+ * is only ever equal to an array: an object that happens to have the same
27
+ * indices, or a `length`, is a different value, and a provider's body is not
28
+ * trusted to be the shape it resembles.
29
+ */
30
+ function sameValue(expected, observed) {
31
+ if (expected === null || observed === null)
32
+ return expected === observed;
33
+ if (typeof expected !== "object" || typeof observed !== "object")
34
+ return expected === observed;
35
+ if (Array.isArray(expected)) {
36
+ return (Array.isArray(observed) &&
37
+ expected.length === observed.length &&
38
+ expected.every((item, index) => sameValue(item, observed[index])));
39
+ }
40
+ if (Array.isArray(observed))
41
+ return false;
42
+ const left = expected;
43
+ const right = observed;
44
+ const keys = Object.keys(left);
45
+ return (keys.length === Object.keys(right).length &&
46
+ keys.every((key) => sameValue(left[key], right[key])));
47
+ }
48
+ //# sourceMappingURL=EffectComparison.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectComparison.js","sourceRoot":"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IAC1C,MAAM,IAAI,GAAG,QAAqC,CAAC;IACnD,MAAM,KAAK,GAAG,QAAqC,CAAC;IACpD,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC/B,OAAO,CACL,IAAI,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM;QACzC,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CACtD,CAAC;AACJ,CAAC"}
@@ -0,0 +1,60 @@
1
+ import type { AuthorityEffectEvidence } from "@decionis/agent-safe-pipeline";
2
+ import { type Comparison } from "./EffectComparison.js";
3
+ import type { PreparedAction, ProviderResult } from "./EffectAdapter.js";
4
+ import type { RegisteredEffect } from "./EffectEvidenceRegister.js";
5
+ /**
6
+ * The profile whose effect-evidence record this builder writes. It is named
7
+ * here rather than imported from the banking family, because this layer is
8
+ * family-agnostic and the family imports it, not the reverse; the family's
9
+ * own `BEAP_PROFILE` is held equal to it by test.
10
+ */
11
+ export declare const EFFECT_EVIDENCE_PROFILE = "decionis.beap/v1.0";
12
+ export type ConfirmationStatus = "PENDING" | "CONFIRMED" | "NOT_EFFECTED" | "REVERSED" | "UNKNOWN";
13
+ export type EffectOutcome = "COMMITTED" | "FAILED" | "INDETERMINATE";
14
+ export interface EvidenceInput {
15
+ readonly prepared: PreparedAction;
16
+ readonly result: ProviderResult | null;
17
+ /** Set when the provider neither committed nor refused. */
18
+ readonly indeterminate?: {
19
+ readonly reason: string;
20
+ readonly providerStatus: string | null;
21
+ };
22
+ readonly observer: {
23
+ readonly id: string;
24
+ readonly version: string;
25
+ };
26
+ readonly correlationId: string;
27
+ readonly idempotencyKey: string;
28
+ readonly observedAt: string;
29
+ }
30
+ /**
31
+ * What confirmation an observation actually supports. An acknowledgement is
32
+ * never a confirmation: a provider saying "accepted" has told you it took
33
+ * the request, not that the effect exists, so the confirmation stays
34
+ * `PENDING` until something read the effect back and it matched. A
35
+ * mismatch is `UNKNOWN`, not `NOT_EFFECTED`: something happened, and what
36
+ * it was is exactly what nobody can yet say.
37
+ */
38
+ export declare function confirmationFor(outcome: EffectOutcome, comparison: Comparison, method: string): ConfirmationStatus;
39
+ /**
40
+ * The effect record for one attempt: what was expected, what was observed,
41
+ * whether they agree, and what that supports. It carries digests,
42
+ * identifiers, statuses and codes; no provider body, no parameter, no
43
+ * credential. The record is digested over its own canonical form, so a
44
+ * later reader can tell that the record they hold is the record that was
45
+ * made.
46
+ */
47
+ export declare function buildEffectRecord(input: EvidenceInput): RegisteredEffect;
48
+ /**
49
+ * The same observation in the authority's own Protocol 1.1 shape. The
50
+ * authority binds it to the grant by the expected-effect digest and the
51
+ * commit correlation id, and refuses a whole finalization whose evidence it
52
+ * cannot bind, so nothing is invented here: the digests and the correlation
53
+ * id are the ones the attempt actually used, and a `MISMATCH` is reported as
54
+ * `UNCONFIRMED` with the digest that was observed rather than hidden.
55
+ */
56
+ export declare function authorityEffectEvidence(effect: RegisteredEffect, correlationId: string, observer: {
57
+ readonly id: string;
58
+ readonly version: string;
59
+ }): AuthorityEffectEvidence;
60
+ //# sourceMappingURL=EffectEvidenceBuilder.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectEvidenceBuilder.d.ts","sourceRoot":"","sources":["../../src/adapters/EffectEvidenceBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAc,MAAM,+BAA+B,CAAC;AAEzF,OAAO,EAAiB,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AACvE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAC;AACzE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAEpE;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AA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ectComparison.js";
3
+ /**
4
+ * The profile whose effect-evidence record this builder writes. It is named
5
+ * here rather than imported from the banking family, because this layer is
6
+ * family-agnostic and the family imports it, not the reverse; the family's
7
+ * own `BEAP_PROFILE` is held equal to it by test.
8
+ */
9
+ export const EFFECT_EVIDENCE_PROFILE = "decionis.beap/v1.0";
10
+ /**
11
+ * What confirmation an observation actually supports. An acknowledgement is
12
+ * never a confirmation: a provider saying "accepted" has told you it took
13
+ * the request, not that the effect exists, so the confirmation stays
14
+ * `PENDING` until something read the effect back and it matched. A
15
+ * mismatch is `UNKNOWN`, not `NOT_EFFECTED`: something happened, and what
16
+ * it was is exactly what nobody can yet say.
17
+ */
18
+ export function confirmationFor(outcome, comparison, method) {
19
+ if (outcome === "INDETERMINATE")
20
+ return "UNKNOWN";
21
+ if (outcome === "FAILED")
22
+ return "NOT_EFFECTED";
23
+ if (comparison === "MISMATCH")
24
+ return "UNKNOWN";
25
+ if (comparison === "PENDING")
26
+ return "PENDING";
27
+ return method === "DOWNSTREAM_ACK" ? "PENDING" : "CONFIRMED";
28
+ }
29
+ /**
30
+ * The effect record for one attempt: what was expected, what was observed,
31
+ * whether they agree, and what that supports. It carries digests,
32
+ * identifiers, statuses and codes; no provider body, no parameter, no
33
+ * credential. The record is digested over its own canonical form, so a
34
+ * later reader can tell that the record they hold is the record that was
35
+ * made.
36
+ */
37
+ export function buildEffectRecord(input) {
38
+ const { prepared, result, indeterminate } = input;
39
+ const outcome = indeterminate !== undefined ? "INDETERMINATE" : (result?.status ?? "INDETERMINATE");
40
+ const observed = outcome === "COMMITTED" ? (result?.observed ?? null) : null;
41
+ const { comparison, mismatched } = compareEffect(prepared.expectedEffect, observed);
42
+ const observationMethod = result?.observationMethod ?? "DOWNSTREAM_ACK";
43
+ const confirmation = confirmationFor(outcome, comparison, observationMethod);
44
+ const observedEffectDigest = observed === null ? null : jcsDigest(observed);
45
+ const reasonCodes = [
46
+ ...(indeterminate === undefined ? [] : ["INDETERMINATE_OUTCOME"]),
47
+ ...(comparison === "MISMATCH" ? ["EFFECT_MISMATCH"] : []),
48
+ ...(result?.failureReason === null || result?.failureReason === undefined
49
+ ? []
50
+ : [result.failureReason]),
51
+ ];
52
+ const evidence = {
53
+ profile: EFFECT_EVIDENCE_PROFILE,
54
+ type: "EFFECT_EVIDENCE",
55
+ domain: prepared.domain,
56
+ action: prepared.actionType,
57
+ intent_digest: prepared.intentDigest,
58
+ execution: {
59
+ adapter: input.observer.id,
60
+ correlation_id: input.correlationId,
61
+ idempotency_key: input.idempotencyKey,
62
+ attempt: 1,
63
+ observed_at: input.observedAt,
64
+ },
65
+ outcome: {
66
+ status: outcome,
67
+ provider_status: result?.providerStatus ?? indeterminate?.providerStatus ?? null,
68
+ provider_reference: result?.providerReference ?? null,
69
+ response_digest: result?.responseDigest ?? null,
70
+ failure_reason: result?.failureReason ?? indeterminate?.reason ?? null,
71
+ },
72
+ effect: {
73
+ effect_type: prepared.effectType,
74
+ resource_ref: prepared.resourceRef,
75
+ expected_effect_digest: prepared.expectedEffectDigest,
76
+ observed_effect_digest: observedEffectDigest,
77
+ observation_method: observationMethod,
78
+ comparison,
79
+ ...(mismatched.length === 0 ? {} : { mismatched_fields: [...mismatched] }),
80
+ },
81
+ confirmation: { status: confirmation },
82
+ provenance: {
83
+ source: result?.source ?? "ADAPTER_OBSERVATION",
84
+ provider_generated: result?.providerGenerated ?? false,
85
+ observer: { id: input.observer.id, version: input.observer.version },
86
+ },
87
+ evidence_status: observed === null ? "INCOMPLETE" : "COMPLETE",
88
+ observed_at: input.observedAt,
89
+ };
90
+ return {
91
+ evidence,
92
+ outcome,
93
+ comparison,
94
+ mismatched,
95
+ confirmation,
96
+ observedEffectDigest,
97
+ expectedEffectDigest: prepared.expectedEffectDigest,
98
+ responseDigest: result?.responseDigest ?? null,
99
+ providerReference: result?.providerReference ?? null,
100
+ observationMethod,
101
+ evidenceDigest: jcsDigest(evidence),
102
+ reasonCodes,
103
+ };
104
+ }
105
+ /**
106
+ * The same observation in the authority's own Protocol 1.1 shape. The
107
+ * authority binds it to the grant by the expected-effect digest and the
108
+ * commit correlation id, and refuses a whole finalization whose evidence it
109
+ * cannot bind, so nothing is invented here: the digests and the correlation
110
+ * id are the ones the attempt actually used, and a `MISMATCH` is reported as
111
+ * `UNCONFIRMED` with the digest that was observed rather than hidden.
112
+ */
113
+ export function authorityEffectEvidence(effect, correlationId, observer) {
114
+ return {
115
+ version: "1.0",
116
+ status: effect.confirmation === "CONFIRMED" ? "CONFIRMED" : "UNCONFIRMED",
117
+ observation_method: effect.observationMethod,
118
+ observer: { id: observer.id, version: observer.version },
119
+ expected_effect_digest: effect.expectedEffectDigest,
120
+ observed_effect_digest: effect.observedEffectDigest,
121
+ observed_at: String(effect.evidence.observed_at ?? null),
122
+ evidence_digest: effect.evidenceDigest,
123
+ evidence_reference: null,
124
+ execution_correlation_id: correlationId,
125
+ };
126
+ }
127
+ //# sourceMappingURL=EffectEvidenceBuilder.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectEvidenceBuilder.js","sourceRoot":"","sources":["../../src/adapters/EffectEvidenceBuilder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAe,MAAM,gBAAgB,CAAC;AACxD,OAAO,EAAE,aAAa,EAAmB,MAAM,uBAAuB,CAAC;AAIvE;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAgB5D;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe,CAC7B,OAAsB,EACtB,UAAsB,EACtB,MAAc;IAEd,IAAI,OAAO,KAAK,eAAe;QAAE,OAAO,SAAS,CAAC;IAClD,IAAI,OAAO,KAAK,QAAQ;QAAE,OAAO,cAAc,CAAC;IAChD,IAAI,UAAU,KAAK,UAAU;QAAE,OAAO,SAAS,CAAC;IAChD,IAAI,UAAU,KAAK,SAAS;QAAE,OAAO,SAAS,CAAC;IAC/C,OAAO,MAAM,KAAK,gBAAgB,CAAC,CAAC,CAAC,SAA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} from "@decionis/agent-safe-pipeline";
2
+ import type { JsonObject } from "@decionis/agent-safe-pipeline";
3
+ /** What the handler observed, waiting for the verifier that finalizes the grant. */
4
+ export interface RegisteredEffect {
5
+ readonly evidence: JsonObject;
6
+ readonly outcome: "COMMITTED" | "FAILED" | "INDETERMINATE";
7
+ readonly comparison: "MATCH" | "MISMATCH" | "PENDING";
8
+ readonly mismatched: readonly string[];
9
+ readonly confirmation: "PENDING" | "CONFIRMED" | "NOT_EFFECTED" | "REVERSED" | "UNKNOWN";
10
+ readonly observedEffectDigest: string | null;
11
+ readonly expectedEffectDigest: string;
12
+ readonly responseDigest: string | null;
13
+ readonly providerReference: string | null;
14
+ readonly observationMethod: string;
15
+ readonly evidenceDigest: string;
16
+ readonly reasonCodes: readonly string[];
17
+ }
18
+ /**
19
+ * The handoff between the handler, which observes the effect, and the
20
+ * verifier, which finalizes the grant with the authority moments later.
21
+ * Keyed by the frozen authorization the pipeline handed both of them, in a
22
+ * `WeakMap`, so an entry cannot outlive the attempt it belongs to and one
23
+ * attempt can never read another's: there is no shared identifier to guess
24
+ * and nothing to clear.
25
+ */
26
+ export declare class EffectEvidenceRegister {
27
+ private readonly entries;
28
+ attach(authorization: VerifiedAuthorization, effect: RegisteredEffect): void;
29
+ take(authorization: VerifiedAuthorization): RegisteredEffect | null;
30
+ }
31
+ //# sourceMappingURL=EffectEvidenceRegister.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectEvidenceRegister.d.ts","sourceRoot":"","sources":["../../src/adapters/EffectEvidenceRegister.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,+BAA+B,CAAC;AAC3E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAEhE,oFAAoF;AACpF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,QAAQ,EAAE,UAAU,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,WAAW,GAAG,QAAQ,GAAG,eAAe,CAAC;IAC3D,QAAQ,CAAC,UAAU,EAAE,OAAO,GAAG,UAAU,GAAG,SAAS,CAAC;IACtD,QAAQ,CAAC,UAAU,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,QAAQ,CAAC,YAAY,EAAE,SAAS,GAAG,WAAW,GAAG,cAAc,GAAG,UAAU,GAAG,SAAS,CAAC;IACzF,QAAQ,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAC;IACtC,QAAQ,CAAC,cAAc,EAAE,MAAM,GAAG,IAAI,CAAC;IACvC,QAAQ,CAAC,iBAAiB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1C,QAAQ,CAAC,iBAAiB,EAAE,MAAM,CAAC;IACnC,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,QAAQ,CAAC,WAAW,EAAE,SAAS,MAAM,EAAE,CAAC;CACzC;AAED;;;;;;;GAOG;AACH,qBAAa,sBAAsB;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA0D;IAE3E,MAAM,CAAC,aAAa,EAAE,qBAAqB,EAAE,MAAM,EAAE,gBAAgB,GAAG,IAAI;IAI5E,IAAI,CAAC,aAAa,EAAE,qBAAqB,GAAG,gBAAgB,GAAG,IAAI;CAK3E"}
@@ -0,0 +1,21 @@
1
+ /**
2
+ * The handoff between the handler, which observes the effect, and the
3
+ * verifier, which finalizes the grant with the authority moments later.
4
+ * Keyed by the frozen authorization the pipeline handed both of them, in a
5
+ * `WeakMap`, so an entry cannot outlive the attempt it belongs to and one
6
+ * attempt can never read another's: there is no shared identifier to guess
7
+ * and nothing to clear.
8
+ */
9
+ export class EffectEvidenceRegister {
10
+ entries = new WeakMap();
11
+ attach(authorization, effect) {
12
+ this.entries.set(authorization, effect);
13
+ }
14
+ take(authorization) {
15
+ const effect = this.entries.get(authorization) ?? null;
16
+ if (effect !== null)
17
+ this.entries.delete(authorization);
18
+ return effect;
19
+ }
20
+ }
21
+ //# sourceMappingURL=EffectEvidenceRegister.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EffectEvidenceRegister.js","sourceRoot":"","sources":["../../src/adapters/EffectEvidenceRegister.ts"],"names":[],"mappings":"AAmBA;;;;;;;GAOG;AACH,MAAM,OAAO,sBAAsB;IAChB,OAAO,GAAG,IAAI,OAAO,EAA2C,CAAC;IAE3E,MAAM,CAAC,aAAoC,EAAE,MAAwB;QAC1E,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;IAC1C,CAAC;IAEM,IAAI,CAAC,aAAoC;QAC9C,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,IAAI,IAAI,CAAC;QACvD,IAAI,MAAM,KAAK,IAAI;YAAE,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QACxD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF"}
@@ -0,0 +1,43 @@
1
+ import { type JsonValue } from "@decionis/agent-safe-pipeline";
2
+ /** A digest in the one form every wire field in this repository uses. */
3
+ export type Sha256 = `sha256:${string}`;
4
+ export declare class JcsError extends Error {
5
+ readonly code: "JCS_NOT_I_JSON" | "JCS_NUMBER_NOT_FINITE";
6
+ constructor(code: "JCS_NOT_I_JSON" | "JCS_NUMBER_NOT_FINITE");
7
+ }
8
+ /**
9
+ * The canonical digest BEAP asks for: SHA-256 over the RFC 8785 canonical
10
+ * form of the value. The canonicaliser is the pipeline's own, which sorts
11
+ * keys by UTF-16 code unit and serialises numbers and strings the way
12
+ * ECMAScript does; for I-JSON input those rules and RFC 8785's coincide,
13
+ * which the conformance vectors and the authority's independent
14
+ * canonicaliser both hold this repository to.
15
+ *
16
+ * What the canonicaliser does not do is refuse input that is not I-JSON, so
17
+ * this adds that gate: a lone surrogate would serialise differently in
18
+ * another language's JSON writer, and a non-finite number has no JSON form
19
+ * at all. Both are refused here rather than producing a digest two
20
+ * implementations would disagree about.
21
+ */
22
+ export declare function jcsDigest(value: JsonValue): Sha256;
23
+ /** The canonical text itself, for a caller that wants to see what was hashed. */
24
+ export declare function jcsCanonical(value: JsonValue): string;
25
+ /**
26
+ * Whether a string is well-formed UTF-16: every surrogate paired. Written
27
+ * out rather than taken from `String.prototype.isWellFormed`, which this
28
+ * repository's ES2022 target does not declare, and small enough that
29
+ * depending on the newer library for it would be the larger change.
30
+ *
31
+ * The string iterator does the pairing: it yields a well-formed pair as one
32
+ * two-unit character, and anything unpaired as a single unit. So a lone
33
+ * surrogate is exactly a one-unit character whose code is in the surrogate
34
+ * range, and there is no index arithmetic to get wrong.
35
+ */
36
+ export declare function isWellFormedUtf16(value: string): boolean;
37
+ /**
38
+ * Every string well-formed UTF-16, every number finite. Recurses through
39
+ * arrays and objects, and checks keys as well as values, because a key is
40
+ * as much of the canonical form as a value is.
41
+ */
42
+ export declare function assertIJson(value: JsonValue): void;
43
+ //# sourceMappingURL=JcsDigest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JcsDigest.d.ts","sourceRoot":"","sources":["../../src/adapters/JcsDigest.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAEtF,yEAAyE;AACzE,MAAM,MAAM,MAAM,GAAG,UAAU,MAAM,EAAE,CAAC;AAExC,qBAAa,QAAS,SAAQ,KAAK;aACE,IAAI,EAAE,gBAAgB,GAAG,uBAAuB;gBAAhD,IAAI,EAAE,gBAAgB,GAAG,uBAAuB;CAIpF;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAIlD;AAED,iFAAiF;AACjF,wBAAgB,YAAY,CAAC,KAAK,EAAE,SAAS,GAAG,MAAM,CAGrD;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAQxD;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAmBlD"}
@@ -0,0 +1,86 @@
1
+ import { createHash } from "node:crypto";
2
+ import { CanonicalIntentHasher } from "@decionis/agent-safe-pipeline";
3
+ export class JcsError extends Error {
4
+ code;
5
+ constructor(code) {
6
+ super(code);
7
+ this.code = code;
8
+ this.name = "JcsError";
9
+ }
10
+ }
11
+ /**
12
+ * The canonical digest BEAP asks for: SHA-256 over the RFC 8785 canonical
13
+ * form of the value. The canonicaliser is the pipeline's own, which sorts
14
+ * keys by UTF-16 code unit and serialises numbers and strings the way
15
+ * ECMAScript does; for I-JSON input those rules and RFC 8785's coincide,
16
+ * which the conformance vectors and the authority's independent
17
+ * canonicaliser both hold this repository to.
18
+ *
19
+ * What the canonicaliser does not do is refuse input that is not I-JSON, so
20
+ * this adds that gate: a lone surrogate would serialise differently in
21
+ * another language's JSON writer, and a non-finite number has no JSON form
22
+ * at all. Both are refused here rather than producing a digest two
23
+ * implementations would disagree about.
24
+ */
25
+ export function jcsDigest(value) {
26
+ assertIJson(value);
27
+ const canonical = CanonicalIntentHasher.stringify(value);
28
+ return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
29
+ }
30
+ /** The canonical text itself, for a caller that wants to see what was hashed. */
31
+ export function jcsCanonical(value) {
32
+ assertIJson(value);
33
+ return CanonicalIntentHasher.stringify(value);
34
+ }
35
+ /**
36
+ * Whether a string is well-formed UTF-16: every surrogate paired. Written
37
+ * out rather than taken from `String.prototype.isWellFormed`, which this
38
+ * repository's ES2022 target does not declare, and small enough that
39
+ * depending on the newer library for it would be the larger change.
40
+ *
41
+ * The string iterator does the pairing: it yields a well-formed pair as one
42
+ * two-unit character, and anything unpaired as a single unit. So a lone
43
+ * surrogate is exactly a one-unit character whose code is in the surrogate
44
+ * range, and there is no index arithmetic to get wrong.
45
+ */
46
+ export function isWellFormedUtf16(value) {
47
+ for (const character of value) {
48
+ if (character.length === 1) {
49
+ const unit = character.charCodeAt(0);
50
+ if (unit >= 0xd800 && unit <= 0xdfff)
51
+ return false;
52
+ }
53
+ }
54
+ return true;
55
+ }
56
+ /**
57
+ * Every string well-formed UTF-16, every number finite. Recurses through
58
+ * arrays and objects, and checks keys as well as values, because a key is
59
+ * as much of the canonical form as a value is.
60
+ */
61
+ export function assertIJson(value) {
62
+ if (typeof value === "string") {
63
+ if (!isWellFormedUtf16(value))
64
+ throw new JcsError("JCS_NOT_I_JSON");
65
+ return;
66
+ }
67
+ if (typeof value === "number") {
68
+ if (!Number.isFinite(value))
69
+ throw new JcsError("JCS_NUMBER_NOT_FINITE");
70
+ return;
71
+ }
72
+ // Only null has to be turned away here: `Object.entries` walks an array's
73
+ // indices and a boolean's absent properties correctly, so a case for each
74
+ // would be a branch no input could tell apart from this one.
75
+ if (value === null)
76
+ return;
77
+ for (const [key, entry] of Object.entries(value)) {
78
+ if (!isWellFormedUtf16(key))
79
+ throw new JcsError("JCS_NOT_I_JSON");
80
+ // A key whose value is `undefined` is a key the canonical form drops,
81
+ // so there is nothing under it to check.
82
+ if (entry !== undefined)
83
+ assertIJson(entry);
84
+ }
85
+ }
86
+ //# sourceMappingURL=JcsDigest.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"JcsDigest.js","sourceRoot":"","sources":["../../src/adapters/JcsDigest.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,qBAAqB,EAAkB,MAAM,+BAA+B,CAAC;AAKtF,MAAM,OAAO,QAAS,SAAQ,KAAK;IACE;IAAnC,YAAmC,IAAgD;QACjF,KAAK,CAAC,IAAI,CAAC,CAAC;QADqB,SAAI,GAAJ,IAAI,CAA4C;QAEjF,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;IACzB,CAAC;CACF;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,SAAS,CAAC,KAAgB;IACxC,WAAW,C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