@decionis/agentsafe 0.6.0 → 0.8.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 (288) hide show
  1. package/README.md +68 -20
  2. package/dist/Cli.js +30 -3
  3. package/dist/Cli.js.map +1 -1
  4. package/dist/Index.d.ts +5 -3
  5. package/dist/Index.d.ts.map +1 -1
  6. package/dist/Index.js +3 -1
  7. package/dist/Index.js.map +1 -1
  8. package/dist/TrustedExecutor.d.ts.map +1 -1
  9. package/dist/TrustedExecutor.js +2 -0
  10. package/dist/TrustedExecutor.js.map +1 -1
  11. package/dist/acceptance/AcceptancePlan.d.ts +109 -0
  12. package/dist/acceptance/AcceptancePlan.d.ts.map +1 -0
  13. package/dist/acceptance/AcceptancePlan.js +128 -0
  14. package/dist/acceptance/AcceptancePlan.js.map +1 -0
  15. package/dist/acceptance/AcceptanceReport.d.ts +596 -0
  16. package/dist/acceptance/AcceptanceReport.d.ts.map +1 -0
  17. package/dist/acceptance/AcceptanceReport.js +361 -0
  18. package/dist/acceptance/AcceptanceReport.js.map +1 -0
  19. package/dist/acceptance/AcceptanceRun.d.ts +118 -0
  20. package/dist/acceptance/AcceptanceRun.d.ts.map +1 -0
  21. package/dist/acceptance/AcceptanceRun.js +419 -0
  22. package/dist/acceptance/AcceptanceRun.js.map +1 -0
  23. package/dist/acceptance/Coverage.d.ts +12 -0
  24. package/dist/acceptance/Coverage.d.ts.map +1 -0
  25. package/dist/acceptance/Coverage.js +48 -0
  26. package/dist/acceptance/Coverage.js.map +1 -0
  27. package/dist/acceptance/OutageDoubles.d.ts +34 -0
  28. package/dist/acceptance/OutageDoubles.d.ts.map +1 -0
  29. package/dist/acceptance/OutageDoubles.js +67 -0
  30. package/dist/acceptance/OutageDoubles.js.map +1 -0
  31. package/dist/acceptance/ZoneProbes.d.ts +368 -0
  32. package/dist/acceptance/ZoneProbes.d.ts.map +1 -0
  33. package/dist/acceptance/ZoneProbes.js +488 -0
  34. package/dist/acceptance/ZoneProbes.js.map +1 -0
  35. package/dist/adapters/JcsDigest.d.ts +6 -5
  36. package/dist/adapters/JcsDigest.d.ts.map +1 -1
  37. package/dist/adapters/JcsDigest.js +9 -8
  38. package/dist/adapters/JcsDigest.js.map +1 -1
  39. package/dist/adapters/mcp/McpGuard.d.ts +32 -3
  40. package/dist/adapters/mcp/McpGuard.d.ts.map +1 -1
  41. package/dist/adapters/mcp/McpGuard.js +29 -5
  42. package/dist/adapters/mcp/McpGuard.js.map +1 -1
  43. package/dist/adapters/mcp/McpIntentBinder.d.ts +18 -3
  44. package/dist/adapters/mcp/McpIntentBinder.d.ts.map +1 -1
  45. package/dist/adapters/mcp/McpIntentBinder.js +48 -1
  46. package/dist/adapters/mcp/McpIntentBinder.js.map +1 -1
  47. package/dist/adapters/mcp/McpInvocation.d.ts +9 -2
  48. package/dist/adapters/mcp/McpInvocation.d.ts.map +1 -1
  49. package/dist/adapters/mcp/McpInvocation.js.map +1 -1
  50. package/dist/cli/Accept.d.ts +9 -0
  51. package/dist/cli/Accept.d.ts.map +1 -0
  52. package/dist/cli/Accept.js +209 -0
  53. package/dist/cli/Accept.js.map +1 -0
  54. package/dist/cli/Actions.d.ts +16 -0
  55. package/dist/cli/Actions.d.ts.map +1 -0
  56. package/dist/cli/Actions.js +194 -0
  57. package/dist/cli/Actions.js.map +1 -0
  58. package/dist/cli/Arguments.d.ts +4 -0
  59. package/dist/cli/Arguments.d.ts.map +1 -1
  60. package/dist/cli/Arguments.js +12 -3
  61. package/dist/cli/Arguments.js.map +1 -1
  62. package/dist/cli/Commands.d.ts +1 -1
  63. package/dist/cli/Commands.d.ts.map +1 -1
  64. package/dist/cli/Commands.js +5 -0
  65. package/dist/cli/Commands.js.map +1 -1
  66. package/dist/cli/ConfigCommand.d.ts.map +1 -1
  67. package/dist/cli/ConfigCommand.js +10 -0
  68. package/dist/cli/ConfigCommand.js.map +1 -1
  69. package/dist/cli/Doctor.d.ts.map +1 -1
  70. package/dist/cli/Doctor.js +67 -1
  71. package/dist/cli/Doctor.js.map +1 -1
  72. package/dist/cli/Help.d.ts.map +1 -1
  73. package/dist/cli/Help.js +18 -1
  74. package/dist/cli/Help.js.map +1 -1
  75. package/dist/cli/Host.d.ts +5 -2
  76. package/dist/cli/Host.d.ts.map +1 -1
  77. package/dist/cli/Host.js +24 -2
  78. package/dist/cli/Host.js.map +1 -1
  79. package/dist/cli/Identity.d.ts +13 -1
  80. package/dist/cli/Identity.d.ts.map +1 -1
  81. package/dist/cli/Identity.js +25 -2
  82. package/dist/cli/Identity.js.map +1 -1
  83. package/dist/cli/Profile.d.ts +24 -0
  84. package/dist/cli/Profile.d.ts.map +1 -0
  85. package/dist/cli/Profile.js +168 -0
  86. package/dist/cli/Profile.js.map +1 -0
  87. package/dist/cli/Records.d.ts +15 -0
  88. package/dist/cli/Records.d.ts.map +1 -0
  89. package/dist/cli/Records.js +205 -0
  90. package/dist/cli/Records.js.map +1 -0
  91. package/dist/cli/Status.d.ts +23 -0
  92. package/dist/cli/Status.d.ts.map +1 -1
  93. package/dist/cli/Status.js +80 -18
  94. package/dist/cli/Status.js.map +1 -1
  95. package/dist/cli/VerifyAcceptance.d.ts +38 -0
  96. package/dist/cli/VerifyAcceptance.d.ts.map +1 -0
  97. package/dist/cli/VerifyAcceptance.js +143 -0
  98. package/dist/cli/VerifyAcceptance.js.map +1 -0
  99. package/dist/config/ConfigKeys.d.ts +2 -2
  100. package/dist/config/ConfigKeys.d.ts.map +1 -1
  101. package/dist/config/ConfigKeys.js +6 -0
  102. package/dist/config/ConfigKeys.js.map +1 -1
  103. package/dist/config/ExecutorConfig.d.ts +35 -1
  104. package/dist/config/ExecutorConfig.d.ts.map +1 -1
  105. package/dist/config/ExecutorConfig.js +53 -1
  106. package/dist/config/ExecutorConfig.js.map +1 -1
  107. package/dist/egress/ZoneHttpClient.d.ts +3 -0
  108. package/dist/egress/ZoneHttpClient.d.ts.map +1 -0
  109. package/dist/egress/ZoneHttpClient.js +72 -0
  110. package/dist/egress/ZoneHttpClient.js.map +1 -0
  111. package/dist/exposure/DecionisExposureLedger.d.ts +44 -0
  112. package/dist/exposure/DecionisExposureLedger.d.ts.map +1 -0
  113. package/dist/exposure/DecionisExposureLedger.js +175 -0
  114. package/dist/exposure/DecionisExposureLedger.js.map +1 -0
  115. package/dist/exposure/ExposureDeclaration.d.ts +68 -0
  116. package/dist/exposure/ExposureDeclaration.d.ts.map +1 -0
  117. package/dist/exposure/ExposureDeclaration.js +83 -0
  118. package/dist/exposure/ExposureDeclaration.js.map +1 -0
  119. package/dist/exposure/ExposureFacts.d.ts +61 -0
  120. package/dist/exposure/ExposureFacts.d.ts.map +1 -0
  121. package/dist/exposure/ExposureFacts.js +201 -0
  122. package/dist/exposure/ExposureFacts.js.map +1 -0
  123. package/dist/exposure/ExposureGate.d.ts +144 -0
  124. package/dist/exposure/ExposureGate.d.ts.map +1 -0
  125. package/dist/exposure/ExposureGate.js +446 -0
  126. package/dist/exposure/ExposureGate.js.map +1 -0
  127. package/dist/exposure/ExposureLedger.d.ts +93 -0
  128. package/dist/exposure/ExposureLedger.d.ts.map +1 -0
  129. package/dist/exposure/ExposureLedger.js +24 -0
  130. package/dist/exposure/ExposureLedger.js.map +1 -0
  131. package/dist/gateway/AttemptStore.d.ts +83 -0
  132. package/dist/gateway/AttemptStore.d.ts.map +1 -0
  133. package/dist/gateway/AttemptStore.js +229 -0
  134. package/dist/gateway/AttemptStore.js.map +1 -0
  135. package/dist/gateway/ForwardHandler.d.ts +50 -6
  136. package/dist/gateway/ForwardHandler.d.ts.map +1 -1
  137. package/dist/gateway/ForwardHandler.js +58 -14
  138. package/dist/gateway/ForwardHandler.js.map +1 -1
  139. package/dist/gateway/Gateway.d.ts +347 -15
  140. package/dist/gateway/Gateway.d.ts.map +1 -1
  141. package/dist/gateway/Gateway.js +1524 -63
  142. package/dist/gateway/Gateway.js.map +1 -1
  143. package/dist/gateway/GatewayConfig.d.ts +295 -0
  144. package/dist/gateway/GatewayConfig.d.ts.map +1 -1
  145. package/dist/gateway/GatewayConfig.js +485 -13
  146. package/dist/gateway/GatewayConfig.js.map +1 -1
  147. package/dist/gateway/GatewayManifest.d.ts +18 -0
  148. package/dist/gateway/GatewayManifest.d.ts.map +1 -0
  149. package/dist/gateway/GatewayManifest.js +42 -0
  150. package/dist/gateway/GatewayManifest.js.map +1 -0
  151. package/dist/gateway/GatewayMetrics.d.ts +12 -4
  152. package/dist/gateway/GatewayMetrics.d.ts.map +1 -1
  153. package/dist/gateway/GatewayMetrics.js +5 -0
  154. package/dist/gateway/GatewayMetrics.js.map +1 -1
  155. package/dist/gateway/GatewayReport.d.ts +39 -2
  156. package/dist/gateway/GatewayReport.d.ts.map +1 -1
  157. package/dist/gateway/GatewayReport.js +14 -0
  158. package/dist/gateway/GatewayReport.js.map +1 -1
  159. package/dist/gateway/HoldStore.d.ts +89 -0
  160. package/dist/gateway/HoldStore.d.ts.map +1 -0
  161. package/dist/gateway/HoldStore.js +280 -0
  162. package/dist/gateway/HoldStore.js.map +1 -0
  163. package/dist/gateway/InterceptedRequest.d.ts +55 -1
  164. package/dist/gateway/InterceptedRequest.d.ts.map +1 -1
  165. package/dist/gateway/InterceptedRequest.js +63 -1
  166. package/dist/gateway/InterceptedRequest.js.map +1 -1
  167. package/dist/gateway/PolicySelector.d.ts +5 -0
  168. package/dist/gateway/PolicySelector.d.ts.map +1 -0
  169. package/dist/gateway/PolicySelector.js +9 -0
  170. package/dist/gateway/PolicySelector.js.map +1 -0
  171. package/dist/gateway/RouteTable.d.ts +72 -7
  172. package/dist/gateway/RouteTable.d.ts.map +1 -1
  173. package/dist/gateway/RouteTable.js +133 -9
  174. package/dist/gateway/RouteTable.js.map +1 -1
  175. package/dist/gateway/ShadowLedger.d.ts +11 -0
  176. package/dist/gateway/ShadowLedger.d.ts.map +1 -1
  177. package/dist/gateway/ShadowLedger.js +11 -0
  178. package/dist/gateway/ShadowLedger.js.map +1 -1
  179. package/dist/gateway/SubjectSessions.d.ts +113 -0
  180. package/dist/gateway/SubjectSessions.d.ts.map +1 -0
  181. package/dist/gateway/SubjectSessions.js +219 -0
  182. package/dist/gateway/SubjectSessions.js.map +1 -0
  183. package/dist/gateway/TargetEffect.d.ts +74 -0
  184. package/dist/gateway/TargetEffect.d.ts.map +1 -0
  185. package/dist/gateway/TargetEffect.js +95 -0
  186. package/dist/gateway/TargetEffect.js.map +1 -0
  187. package/dist/gateway/TargetReader.d.ts +70 -0
  188. package/dist/gateway/TargetReader.d.ts.map +1 -0
  189. package/dist/gateway/TargetReader.js +106 -0
  190. package/dist/gateway/TargetReader.js.map +1 -0
  191. package/dist/gateway/Upstream.d.ts +26 -0
  192. package/dist/gateway/Upstream.d.ts.map +1 -1
  193. package/dist/gateway/Upstream.js +42 -3
  194. package/dist/gateway/Upstream.js.map +1 -1
  195. package/dist/hosted/TenantHost.d.ts +26 -6
  196. package/dist/hosted/TenantHost.d.ts.map +1 -1
  197. package/dist/hosted/TenantHost.js +45 -10
  198. package/dist/hosted/TenantHost.js.map +1 -1
  199. package/dist/hosted/TenantRegistry.d.ts +28 -0
  200. package/dist/hosted/TenantRegistry.d.ts.map +1 -1
  201. package/dist/hosted/TenantRegistry.js +60 -1
  202. package/dist/hosted/TenantRegistry.js.map +1 -1
  203. package/dist/http/GatewayHttpServer.d.ts +7 -0
  204. package/dist/http/GatewayHttpServer.d.ts.map +1 -1
  205. package/dist/http/GatewayHttpServer.js +103 -3
  206. package/dist/http/GatewayHttpServer.js.map +1 -1
  207. package/dist/identity/WorkloadJwtVerifier.d.ts +13 -0
  208. package/dist/identity/WorkloadJwtVerifier.d.ts.map +1 -1
  209. package/dist/identity/WorkloadJwtVerifier.js +40 -8
  210. package/dist/identity/WorkloadJwtVerifier.js.map +1 -1
  211. package/dist/incident/HaltSwitch.d.ts +10 -2
  212. package/dist/incident/HaltSwitch.d.ts.map +1 -1
  213. package/dist/incident/HaltSwitch.js +22 -2
  214. package/dist/incident/HaltSwitch.js.map +1 -1
  215. package/dist/incident/SecurityEvents.d.ts +18 -0
  216. package/dist/incident/SecurityEvents.d.ts.map +1 -1
  217. package/dist/incident/SecurityEvents.js +17 -0
  218. package/dist/incident/SecurityEvents.js.map +1 -1
  219. package/dist/limits/HardLimits.d.ts.map +1 -1
  220. package/dist/limits/HardLimits.js.map +1 -1
  221. package/dist/outcomes/CardOutcomeEvidence.d.ts +56 -0
  222. package/dist/outcomes/CardOutcomeEvidence.d.ts.map +1 -0
  223. package/dist/outcomes/CardOutcomeEvidence.js +211 -0
  224. package/dist/outcomes/CardOutcomeEvidence.js.map +1 -0
  225. package/dist/outcomes/CardOutcomeFact.d.ts +90 -0
  226. package/dist/outcomes/CardOutcomeFact.d.ts.map +1 -0
  227. package/dist/outcomes/CardOutcomeFact.js +76 -0
  228. package/dist/outcomes/CardOutcomeFact.js.map +1 -0
  229. package/dist/outcomes/CardOutcomeLedger.d.ts +26 -0
  230. package/dist/outcomes/CardOutcomeLedger.d.ts.map +1 -0
  231. package/dist/outcomes/CardOutcomeLedger.js +31 -0
  232. package/dist/outcomes/CardOutcomeLedger.js.map +1 -0
  233. package/dist/outcomes/CardOutcomeRecorder.d.ts +35 -0
  234. package/dist/outcomes/CardOutcomeRecorder.d.ts.map +1 -0
  235. package/dist/outcomes/CardOutcomeRecorder.js +84 -0
  236. package/dist/outcomes/CardOutcomeRecorder.js.map +1 -0
  237. package/dist/outcomes/CardOutcomes.d.ts +68 -0
  238. package/dist/outcomes/CardOutcomes.d.ts.map +1 -0
  239. package/dist/outcomes/CardOutcomes.js +191 -0
  240. package/dist/outcomes/CardOutcomes.js.map +1 -0
  241. package/dist/outcomes/CoreOutcomeEvidenceClient.d.ts +54 -0
  242. package/dist/outcomes/CoreOutcomeEvidenceClient.d.ts.map +1 -0
  243. package/dist/outcomes/CoreOutcomeEvidenceClient.js +116 -0
  244. package/dist/outcomes/CoreOutcomeEvidenceClient.js.map +1 -0
  245. package/dist/outcomes/FileCardOutcomeLedger.d.ts +36 -0
  246. package/dist/outcomes/FileCardOutcomeLedger.d.ts.map +1 -0
  247. package/dist/outcomes/FileCardOutcomeLedger.js +152 -0
  248. package/dist/outcomes/FileCardOutcomeLedger.js.map +1 -0
  249. package/dist/outcomes/OutcomeEvidence.d.ts +238 -0
  250. package/dist/outcomes/OutcomeEvidence.d.ts.map +1 -0
  251. package/dist/outcomes/OutcomeEvidence.js +130 -0
  252. package/dist/outcomes/OutcomeEvidence.js.map +1 -0
  253. package/dist/outcomes/OutcomeEvidencePublisher.d.ts +81 -0
  254. package/dist/outcomes/OutcomeEvidencePublisher.d.ts.map +1 -0
  255. package/dist/outcomes/OutcomeEvidencePublisher.js +189 -0
  256. package/dist/outcomes/OutcomeEvidencePublisher.js.map +1 -0
  257. package/dist/outcomes/OutcomeEvidenceStore.d.ts +57 -0
  258. package/dist/outcomes/OutcomeEvidenceStore.d.ts.map +1 -0
  259. package/dist/outcomes/OutcomeEvidenceStore.js +191 -0
  260. package/dist/outcomes/OutcomeEvidenceStore.js.map +1 -0
  261. package/dist/posture/ActionSpaceDrift.d.ts +40 -0
  262. package/dist/posture/ActionSpaceDrift.d.ts.map +1 -0
  263. package/dist/posture/ActionSpaceDrift.js +67 -0
  264. package/dist/posture/ActionSpaceDrift.js.map +1 -0
  265. package/dist/posture/DeploymentFingerprint.d.ts +88 -0
  266. package/dist/posture/DeploymentFingerprint.d.ts.map +1 -0
  267. package/dist/posture/DeploymentFingerprint.js +78 -0
  268. package/dist/posture/DeploymentFingerprint.js.map +1 -0
  269. package/dist/secrets/SecretStore.d.ts +6 -1
  270. package/dist/secrets/SecretStore.d.ts.map +1 -1
  271. package/dist/secrets/SecretStore.js.map +1 -1
  272. package/dist/service/EscalationResolver.d.ts +6 -6
  273. package/dist/service/EscalationResolver.d.ts.map +1 -1
  274. package/dist/service/EscalationResolver.js +8 -4
  275. package/dist/service/EscalationResolver.js.map +1 -1
  276. package/dist/service/Requests.d.ts +6 -0
  277. package/dist/service/Requests.d.ts.map +1 -1
  278. package/dist/service/Requests.js +9 -1
  279. package/dist/service/Requests.js.map +1 -1
  280. package/dist/service/TrustedExecutorService.d.ts +21 -1
  281. package/dist/service/TrustedExecutorService.d.ts.map +1 -1
  282. package/dist/service/TrustedExecutorService.js +54 -13
  283. package/dist/service/TrustedExecutorService.js.map +1 -1
  284. package/dist/verify/VerifyingProvider.d.ts +32 -6
  285. package/dist/verify/VerifyingProvider.d.ts.map +1 -1
  286. package/dist/verify/VerifyingProvider.js +16 -2
  287. package/dist/verify/VerifyingProvider.js.map +1 -1
  288. package/package.json +7 -6
@@ -0,0 +1,488 @@
1
+ import { generateKeyPairSync, randomBytes, randomUUID } from "node:crypto";
2
+ import { existsSync } from "node:fs";
3
+ import { delimiter, join } from "node:path";
4
+ import { z } from "zod";
5
+ import { verdictFor } from "../containment/ContainmentProbe.js";
6
+ import { SignedRequestCredential } from "../credential/SignedRequestCredential.js";
7
+ import { SecretHandle } from "../secrets/SecretHandle.js";
8
+ /** Bounds on what the zone may report, which `zoneFindingsSchema` enforces. */
9
+ export const ZONE_LIMITS = Object.freeze({
10
+ /** Origins, providers and MCP servers, each. */
11
+ targets: 64,
12
+ credentials: 512,
13
+ /** A plan label. */
14
+ name: 256,
15
+ /** A host and port, IPv6 brackets included. */
16
+ address: 300,
17
+ /** An environment variable's name, or a file's. */
18
+ credentialName: 1_024,
19
+ });
20
+ /** What a finding says a credential is. A fixed word, never derived from the value's text. */
21
+ export const CREDENTIAL_KINDS = [
22
+ "jwt",
23
+ "pem-private-key",
24
+ "url-with-userinfo",
25
+ "aws-access-key",
26
+ "aws-secret-key",
27
+ "aws-session-token",
28
+ "azure-client-secret",
29
+ "github-token",
30
+ "credential-file-path",
31
+ "secret-like",
32
+ "service-account-token",
33
+ "web-identity-token",
34
+ "aws-credentials",
35
+ "gcp-credentials",
36
+ "azure-cli-credentials",
37
+ "kubeconfig",
38
+ "docker-config",
39
+ "netrc",
40
+ "npmrc",
41
+ ];
42
+ export const METADATA_URL = "http://169.254.169.254/";
43
+ const DEFAULT_TIMEOUT_MS = 5_000;
44
+ const METADATA_TIMEOUT_MS = 2_000;
45
+ /** Enough for a refusal's JSON; the rest of a body is not read. */
46
+ const REFUSAL_BODY_BYTES = 4_096;
47
+ const ANSWERED = "ANSWERED";
48
+ const UNKNOWN = "UNKNOWN";
49
+ const CODE = /^[A-Z][A-Z0-9_]{0,63}$/;
50
+ const KEY_ID = /^agentsafe-acceptance-[0-9a-f]{32}$/;
51
+ const SCHEMES = new Set(["http:", "https:"]);
52
+ /** A value that is a code, or null. A message, a value or anything else is not kept. */
53
+ function code(value) {
54
+ return typeof value === "string" && CODE.test(value) ? value : null;
55
+ }
56
+ function codeOf(error) {
57
+ return code(error?.code) ?? UNKNOWN;
58
+ }
59
+ /** The status's class, `2` for `2xx`; `0` for no answer. */
60
+ function classOf(status) {
61
+ return Math.floor((status ?? 0) / 100);
62
+ }
63
+ /**
64
+ * A target the zone can probe: an `http` or `https` URL with no userinfo. One
65
+ * the operator cannot spell is refused rather than probed, and the error names
66
+ * the plan's label, never the URL, which could carry a credential.
67
+ */
68
+ function targetOf(target) {
69
+ const url = URL.parse(target.url);
70
+ if (url === null || !SCHEMES.has(url.protocol) || url.username !== "" || url.password !== "") {
71
+ throw new Error(`ZONE_TARGET_INVALID: ${target.name}`);
72
+ }
73
+ const port = url.port === "" ? (url.protocol === "https:" ? 443 : 80) : Number(url.port);
74
+ const host = url.hostname.startsWith("[") ? url.hostname.slice(1, -1) : url.hostname;
75
+ return { url, host, port, address: `${url.hostname}:${String(port)}` };
76
+ }
77
+ /** A base URL's origin and path prefix, with a path and query appended. */
78
+ function under(base, pathAndQuery) {
79
+ const { url } = targetOf(base);
80
+ const prefix = url.pathname.endsWith("/") ? url.pathname.slice(0, -1) : url.pathname;
81
+ return `${url.origin}${prefix}${pathAndQuery}`;
82
+ }
83
+ async function exchange(http, request) {
84
+ try {
85
+ const response = await http(request);
86
+ return { status: response.status, detail: ANSWERED, body: response.body };
87
+ }
88
+ catch (error) {
89
+ return { status: null, detail: codeOf(error), body: null };
90
+ }
91
+ }
92
+ /**
93
+ * Dial, then read only if the dial connected. The verdict is the dial's: a
94
+ * connection that answered is a hole whatever the read did next, and a read is
95
+ * never sent where the dial met silence or a refusal.
96
+ */
97
+ async function directRead(target, options, timeoutMs) {
98
+ const outcome = await options.dial(target.host, target.port, timeoutMs);
99
+ if (outcome.state !== "CONNECTED") {
100
+ const { verdict, detail } = verdictFor(outcome);
101
+ return { status: null, detail: code(detail) ?? UNKNOWN, verdict };
102
+ }
103
+ const read = await exchange(options.http, {
104
+ method: "GET",
105
+ url: target.url.href,
106
+ headers: {},
107
+ body: null,
108
+ timeoutMs,
109
+ maxBodyBytes: 0,
110
+ });
111
+ return { status: read.status, detail: read.detail, verdict: "REACHABLE" };
112
+ }
113
+ const now = (options) => (options.clock ?? (() => new Date()))().toISOString();
114
+ /**
115
+ * Read one origin directly and through the gateway. The direct read is a
116
+ * `GET` of the plan's read URL with no header the probe sets, after a dial to
117
+ * its host and port; the control is the same path and query through the
118
+ * gateway, with the gateway's headers. Both are sent whatever the first one
119
+ * did, so the report shows the gateway path working beside every verdict.
120
+ *
121
+ * It establishes that an origin answered from the zone (`REACHABLE`). It
122
+ * never establishes that the origin is unreachable: `CONTAINED` says only that
123
+ * the zone met silence while the gateway's path worked.
124
+ */
125
+ export async function probeOrigin(origin, options) {
126
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
127
+ const target = targetOf(origin);
128
+ const controlUrl = under({ name: "gateway", url: options.gateway }, `${target.url.pathname}${target.url.search}`);
129
+ const direct = await directRead(target, options, timeoutMs);
130
+ const control = await exchange(options.http, {
131
+ method: "GET",
132
+ url: controlUrl,
133
+ headers: options.gatewayHeaders ?? {},
134
+ body: null,
135
+ timeoutMs,
136
+ maxBodyBytes: 0,
137
+ });
138
+ const verdict = direct.verdict !== "CONTAINED"
139
+ ? direct.verdict
140
+ : classOf(control.status) === 2
141
+ ? "CONTAINED"
142
+ : "INCONCLUSIVE";
143
+ return {
144
+ name: origin.name,
145
+ address: target.address,
146
+ direct: { status: direct.status, detail: direct.detail },
147
+ control: { status: control.status, detail: control.detail },
148
+ verdict,
149
+ at: now(options),
150
+ };
151
+ }
152
+ async function attempt(http, request) {
153
+ const answer = await exchange(http, request);
154
+ return { status: answer.status, reason_code: reasonCodeOf(answer.body), detail: answer.detail };
155
+ }
156
+ /**
157
+ * The `reason_code` a refusal's JSON body names, when it is a code. Nothing
158
+ * else of the body survives. No body reads as the text `null`, which, like a
159
+ * body that is not JSON, throws on the way and names none.
160
+ */
161
+ function reasonCodeOf(body) {
162
+ try {
163
+ return code(JSON.parse(String(body)).reason_code);
164
+ }
165
+ catch {
166
+ return null;
167
+ }
168
+ }
169
+ /**
170
+ * Headers for one write, signed (RFC 9421, Ed25519) with a key generated here
171
+ * for this request alone. The provider has never seen the key, so a provider
172
+ * that verifies refuses it; the signature is otherwise well formed, so the
173
+ * refusal is about the key and not the shape.
174
+ */
175
+ async function unknownKeyHeaders(request, clock) {
176
+ const keyId = `agentsafe-acceptance-${randomBytes(16).toString("hex")}`;
177
+ // The key lives in this call's scope and nowhere else. Its public half is
178
+ // never exported, so no provider could have registered it.
179
+ const pem = generateKeyPairSync("ed25519").privateKey.export({ type: "pkcs8", format: "pem" });
180
+ const handle = SecretHandle.fromString(keyId, String(pem));
181
+ const credential = new SignedRequestCredential({ algorithm: "ed25519", keyId }, () => handle, () => clock().getTime());
182
+ const headers = await credential.headersFor({
183
+ // The credential covers whatever method it is handed; the type names the
184
+ // two a handler sends, and a plan's write may use another.
185
+ method: request.method,
186
+ url: request.url,
187
+ body: request.body,
188
+ idempotencyKey: randomUUID(),
189
+ intentHash: `sha256:${randomBytes(32).toString("hex")}`,
190
+ });
191
+ return { keyId, headers };
192
+ }
193
+ /**
194
+ * Send the plan's write to a verifying provider twice, from the zone: first
195
+ * with no signature, then signed with a key the provider cannot know. A
196
+ * provider that holds the boundary refuses both with a `4xx`.
197
+ *
198
+ * It establishes how this provider answered these two requests. It does not
199
+ * establish that the provider refuses a grant replayed or altered after
200
+ * issuance: the zone holds no grant to try, and those refusals are the
201
+ * build's to show (the provider conformance vectors).
202
+ */
203
+ export async function probeProvider(provider, options) {
204
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
205
+ const clock = options.clock ?? (() => new Date());
206
+ if (!provider.write.path.startsWith("/"))
207
+ throw new Error(`ZONE_TARGET_INVALID: ${provider.name}`);
208
+ const write = {
209
+ method: provider.write.method.toUpperCase(),
210
+ url: under(provider, provider.write.path),
211
+ body: provider.write.body,
212
+ };
213
+ const base = { ...write, timeoutMs, maxBodyBytes: REFUSAL_BODY_BYTES };
214
+ const json = write.body === null ? {} : { "content-type": "application/json" };
215
+ const unattested = await attempt(options.http, { ...base, headers: json });
216
+ if (classOf(unattested.status) === 2) {
217
+ return {
218
+ name: provider.name,
219
+ unattested,
220
+ signed: null,
221
+ verdict: "ACCEPTED",
222
+ at: clock().toISOString(),
223
+ };
224
+ }
225
+ const { keyId, headers } = await unknownKeyHeaders(write, clock);
226
+ const signed = {
227
+ ...(await attempt(options.http, { ...base, headers: { ...json, ...headers } })),
228
+ key_id: keyId,
229
+ };
230
+ const verdict = classOf(signed.status) === 2
231
+ ? "ACCEPTED"
232
+ : classOf(unattested.status) === 4 && classOf(signed.status) === 4
233
+ ? "REFUSED"
234
+ : "INCONCLUSIVE";
235
+ return { name: provider.name, unattested, signed, verdict, at: clock().toISOString() };
236
+ }
237
+ /**
238
+ * Dial every MCP server's host and port once, in order. No MCP message is
239
+ * sent, so a finding says a server answered the zone, never that it would
240
+ * serve a tool call.
241
+ */
242
+ export async function probeMcp(servers, options) {
243
+ const timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
244
+ const findings = [];
245
+ for (const server of servers) {
246
+ const target = targetOf(server);
247
+ const { verdict, detail } = verdictFor(await options.dial(target.host, target.port, timeoutMs));
248
+ findings.push({
249
+ name: server.name,
250
+ address: target.address,
251
+ verdict,
252
+ detail: code(detail) ?? UNKNOWN,
253
+ at: now(options),
254
+ });
255
+ }
256
+ return findings;
257
+ }
258
+ /**
259
+ * Read the cloud metadata endpoint with a bare `GET /`: no header, no token,
260
+ * no path, and a short timeout. Run only when the plan names it. A metadata
261
+ * service that answers at all is reported as `REACHABLE`, since the headers
262
+ * it would need to hand out credentials are the zone's to send.
263
+ */
264
+ export async function probeMetadata(options) {
265
+ const target = targetOf({ name: "metadata", url: options.url ?? METADATA_URL });
266
+ const read = await directRead(target, options, options.timeoutMs ?? METADATA_TIMEOUT_MS);
267
+ return {
268
+ address: target.address,
269
+ status: read.status,
270
+ detail: read.detail,
271
+ verdict: read.verdict,
272
+ at: now(options),
273
+ };
274
+ }
275
+ /** Variables whose name says what they hold. */
276
+ const NAMED_KINDS = new Map([
277
+ ["AWS_ACCESS_KEY_ID", "aws-access-key"],
278
+ ["AWS_SECRET_ACCESS_KEY", "aws-secret-key"],
279
+ ["AWS_SESSION_TOKEN", "aws-session-token"],
280
+ ["AZURE_CLIENT_SECRET", "azure-client-secret"],
281
+ ["GITHUB_TOKEN", "github-token"],
282
+ ["GH_TOKEN", "github-token"],
283
+ ["GOOGLE_APPLICATION_CREDENTIALS", "credential-file-path"],
284
+ ["AWS_SHARED_CREDENTIALS_FILE", "credential-file-path"],
285
+ ["AWS_WEB_IDENTITY_TOKEN_FILE", "credential-file-path"],
286
+ ["AZURE_FEDERATED_TOKEN_FILE", "credential-file-path"],
287
+ ]);
288
+ /**
289
+ * What a variable's name ends a word with when it holds a credential, the
290
+ * name split into words at anything not a letter and where a lower case
291
+ * letter meets a capital. A term matches the end of a word, so `AUTHTOKEN`
292
+ * and `TOKEN2` match and `TOKENIZERS` does not; `TOKENS` is left out because
293
+ * `MAX_TOKENS` is a model setting, not a secret.
294
+ */
295
+ const NAME_TERMS = [
296
+ "TOKEN",
297
+ "SECRET",
298
+ "SECRETS",
299
+ "PASSWORD",
300
+ "PASSWORDS",
301
+ "PASSWD",
302
+ "CREDENTIAL",
303
+ "CREDENTIALS",
304
+ "APIKEY",
305
+ "API_KEY",
306
+ "ACCESSKEY",
307
+ "ACCESS_KEY",
308
+ "PRIVATEKEY",
309
+ "PRIVATE_KEY",
310
+ "SESSION_KEY",
311
+ "COOKIE",
312
+ "COOKIES",
313
+ "AUTH",
314
+ "AUTHORIZATION",
315
+ ];
316
+ function credentialName(name) {
317
+ const words = `${name
318
+ .replace(/([a-z])([A-Z])/g, "$1_$2")
319
+ .toUpperCase()
320
+ .split(/[^A-Z]+/)
321
+ .join("_")}_`;
322
+ // A session is a credential when it ends the name (`APP_SESSION`), not when
323
+ // it qualifies something else (`TERM_SESSION_ID`).
324
+ return NAME_TERMS.some((term) => words.includes(`${term}_`)) || words.endsWith("SESSION_");
325
+ }
326
+ const JWT = /^eyJ[\w-]+\.[\w-]+\.[\w-]*$/;
327
+ const AWS_KEY_ID = /^(?:AKIA|ASIA)[A-Z0-9]{16}$/;
328
+ /** What a value's shape says it is, or null. Only the kind leaves this function. */
329
+ function shapeOf(value) {
330
+ if (JWT.test(value))
331
+ return "jwt";
332
+ if (value.includes("-----BEGIN ") && value.includes("PRIVATE KEY-----"))
333
+ return "pem-private-key";
334
+ if (AWS_KEY_ID.test(value))
335
+ return "aws-access-key";
336
+ const url = URL.parse(value);
337
+ return url !== null && (url.username !== "" || url.password !== "") ? "url-with-userinfo" : null;
338
+ }
339
+ /** Files that hold a credential wherever they exist. */
340
+ const WELL_KNOWN_FILES = [
341
+ {
342
+ path: "/var/run/secrets/kubernetes.io/serviceaccount/token",
343
+ home: false,
344
+ kind: "service-account-token",
345
+ },
346
+ { path: ".aws/credentials", home: true, kind: "aws-credentials" },
347
+ {
348
+ path: ".config/gcloud/application_default_credentials.json",
349
+ home: true,
350
+ kind: "gcp-credentials",
351
+ },
352
+ { path: ".azure/msal_token_cache.json", home: true, kind: "azure-cli-credentials" },
353
+ { path: ".azure/accessTokens.json", home: true, kind: "azure-cli-credentials" },
354
+ { path: ".azure/service_principal_entries.json", home: true, kind: "azure-cli-credentials" },
355
+ { path: ".kube/config", home: true, kind: "kubeconfig" },
356
+ { path: ".docker/config.json", home: true, kind: "docker-config" },
357
+ { path: ".netrc", home: true, kind: "netrc" },
358
+ { path: ".npmrc", home: true, kind: "npmrc" },
359
+ ];
360
+ /** Variables that name a credential file, or a list of them. */
361
+ const NAMED_FILES = [
362
+ ["GOOGLE_APPLICATION_CREDENTIALS", "gcp-credentials"],
363
+ ["AWS_SHARED_CREDENTIALS_FILE", "aws-credentials"],
364
+ ["AWS_WEB_IDENTITY_TOKEN_FILE", "web-identity-token"],
365
+ ["AZURE_FEDERATED_TOKEN_FILE", "web-identity-token"],
366
+ ["KUBECONFIG", "kubeconfig"],
367
+ ];
368
+ /**
369
+ * List the credentials the zone holds, by name and kind, environment first in
370
+ * name order, then files in a fixed order.
371
+ *
372
+ * An environment variable is reported when its value is shaped like a JWT, a
373
+ * PEM private key, an AWS access key id or a URL with userinfo, when its name
374
+ * is one whose meaning is known, when its name reads as a credential's, or
375
+ * when the caller names it as the run's own. A variable with an empty value is
376
+ * not. The kind is the value's shape when it has one, then the known name's,
377
+ * then `secret-like`.
378
+ *
379
+ * A file is reported when it exists at a path where a credential is kept: the
380
+ * Kubernetes service-account token, the AWS, gcloud and Azure CLI stores,
381
+ * `~/.kube/config`, `~/.docker/config.json`, `~/.netrc`, `~/.npmrc`, and the
382
+ * files `GOOGLE_APPLICATION_CREDENTIALS` and its kin name. Files are never
383
+ * opened, so a file that holds no credential is reported too; and a variable
384
+ * that names a file is reported as `$VARIABLE`, since its value could be the
385
+ * credential itself rather than a path.
386
+ *
387
+ * It establishes what the zone holds at those names. It does not establish
388
+ * that the zone holds nothing else: a credential under an ordinary name, in an
389
+ * ordinary file, or in a process's memory is not seen.
390
+ */
391
+ export function scanCredentials(options) {
392
+ const own = new Set(options.own);
393
+ const exists = options.exists ?? existsSync;
394
+ const findings = [];
395
+ for (const name of Object.keys(options.env).sort()) {
396
+ const value = options.env[name];
397
+ if (value === undefined || value === "")
398
+ continue;
399
+ const kind = shapeOf(value) ??
400
+ NAMED_KINDS.get(name) ??
401
+ (credentialName(name) || own.has(name) ? "secret-like" : null);
402
+ if (kind !== null)
403
+ findings.push({ source: "environment", name, kind, own: own.has(name) });
404
+ }
405
+ for (const file of WELL_KNOWN_FILES) {
406
+ const name = file.home ? `~/${file.path}` : file.path;
407
+ if (exists(file.home ? join(options.home, file.path) : file.path)) {
408
+ findings.push({ source: "file", name, kind: file.kind, own: own.has(name) });
409
+ }
410
+ }
411
+ for (const [variable, kind] of NAMED_FILES) {
412
+ const value = options.env[variable];
413
+ if (value === undefined)
414
+ continue;
415
+ const name = `$${variable}`;
416
+ if (value.split(delimiter).some((path) => exists(path))) {
417
+ findings.push({ source: "file", name, kind, own: own.has(name) });
418
+ }
419
+ }
420
+ return findings;
421
+ }
422
+ const zoneName = z.string().min(1).max(ZONE_LIMITS.name);
423
+ const zoneAddress = z.string().min(1).max(ZONE_LIMITS.address);
424
+ const zoneCode = z.string().regex(CODE);
425
+ const zoneStatus = z.int().min(100).max(999).nullable();
426
+ const zoneVerdict = z.enum(["REACHABLE", "CONTAINED", "INCONCLUSIVE"]);
427
+ const zoneAt = z.iso.datetime();
428
+ const zoneExchange = z.strictObject({ status: zoneStatus, detail: zoneCode });
429
+ const providerAttempt = {
430
+ status: zoneStatus,
431
+ reason_code: zoneCode.nullable(),
432
+ detail: zoneCode,
433
+ };
434
+ /**
435
+ * The zone's findings, as the gateway parses them when a run closes. Closed
436
+ * at every level, bounded in every array and string, and with no field that
437
+ * can carry a credential's value: a kind is one of `CREDENTIAL_KINDS`, a
438
+ * detail and a reason are codes. It checks the form of what the zone said,
439
+ * not its truth.
440
+ */
441
+ export const zoneFindingsSchema = z.strictObject({
442
+ origins: z
443
+ .array(z.strictObject({
444
+ name: zoneName,
445
+ address: zoneAddress,
446
+ direct: zoneExchange,
447
+ control: zoneExchange,
448
+ verdict: zoneVerdict,
449
+ at: zoneAt,
450
+ }))
451
+ .max(ZONE_LIMITS.targets),
452
+ providers: z
453
+ .array(z.strictObject({
454
+ name: zoneName,
455
+ unattested: z.strictObject(providerAttempt),
456
+ signed: z.strictObject({ ...providerAttempt, key_id: z.string().regex(KEY_ID) }).nullable(),
457
+ verdict: z.enum(["REFUSED", "ACCEPTED", "INCONCLUSIVE"]),
458
+ at: zoneAt,
459
+ }))
460
+ .max(ZONE_LIMITS.targets),
461
+ mcp: z
462
+ .array(z.strictObject({
463
+ name: zoneName,
464
+ address: zoneAddress,
465
+ verdict: zoneVerdict,
466
+ detail: zoneCode,
467
+ at: zoneAt,
468
+ }))
469
+ .max(ZONE_LIMITS.targets),
470
+ credentials: z
471
+ .array(z.strictObject({
472
+ source: z.enum(["environment", "file"]),
473
+ name: z.string().min(1).max(ZONE_LIMITS.credentialName),
474
+ kind: z.enum(CREDENTIAL_KINDS),
475
+ own: z.boolean(),
476
+ }))
477
+ .max(ZONE_LIMITS.credentials),
478
+ metadata: z
479
+ .strictObject({
480
+ address: zoneAddress,
481
+ status: zoneStatus,
482
+ detail: zoneCode,
483
+ verdict: zoneVerdict,
484
+ at: zoneAt,
485
+ })
486
+ .nullable(),
487
+ });
488
+ //# sourceMappingURL=ZoneProbes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ZoneProbes.js","sourceRoot":"","sources":["../../src/acceptance/ZoneProbes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC3E,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAA2B,MAAM,oCAAoC,CAAC;AAEzF,OAAO,EAAE,uBAAuB,EAAE,MAAM,0CAA0C,CAAC;AAEnF,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B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AAM,EAAE,QAAQ;QAChB,EAAE,EAAE,MAAM;KACX,CAAC,CACH;SACA,GAAG,CAAC,WAAW,CAAC,OAAO,CAAC;IAC3B,WAAW,EAAE,CAAC;SACX,KAAK,CACJ,CAAC,CAAC,YAAY,CAAC;QACb,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,aAAa,EAAE,MAAM,CAAC,CAAC;QACvC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,CAAC,cAAc,CAAC;QACvD,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC;QAC9B,GAAG,EAAE,CAAC,CAAC,OAAO,EAAE;KACjB,CAAC,CACH;SACA,GAAG,CAAC,WAAW,CAAC,WAAW,CAAC;IAC/B,QAAQ,EAAE,CAAC;SACR,YAAY,CAAC;QACZ,OAAO,EAAE,WAAW;QACpB,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,QAAQ;QAChB,OAAO,EAAE,WAAW;QACpB,EAAE,EAAE,MAAM;KACX,CAAC;SACD,QAAQ,EAAE;CACd,CAAC,CAAC"}
@@ -7,11 +7,12 @@ export declare class JcsError extends Error {
7
7
  }
8
8
  /**
9
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.
10
+ * form of the value. The canonicaliser is the pipeline's `Rfc8785`, which
11
+ * sorts every key by UTF-16 code unit and serialises numbers and strings the
12
+ * way ECMAScript does; for I-JSON input those are RFC 8785's rules, and the
13
+ * authority's payload digest and every verifier in another language apply
14
+ * them. It is not the intent's canonical form, which puts array-index keys
15
+ * first (spec/intent/v1 §4), so `{"10":…,"9":…}` keeps that order here.
15
16
  *
16
17
  * What the canonicaliser does not do is refuse input that is not I-JSON, so
17
18
  * this adds that gate: a lone surrogate would serialise differently in
@@ -1 +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"}
1
+ {"version":3,"file":"JcsDigest.d.ts","sourceRoot":"","sources":["../../src/adapters/JcsDigest.ts"],"names":[],"mappings":"AACA,OAAO,EAAW,KAAK,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAExE,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;;;;;;;;;;;;;;GAcG;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"}
@@ -1,5 +1,5 @@
1
1
  import { createHash } from "node:crypto";
2
- import { CanonicalIntentHasher } from "@decionis/agent-safe-pipeline";
2
+ import { Rfc8785 } from "@decionis/agent-safe-pipeline";
3
3
  export class JcsError extends Error {
4
4
  code;
5
5
  constructor(code) {
@@ -10,11 +10,12 @@ export class JcsError extends Error {
10
10
  }
11
11
  /**
12
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.
13
+ * form of the value. The canonicaliser is the pipeline's `Rfc8785`, which
14
+ * sorts every key by UTF-16 code unit and serialises numbers and strings the
15
+ * way ECMAScript does; for I-JSON input those are RFC 8785's rules, and the
16
+ * authority's payload digest and every verifier in another language apply
17
+ * them. It is not the intent's canonical form, which puts array-index keys
18
+ * first (spec/intent/v1 §4), so `{"10":…,"9":…}` keeps that order here.
18
19
  *
19
20
  * What the canonicaliser does not do is refuse input that is not I-JSON, so
20
21
  * this adds that gate: a lone surrogate would serialise differently in
@@ -24,13 +25,13 @@ export class JcsError extends Error {
24
25
  */
25
26
  export function jcsDigest(value) {
26
27
  assertIJson(value);
27
- const canonical = CanonicalIntentHasher.stringify(value);
28
+ const canonical = Rfc8785.stringify(value);
28
29
  return `sha256:${createHash("sha256").update(canonical).digest("hex")}`;
29
30
  }
30
31
  /** The canonical text itself, for a caller that wants to see what was hashed. */
31
32
  export function jcsCanonical(value) {
32
33
  assertIJson(value);
33
- return CanonicalIntentHasher.stringify(value);
34
+ return Rfc8785.stringify(value);
34
35
  }
35
36
  /**
36
37
  * Whether a string is well-formed UTF-16: every surrogate paired. Written
@@ -1 +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,CAAC,KAAK,CAAC,CAAC;IACnB,MAAM,SAAS,GAAG,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;IACzD,OAAO,UAAU,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;AAC1E,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,YAAY,CAAC,KAAgB;IAC3C,WAAW,CAAC,KAAK,CAAC,CAAC;IACnB,OAAO,qBAAqB,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAChD,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,iBAAiB,CAAC,KAAa;IAC7C,KAAK,MAAM,SAAS,IAAI,KAAK,EAAE,CAAC;QAC9B,IAAI,SAAS,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;YACrC,IAAI,IAAI,IAAI,MAAM,IAAI,IAAI,IAAI,MAAM;gBAAE,OAAO,KAAK,CAAC;QACrD,C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AC1E,0EAA0E;IAC1E,6DAA6D;IAC7D,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO;IAC3B,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACjD,IAAI,CAAC,iBAAiB,CAAC,GAAG,CAAC;YAAE,MAAM,IAAI,QAAQ,CAAC,gBAAgB,CAAC,CAAC;QAClE,sEAAsE;QACtE,yCAAyC;QACzC,IAAI,KAAK,KAAK,SAAS;YAAE,WAAW,CAAC,KAAkB,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC"}
@@ -1,4 +1,4 @@
1
- import { IntentCapture, type AuditRecorder, type AuthorizationVerifier, type DecisionAuthority, type ExecutionSignals, type IntentActor, type JsonObject } from "@decionis/agent-safe-pipeline";
1
+ import { IntentCapture, type AuditRecorder, type AuthorizationVerifier, type DecisionAuthority, type ExecutionSignals, type IntentActor, type JsonObject, type McpToolProfile } from "@decionis/agent-safe-pipeline";
2
2
  import { McpBindingError } from "./McpIntentBinder.js";
3
3
  import type { McpInvocation, McpToolBinding } from "./McpInvocation.js";
4
4
  /**
@@ -10,8 +10,25 @@ export interface McpTool<TResult = unknown> {
10
10
  readonly binding: McpToolBinding;
11
11
  invoke(args: JsonObject): Promise<TResult>;
12
12
  }
13
+ /**
14
+ * A tool an `agent-safe.profile.mcp/1` profile declares: only its name and
15
+ * what it does. Its action, target, subject, consequential arguments and the
16
+ * arguments it accepts are the profile's, read as data.
17
+ */
18
+ export interface McpProfiledTool<TResult = unknown> {
19
+ readonly tool: string;
20
+ invoke(args: JsonObject): Promise<TResult>;
21
+ }
22
+ /** What the host knows about the session a call belongs to, never what the model sent. */
23
+ export interface McpSession {
24
+ /** The subject the session is pinned to, verified by the host. */
25
+ readonly subject?: string;
26
+ }
13
27
  export interface McpGuardOptions {
14
- readonly tools: readonly McpTool[];
28
+ /** Tools bound in code (`McpTool`), or declared by `profile` (`McpProfiledTool`). */
29
+ readonly tools: readonly (McpTool | McpProfiledTool)[];
30
+ /** The tool profile the profiled tools are declared in. */
31
+ readonly profile?: McpToolProfile;
15
32
  readonly authority: DecisionAuthority;
16
33
  readonly verifier: AuthorizationVerifier;
17
34
  readonly tenantId: string;
@@ -83,9 +100,21 @@ export declare class McpGuard {
83
100
  private readonly executor;
84
101
  private readonly options;
85
102
  constructor(options: McpGuardOptions);
103
+ /**
104
+ * A tool as the guard holds it: a code binding as given, or a profiled
105
+ * tool's binding read from the profile. A profiled tool the profile does
106
+ * not declare is refused at construction, never governed by a guess.
107
+ */
108
+ private static resolve;
86
109
  /** Every tool this guard governs, for a server publishing its tool list. */
87
110
  governs(tool: string): boolean;
88
- guard<TResult = unknown>(invocation: McpInvocation): Promise<McpOutcome<TResult>>;
111
+ /**
112
+ * One invocation, through the lifecycle. `session` is the host's: the
113
+ * subject it verified for this conversation. A tool that names a subject
114
+ * argument is refused without one, or for another subject, before the
115
+ * authority is asked; any tool's intent states it as `session.subject`.
116
+ */
117
+ guard<TResult = unknown>(invocation: McpInvocation, session?: McpSession): Promise<McpOutcome<TResult>>;
89
118
  private outcomeOf;
90
119
  }
91
120
  //# sourceMappingURL=McpGuard.d.ts.map