@emilia-protocol/gate 0.11.0 → 0.14.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 (425) hide show
  1. package/CHANGELOG.md +80 -0
  2. package/README.md +310 -0
  3. package/action-control-manifest.js +3 -268
  4. package/action-escrow-custodian.js +3 -394
  5. package/action-escrow-evidence.js +3 -858
  6. package/action-escrow-package.js +3 -1668
  7. package/action-escrow-postgres.js +3 -337
  8. package/action-escrow-state.js +3 -396
  9. package/action-escrow-verifiers.js +3 -331
  10. package/action-escrow.js +3 -2447
  11. package/action-packs.js +3 -140
  12. package/adapters/_kit.js +3 -104
  13. package/adapters/aws.js +3 -108
  14. package/adapters/cloudflare.js +3 -54
  15. package/adapters/gcp.js +3 -70
  16. package/adapters/github.js +3 -109
  17. package/adapters/jira.js +3 -55
  18. package/adapters/k8s.js +3 -70
  19. package/adapters/linear.js +3 -55
  20. package/adapters/salesforce.js +3 -55
  21. package/adapters/stripe.js +3 -81
  22. package/adapters/supabase.js +3 -121
  23. package/adapters/terraform.js +3 -59
  24. package/adapters/vercel.js +3 -84
  25. package/aec-execution.js +3 -312
  26. package/breakglass.js +3 -582
  27. package/capability-receipt.js +4 -0
  28. package/cf1-conformance.js +3 -106
  29. package/challenge-store.js +3 -69
  30. package/control-plane.js +3 -340
  31. package/coverage.js +3 -721
  32. package/demo.mjs +1 -1
  33. package/deployment-attestation.js +3 -247
  34. package/dist/action-control-manifest.d.ts +82 -0
  35. package/dist/action-control-manifest.d.ts.map +1 -0
  36. package/dist/action-control-manifest.js +422 -0
  37. package/dist/action-control-manifest.js.map +1 -0
  38. package/dist/action-escrow-custodian.d.ts +74 -0
  39. package/dist/action-escrow-custodian.d.ts.map +1 -0
  40. package/dist/action-escrow-custodian.js +363 -0
  41. package/dist/action-escrow-custodian.js.map +1 -0
  42. package/dist/action-escrow-evidence.d.ts +130 -0
  43. package/dist/action-escrow-evidence.d.ts.map +1 -0
  44. package/dist/action-escrow-evidence.js +1012 -0
  45. package/dist/action-escrow-evidence.js.map +1 -0
  46. package/dist/action-escrow-package.d.ts +10 -0
  47. package/dist/action-escrow-package.d.ts.map +1 -0
  48. package/dist/action-escrow-package.js +1583 -0
  49. package/dist/action-escrow-package.js.map +1 -0
  50. package/dist/action-escrow-postgres.d.ts +62 -0
  51. package/dist/action-escrow-postgres.d.ts.map +1 -0
  52. package/dist/action-escrow-postgres.js +339 -0
  53. package/dist/action-escrow-postgres.js.map +1 -0
  54. package/dist/action-escrow-state.d.ts +141 -0
  55. package/dist/action-escrow-state.d.ts.map +1 -0
  56. package/dist/action-escrow-state.js +413 -0
  57. package/dist/action-escrow-state.js.map +1 -0
  58. package/dist/action-escrow-verifiers.d.ts +65 -0
  59. package/dist/action-escrow-verifiers.d.ts.map +1 -0
  60. package/dist/action-escrow-verifiers.js +421 -0
  61. package/dist/action-escrow-verifiers.js.map +1 -0
  62. package/dist/action-escrow.d.ts +112 -0
  63. package/dist/action-escrow.d.ts.map +1 -0
  64. package/dist/action-escrow.js +2661 -0
  65. package/dist/action-escrow.js.map +1 -0
  66. package/dist/action-packs.d.ts +54 -0
  67. package/dist/action-packs.d.ts.map +1 -0
  68. package/dist/action-packs.js +143 -0
  69. package/dist/action-packs.js.map +1 -0
  70. package/dist/adapters/_kit.d.ts +50 -0
  71. package/dist/adapters/_kit.d.ts.map +1 -0
  72. package/dist/adapters/_kit.js +98 -0
  73. package/dist/adapters/_kit.js.map +1 -0
  74. package/dist/adapters/aws.d.ts +158 -0
  75. package/dist/adapters/aws.d.ts.map +1 -0
  76. package/dist/adapters/aws.js +136 -0
  77. package/dist/adapters/aws.js.map +1 -0
  78. package/dist/adapters/cloudflare.d.ts +116 -0
  79. package/dist/adapters/cloudflare.d.ts.map +1 -0
  80. package/dist/adapters/cloudflare.js +75 -0
  81. package/dist/adapters/cloudflare.js.map +1 -0
  82. package/dist/adapters/gcp.d.ts +139 -0
  83. package/dist/adapters/gcp.d.ts.map +1 -0
  84. package/dist/adapters/gcp.js +69 -0
  85. package/dist/adapters/gcp.js.map +1 -0
  86. package/dist/adapters/github.d.ts +123 -0
  87. package/dist/adapters/github.d.ts.map +1 -0
  88. package/dist/adapters/github.js +105 -0
  89. package/dist/adapters/github.js.map +1 -0
  90. package/dist/adapters/jira.d.ts +109 -0
  91. package/dist/adapters/jira.d.ts.map +1 -0
  92. package/dist/adapters/jira.js +54 -0
  93. package/dist/adapters/jira.js.map +1 -0
  94. package/dist/adapters/k8s.d.ts +139 -0
  95. package/dist/adapters/k8s.d.ts.map +1 -0
  96. package/dist/adapters/k8s.js +69 -0
  97. package/dist/adapters/k8s.js.map +1 -0
  98. package/dist/adapters/linear.d.ts +109 -0
  99. package/dist/adapters/linear.d.ts.map +1 -0
  100. package/dist/adapters/linear.js +54 -0
  101. package/dist/adapters/linear.js.map +1 -0
  102. package/dist/adapters/salesforce.d.ts +109 -0
  103. package/dist/adapters/salesforce.d.ts.map +1 -0
  104. package/dist/adapters/salesforce.js +54 -0
  105. package/dist/adapters/salesforce.js.map +1 -0
  106. package/dist/adapters/stripe.d.ts +116 -0
  107. package/dist/adapters/stripe.d.ts.map +1 -0
  108. package/dist/adapters/stripe.js +77 -0
  109. package/dist/adapters/stripe.js.map +1 -0
  110. package/dist/adapters/supabase.d.ts +127 -0
  111. package/dist/adapters/supabase.d.ts.map +1 -0
  112. package/dist/adapters/supabase.js +112 -0
  113. package/dist/adapters/supabase.js.map +1 -0
  114. package/dist/adapters/terraform.d.ts +109 -0
  115. package/dist/adapters/terraform.d.ts.map +1 -0
  116. package/dist/adapters/terraform.js +58 -0
  117. package/dist/adapters/terraform.js.map +1 -0
  118. package/dist/adapters/vercel.d.ts +114 -0
  119. package/dist/adapters/vercel.d.ts.map +1 -0
  120. package/dist/adapters/vercel.js +81 -0
  121. package/dist/adapters/vercel.js.map +1 -0
  122. package/dist/aec-execution.d.ts +107 -0
  123. package/dist/aec-execution.d.ts.map +1 -0
  124. package/dist/aec-execution.js +334 -0
  125. package/dist/aec-execution.js.map +1 -0
  126. package/dist/breakglass.d.ts +205 -0
  127. package/dist/breakglass.d.ts.map +1 -0
  128. package/dist/breakglass.js +627 -0
  129. package/dist/breakglass.js.map +1 -0
  130. package/dist/capability-receipt.d.ts +601 -0
  131. package/dist/capability-receipt.d.ts.map +1 -0
  132. package/dist/capability-receipt.js +1177 -0
  133. package/dist/capability-receipt.js.map +1 -0
  134. package/dist/cf1-conformance.d.ts +83 -0
  135. package/dist/cf1-conformance.d.ts.map +1 -0
  136. package/dist/cf1-conformance.js +94 -0
  137. package/dist/cf1-conformance.js.map +1 -0
  138. package/dist/challenge-store.d.ts +20 -0
  139. package/dist/challenge-store.d.ts.map +1 -0
  140. package/dist/challenge-store.js +62 -0
  141. package/dist/challenge-store.js.map +1 -0
  142. package/dist/control-plane.d.ts +136 -0
  143. package/dist/control-plane.d.ts.map +1 -0
  144. package/dist/control-plane.js +349 -0
  145. package/dist/control-plane.js.map +1 -0
  146. package/dist/coverage.d.ts +156 -0
  147. package/dist/coverage.d.ts.map +1 -0
  148. package/dist/coverage.js +768 -0
  149. package/dist/coverage.js.map +1 -0
  150. package/dist/deployment-attestation.d.ts +93 -0
  151. package/dist/deployment-attestation.d.ts.map +1 -0
  152. package/dist/deployment-attestation.js +262 -0
  153. package/dist/deployment-attestation.js.map +1 -0
  154. package/dist/eg1-conformance.d.ts +286 -0
  155. package/dist/eg1-conformance.d.ts.map +1 -0
  156. package/dist/eg1-conformance.js +379 -0
  157. package/dist/eg1-conformance.js.map +1 -0
  158. package/dist/enterprise.d.ts +88 -0
  159. package/dist/enterprise.d.ts.map +1 -0
  160. package/dist/enterprise.js +194 -0
  161. package/dist/enterprise.js.map +1 -0
  162. package/dist/evidence-postgres.d.ts +123 -0
  163. package/dist/evidence-postgres.d.ts.map +1 -0
  164. package/dist/evidence-postgres.js +343 -0
  165. package/dist/evidence-postgres.js.map +1 -0
  166. package/dist/evidence.d.ts +113 -0
  167. package/dist/evidence.d.ts.map +1 -0
  168. package/dist/evidence.js +369 -0
  169. package/dist/evidence.js.map +1 -0
  170. package/dist/execution-binding.d.ts +49 -0
  171. package/dist/execution-binding.d.ts.map +1 -0
  172. package/dist/execution-binding.js +243 -0
  173. package/dist/execution-binding.js.map +1 -0
  174. package/dist/formal-runtime-map.d.ts +42 -0
  175. package/dist/formal-runtime-map.d.ts.map +1 -0
  176. package/dist/formal-runtime-map.js +23 -0
  177. package/dist/formal-runtime-map.js.map +1 -0
  178. package/dist/index.d.ts +1003 -0
  179. package/dist/index.d.ts.map +1 -0
  180. package/dist/index.js +1737 -0
  181. package/dist/index.js.map +1 -0
  182. package/dist/key-registry.d.ts +60 -0
  183. package/dist/key-registry.d.ts.map +1 -0
  184. package/dist/key-registry.js +144 -0
  185. package/dist/key-registry.js.map +1 -0
  186. package/dist/mcp.d.ts +53 -0
  187. package/dist/mcp.d.ts.map +1 -0
  188. package/dist/mcp.js +112 -0
  189. package/dist/mcp.js.map +1 -0
  190. package/dist/metering.d.ts +80 -0
  191. package/dist/metering.d.ts.map +1 -0
  192. package/dist/metering.js +227 -0
  193. package/dist/metering.js.map +1 -0
  194. package/dist/metrics.d.ts +68 -0
  195. package/dist/metrics.d.ts.map +1 -0
  196. package/dist/metrics.js +242 -0
  197. package/dist/metrics.js.map +1 -0
  198. package/dist/network-witness.d.ts +167 -0
  199. package/dist/network-witness.d.ts.map +1 -0
  200. package/dist/network-witness.js +520 -0
  201. package/dist/network-witness.js.map +1 -0
  202. package/dist/proposal-to-effect.d.ts +146 -0
  203. package/dist/proposal-to-effect.d.ts.map +1 -0
  204. package/dist/proposal-to-effect.js +427 -0
  205. package/dist/proposal-to-effect.js.map +1 -0
  206. package/dist/protocol-state.d.ts +141 -0
  207. package/dist/protocol-state.d.ts.map +1 -0
  208. package/dist/protocol-state.js +106 -0
  209. package/dist/protocol-state.js.map +1 -0
  210. package/dist/receipt-program.d.ts +59 -0
  211. package/dist/receipt-program.d.ts.map +1 -0
  212. package/dist/receipt-program.js +1053 -0
  213. package/dist/receipt-program.js.map +1 -0
  214. package/dist/reliance-kernel.d.ts +66 -0
  215. package/dist/reliance-kernel.d.ts.map +1 -0
  216. package/dist/reliance-kernel.js +103 -0
  217. package/dist/reliance-kernel.js.map +1 -0
  218. package/dist/reliance-packet.d.ts +67 -0
  219. package/dist/reliance-packet.d.ts.map +1 -0
  220. package/dist/reliance-packet.js +176 -0
  221. package/dist/reliance-packet.js.map +1 -0
  222. package/dist/remedy-program-postgres.d.ts +37 -0
  223. package/dist/remedy-program-postgres.d.ts.map +1 -0
  224. package/dist/remedy-program-postgres.js +291 -0
  225. package/dist/remedy-program-postgres.js.map +1 -0
  226. package/dist/remedy-program-receipt.d.ts +97 -0
  227. package/dist/remedy-program-receipt.d.ts.map +1 -0
  228. package/dist/remedy-program-receipt.js +817 -0
  229. package/dist/remedy-program-receipt.js.map +1 -0
  230. package/dist/remedy-program.d.ts +76 -0
  231. package/dist/remedy-program.d.ts.map +1 -0
  232. package/dist/remedy-program.js +1346 -0
  233. package/dist/remedy-program.js.map +1 -0
  234. package/dist/reports/art14.d.ts +101 -0
  235. package/dist/reports/art14.d.ts.map +1 -0
  236. package/dist/reports/art14.js +340 -0
  237. package/dist/reports/art14.js.map +1 -0
  238. package/dist/reports/assurance-package.d.ts +197 -0
  239. package/dist/reports/assurance-package.d.ts.map +1 -0
  240. package/dist/reports/assurance-package.js +313 -0
  241. package/dist/reports/assurance-package.js.map +1 -0
  242. package/dist/reports/auditor-workpaper.d.ts +194 -0
  243. package/dist/reports/auditor-workpaper.d.ts.map +1 -0
  244. package/dist/reports/auditor-workpaper.js +545 -0
  245. package/dist/reports/auditor-workpaper.js.map +1 -0
  246. package/dist/reports/external-verification.d.ts +76 -0
  247. package/dist/reports/external-verification.d.ts.map +1 -0
  248. package/dist/reports/external-verification.js +209 -0
  249. package/dist/reports/external-verification.js.map +1 -0
  250. package/dist/reports/reperform.d.ts +122 -0
  251. package/dist/reports/reperform.d.ts.map +1 -0
  252. package/dist/reports/reperform.js +432 -0
  253. package/dist/reports/reperform.js.map +1 -0
  254. package/dist/reports/underwriter.d.ts +127 -0
  255. package/dist/reports/underwriter.d.ts.map +1 -0
  256. package/dist/reports/underwriter.js +348 -0
  257. package/dist/reports/underwriter.js.map +1 -0
  258. package/dist/retention.d.ts +88 -0
  259. package/dist/retention.d.ts.map +1 -0
  260. package/dist/retention.js +90 -0
  261. package/dist/retention.js.map +1 -0
  262. package/dist/roster.d.ts +113 -0
  263. package/dist/roster.d.ts.map +1 -0
  264. package/dist/roster.js +261 -0
  265. package/dist/roster.js.map +1 -0
  266. package/dist/runtime-monitor.d.ts +132 -0
  267. package/dist/runtime-monitor.d.ts.map +1 -0
  268. package/dist/runtime-monitor.js +197 -0
  269. package/dist/runtime-monitor.js.map +1 -0
  270. package/dist/settlement.d.ts +68 -0
  271. package/dist/settlement.d.ts.map +1 -0
  272. package/dist/settlement.js +306 -0
  273. package/dist/settlement.js.map +1 -0
  274. package/dist/siem.d.ts +261 -0
  275. package/dist/siem.d.ts.map +1 -0
  276. package/dist/siem.js +247 -0
  277. package/dist/siem.js.map +1 -0
  278. package/dist/store-postgres.d.ts +107 -0
  279. package/dist/store-postgres.d.ts.map +1 -0
  280. package/dist/store-postgres.js +152 -0
  281. package/dist/store-postgres.js.map +1 -0
  282. package/dist/store.d.ts +95 -0
  283. package/dist/store.d.ts.map +1 -0
  284. package/dist/store.js +202 -0
  285. package/dist/store.js.map +1 -0
  286. package/dist/strict-json.d.ts +14 -0
  287. package/dist/strict-json.d.ts.map +1 -0
  288. package/dist/strict-json.js +132 -0
  289. package/dist/strict-json.js.map +1 -0
  290. package/dist/trust-program-adapters.d.ts +122 -0
  291. package/dist/trust-program-adapters.d.ts.map +1 -0
  292. package/dist/trust-program-adapters.js +802 -0
  293. package/dist/trust-program-adapters.js.map +1 -0
  294. package/dist/trust-program-postgres.d.ts +41 -0
  295. package/dist/trust-program-postgres.d.ts.map +1 -0
  296. package/dist/trust-program-postgres.js +346 -0
  297. package/dist/trust-program-postgres.js.map +1 -0
  298. package/dist/trust-program-revocation.d.ts +206 -0
  299. package/dist/trust-program-revocation.d.ts.map +1 -0
  300. package/dist/trust-program-revocation.js +600 -0
  301. package/dist/trust-program-revocation.js.map +1 -0
  302. package/dist/trust-program.d.ts +197 -0
  303. package/dist/trust-program.d.ts.map +1 -0
  304. package/dist/trust-program.js +1351 -0
  305. package/dist/trust-program.js.map +1 -0
  306. package/dist/witness-postgres.d.ts +43 -0
  307. package/dist/witness-postgres.d.ts.map +1 -0
  308. package/dist/witness-postgres.js +92 -0
  309. package/dist/witness-postgres.js.map +1 -0
  310. package/dist/zk-range-proof.d.ts +78 -0
  311. package/dist/zk-range-proof.d.ts.map +1 -0
  312. package/dist/zk-range-proof.js +228 -0
  313. package/dist/zk-range-proof.js.map +1 -0
  314. package/eg1-conformance.js +3 -404
  315. package/enterprise.js +3 -180
  316. package/ep-assure.mjs +1 -0
  317. package/evidence-postgres.js +3 -356
  318. package/evidence.js +4 -360
  319. package/execution-binding.js +3 -212
  320. package/formal-runtime-map.js +4 -0
  321. package/index.js +4 -1249
  322. package/key-registry.js +3 -134
  323. package/mcp.js +3 -109
  324. package/metering.js +3 -226
  325. package/metrics.js +3 -231
  326. package/network-witness.js +3 -499
  327. package/package.json +35 -4
  328. package/proposal-to-effect.js +4 -0
  329. package/receipt-program.js +4 -0
  330. package/reliance-kernel.js +3 -112
  331. package/reliance-packet.js +3 -175
  332. package/remedy-program-postgres.js +4 -0
  333. package/remedy-program-receipt.js +4 -0
  334. package/remedy-program.js +4 -0
  335. package/reports/art14.js +0 -0
  336. package/reports/assurance-package.js +2 -312
  337. package/reports/auditor-workpaper.js +3 -537
  338. package/reports/external-verification.js +3 -222
  339. package/reports/reperform.js +3 -424
  340. package/reports/underwriter.js +3 -339
  341. package/retention.js +3 -84
  342. package/roster.js +3 -264
  343. package/runtime-monitor.js +4 -0
  344. package/settlement.js +3 -299
  345. package/siem.js +3 -235
  346. package/src/action-control-manifest.ts +424 -0
  347. package/src/action-escrow-custodian.ts +427 -0
  348. package/src/action-escrow-evidence.ts +1178 -0
  349. package/src/action-escrow-package.ts +1821 -0
  350. package/src/action-escrow-postgres.ts +366 -0
  351. package/src/action-escrow-state.ts +498 -0
  352. package/src/action-escrow-verifiers.ts +484 -0
  353. package/src/action-escrow.ts +3039 -0
  354. package/src/action-packs.ts +170 -0
  355. package/src/adapters/_kit.ts +117 -0
  356. package/src/adapters/aws.ts +142 -0
  357. package/src/adapters/cloudflare.ts +78 -0
  358. package/src/adapters/gcp.ts +71 -0
  359. package/src/adapters/github.ts +110 -0
  360. package/src/adapters/jira.ts +56 -0
  361. package/src/adapters/k8s.ts +71 -0
  362. package/src/adapters/linear.ts +56 -0
  363. package/src/adapters/salesforce.ts +56 -0
  364. package/src/adapters/stripe.ts +82 -0
  365. package/src/adapters/supabase.ts +122 -0
  366. package/src/adapters/terraform.ts +60 -0
  367. package/src/adapters/vercel.ts +85 -0
  368. package/src/aec-execution.ts +354 -0
  369. package/src/breakglass.ts +647 -0
  370. package/src/capability-receipt.ts +1258 -0
  371. package/src/cf1-conformance.ts +120 -0
  372. package/src/challenge-store.ts +70 -0
  373. package/src/control-plane.ts +374 -0
  374. package/src/coverage.ts +832 -0
  375. package/src/deployment-attestation.ts +259 -0
  376. package/src/eg1-conformance.ts +471 -0
  377. package/src/enterprise.ts +195 -0
  378. package/src/evidence-postgres.ts +374 -0
  379. package/src/evidence.ts +367 -0
  380. package/src/execution-binding.ts +236 -0
  381. package/src/formal-runtime-map.ts +24 -0
  382. package/src/index.ts +2127 -0
  383. package/src/key-registry.ts +150 -0
  384. package/src/mcp.ts +120 -0
  385. package/src/metering.ts +237 -0
  386. package/src/metrics.ts +232 -0
  387. package/src/network-witness.ts +585 -0
  388. package/src/proposal-to-effect.ts +571 -0
  389. package/src/protocol-state.ts +143 -0
  390. package/src/protocol-state.typecheck.ts +94 -0
  391. package/src/receipt-program.ts +1105 -0
  392. package/src/reliance-kernel.ts +119 -0
  393. package/src/reliance-packet.ts +206 -0
  394. package/src/remedy-program-postgres.ts +367 -0
  395. package/src/remedy-program-receipt.ts +891 -0
  396. package/src/remedy-program.ts +1388 -0
  397. package/src/reports/art14.ts +361 -0
  398. package/src/reports/assurance-package.ts +330 -0
  399. package/src/reports/auditor-workpaper.ts +558 -0
  400. package/src/reports/external-verification.ts +232 -0
  401. package/src/reports/reperform.ts +441 -0
  402. package/src/reports/underwriter.ts +356 -0
  403. package/src/retention.ts +100 -0
  404. package/src/roster.ts +273 -0
  405. package/src/runtime-monitor.ts +217 -0
  406. package/src/settlement.ts +313 -0
  407. package/src/siem.ts +247 -0
  408. package/src/store-postgres.ts +167 -0
  409. package/src/store.ts +214 -0
  410. package/src/strict-json.ts +115 -0
  411. package/src/trust-program-adapters.ts +847 -0
  412. package/src/trust-program-postgres.ts +429 -0
  413. package/src/trust-program-revocation.ts +751 -0
  414. package/src/trust-program.ts +1460 -0
  415. package/src/witness-postgres.ts +106 -0
  416. package/src/zk-range-proof.ts +250 -0
  417. package/store-postgres.js +3 -161
  418. package/store.js +4 -198
  419. package/strict-json.js +3 -102
  420. package/trust-program-adapters.js +4 -0
  421. package/trust-program-postgres.js +4 -0
  422. package/trust-program-revocation.js +4 -0
  423. package/trust-program.js +4 -0
  424. package/witness-postgres.js +3 -96
  425. package/zk-range-proof.js +4 -0
@@ -0,0 +1,601 @@
1
+ /**
2
+ * EP Capability Receipt v1.
3
+ *
4
+ * A capability receipt is an issuer-signed envelope around an ordinary EP
5
+ * receipt. The ordinary receipt remains the policy/assurance proof; the
6
+ * capability envelope adds a secret preimage, an immutable budget, an expiry,
7
+ * and (optionally) Shamir shares. Spend state is never trusted from the
8
+ * envelope. Every spend must pass through an atomic capability store.
9
+ *
10
+ * The executor deliberately follows the same indeterminate-outcome rule as
11
+ * Gate: once the external effect is entered, a storage failure cannot reopen
12
+ * the budget. The reservation remains blocked until reconciliation.
13
+ */
14
+ import { randomBytes, type KeyObject } from 'node:crypto';
15
+ export declare const CAPABILITY_RECEIPT_VERSION = "EP-CAPABILITY-RECEIPT-v1";
16
+ export declare const CAPABILITY_STATE_VERSION = "EP-CAPABILITY-STATE-v1";
17
+ export declare const CAPABILITY_SHARE_VERSION = "EP-CAPABILITY-SHARE-v1";
18
+ export declare const CAPABILITY_HASH_ALGORITHM = "sha256";
19
+ export declare const CAPABILITY_SCOPE_PROFILE = "urn:emilia:scope:action-digest-set-v1";
20
+ export declare const CAPABILITY_CAID_SCOPE_PROFILE = "urn:emilia:scope:caid-set-v1";
21
+ type KeyMaterial = KeyObject | string | Buffer;
22
+ type CapabilityBudget = {
23
+ amount: number;
24
+ currency: string;
25
+ };
26
+ type ReserveSpendOptions = {
27
+ capabilityId: string;
28
+ capabilityFingerprint: string;
29
+ operationId: string;
30
+ actionDigest: string;
31
+ amount: number;
32
+ currency: string;
33
+ now?: number | (() => number);
34
+ };
35
+ type CommitSpendOptions = {
36
+ capabilityId?: string;
37
+ operationId?: string;
38
+ reservationToken?: string;
39
+ outcome?: string;
40
+ now?: number | (() => number);
41
+ };
42
+ type ReconcileSpendOptions = {
43
+ capabilityId?: string;
44
+ operationId?: string;
45
+ actionDigest?: string;
46
+ evidenceDigest?: string;
47
+ outcome?: string;
48
+ now?: number | (() => number);
49
+ };
50
+ type ExecuteWithCapabilityOptions = {
51
+ capabilityReceipt?: Record<string, any>;
52
+ secret?: Buffer | string;
53
+ action?: Record<string, any>;
54
+ store?: Record<string, any>;
55
+ executeAction?: (...args: any[]) => any;
56
+ gate?: Record<string, any> | null;
57
+ selector?: Record<string, any>;
58
+ observedAction?: Record<string, any> | null;
59
+ trustedIssuerKeys?: string[];
60
+ verifyBaseReceipt?: ((...args: any[]) => any) | null;
61
+ resolveCaid?: ((action: any) => any) | null;
62
+ operationId?: string | null;
63
+ now?: number | (() => number);
64
+ thresholdSecretVerified?: boolean;
65
+ };
66
+ /** Digest the exact immutable action snapshot exercised under a capability. */
67
+ export declare function capabilityActionDigest(action: any): string;
68
+ /**
69
+ * @param {object} capability
70
+ * @param {object} action
71
+ * @param {string} operationId
72
+ * @param {object} [options]
73
+ * @param {Function|null} [options.resolveCaid]
74
+ */
75
+ export declare function verifyCapabilityScope(capability: any, action: any, operationId: any, { resolveCaid }?: {
76
+ resolveCaid?: ((action: any) => any) | null;
77
+ }): {
78
+ ok: boolean;
79
+ reason: string;
80
+ action_digest: string;
81
+ caid?: undefined;
82
+ operation_id_field?: undefined;
83
+ detail?: undefined;
84
+ } | {
85
+ ok: boolean;
86
+ reason: string;
87
+ action_digest: string;
88
+ caid: never;
89
+ operation_id_field?: undefined;
90
+ detail?: undefined;
91
+ } | {
92
+ ok: boolean;
93
+ reason: string;
94
+ action_digest: string;
95
+ operation_id_field: string;
96
+ caid?: undefined;
97
+ detail?: undefined;
98
+ } | {
99
+ operation_id_field: string;
100
+ caid?: undefined;
101
+ ok: boolean;
102
+ action_digest: string;
103
+ reason?: undefined;
104
+ detail?: undefined;
105
+ } | {
106
+ ok: boolean;
107
+ reason: string;
108
+ detail: string;
109
+ action_digest?: undefined;
110
+ caid?: undefined;
111
+ operation_id_field?: undefined;
112
+ };
113
+ export declare function capabilityBaseReceiptDigest(receipt: any): string;
114
+ /**
115
+ * Mint a signed capability envelope. The issuer must sign the capability
116
+ * metadata; a holder cannot enlarge the budget by editing a bearer object.
117
+ * For m-of-n > 1, the raw secret is not returned; distribute the returned
118
+ * shares instead.
119
+ *
120
+ * @param {object} baseReceipt EP-RECEIPT-v1 document
121
+ * @param {object} [options]
122
+ * @param {KeyMaterial} [options.issuerPrivateKey]
123
+ * @param {CapabilityBudget} [options.budget]
124
+ * @param {string|number} [options.expiry]
125
+ * @param {{m:number,n:number}} [options.threshold]
126
+ * @param {object} [options.scope]
127
+ * @param {any[]} [options.delegationChain]
128
+ * @param {string} [options.capabilityId]
129
+ * @param {Buffer|string} [options.secret]
130
+ */
131
+ export declare function mintCapabilityReceipt(baseReceipt: any, { issuerPrivateKey, budget, expiry, threshold, scope, delegationChain, capabilityId, secret, }?: {
132
+ issuerPrivateKey?: KeyMaterial;
133
+ budget?: CapabilityBudget;
134
+ expiry?: string | number;
135
+ threshold?: {
136
+ m: number;
137
+ n: number;
138
+ };
139
+ scope?: Record<string, any>;
140
+ delegationChain?: any[];
141
+ capabilityId?: string;
142
+ secret?: Buffer | string;
143
+ }): Readonly<{
144
+ capabilityReceipt: Readonly<{
145
+ '@version': string;
146
+ receipt: Record<string, any>;
147
+ capability: {
148
+ version: string;
149
+ id: string;
150
+ secret_hash: string;
151
+ budget: {
152
+ amount: any;
153
+ currency: string;
154
+ };
155
+ consumed: number;
156
+ threshold: {
157
+ m: number;
158
+ n: number;
159
+ };
160
+ scope: {
161
+ [x: string]: any;
162
+ profile: any;
163
+ operation_id_field: string;
164
+ };
165
+ delegation_chain: Record<string, any>[];
166
+ expiry: string;
167
+ };
168
+ capability_signature: {
169
+ algorithm: string;
170
+ public_key: string;
171
+ value: string;
172
+ };
173
+ }>;
174
+ secret: Buffer<ArrayBuffer> | null;
175
+ shares: string[] | null;
176
+ }>;
177
+ /**
178
+ * Verify the issuer signature and immutable capability metadata.
179
+ * @param {object} capabilityReceipt
180
+ * @param {object} [options]
181
+ * @param {string[]} [options.trustedIssuerKeys]
182
+ * @param {boolean} [options.allowUntrustedIssuer]
183
+ */
184
+ export declare function verifyCapabilityReceipt(capabilityReceipt: any, { trustedIssuerKeys, allowUntrustedIssuer, }?: {
185
+ trustedIssuerKeys?: string[];
186
+ allowUntrustedIssuer?: boolean;
187
+ }): {
188
+ ok: boolean;
189
+ reason: string;
190
+ receipt?: undefined;
191
+ capability?: undefined;
192
+ issuer_public_key?: undefined;
193
+ detail?: undefined;
194
+ } | {
195
+ ok: boolean;
196
+ receipt: Record<string, any>;
197
+ capability: any;
198
+ issuer_public_key: any;
199
+ reason?: undefined;
200
+ detail?: undefined;
201
+ } | {
202
+ ok: boolean;
203
+ reason: string;
204
+ detail: string;
205
+ receipt?: undefined;
206
+ capability?: undefined;
207
+ issuer_public_key?: undefined;
208
+ };
209
+ /** Split the 32-byte capability secret using Shamir's polynomial scheme. */
210
+ export declare function splitCapabilitySecret(secret: any, threshold: any, { randomBytesFn }?: {
211
+ randomBytesFn?: typeof randomBytes | undefined;
212
+ }): string[];
213
+ /** Reconstruct a capability secret from at least m unique shares. */
214
+ export declare function reconstructCapabilitySecret(shares: any, threshold: any): Buffer<ArrayBuffer>;
215
+ /**
216
+ * An in-memory atomic reference store. It is intentionally marked non-durable
217
+ * and is suitable only for tests; production callers must use an implementation
218
+ * backed by a transactional database or equivalent linearizable store.
219
+ */
220
+ export declare function createMemoryCapabilityStore(): {
221
+ durable: boolean;
222
+ registerCapability(capabilityReceipt: any): boolean;
223
+ reserveSpend({ capabilityId, capabilityFingerprint, operationId, actionDigest, amount, currency, now }: ReserveSpendOptions): Promise<{
224
+ ok: boolean;
225
+ reason: string;
226
+ operation_id?: undefined;
227
+ reservation_token?: undefined;
228
+ remaining?: undefined;
229
+ } | {
230
+ ok: boolean;
231
+ operation_id: string;
232
+ reservation_token: `${string}-${string}-${string}-${string}-${string}`;
233
+ remaining: number;
234
+ reason?: undefined;
235
+ }>;
236
+ commitSpend({ capabilityId, operationId, reservationToken, outcome, now }?: CommitSpendOptions): Promise<{
237
+ ok: boolean;
238
+ reason: string;
239
+ outcome?: undefined;
240
+ consumed?: undefined;
241
+ remaining?: undefined;
242
+ } | {
243
+ ok: boolean;
244
+ outcome: string;
245
+ consumed: any;
246
+ remaining: number;
247
+ reason?: undefined;
248
+ }>;
249
+ reconcileSpend({ capabilityId, operationId, actionDigest, evidenceDigest, outcome, now }?: ReconcileSpendOptions): Promise<{
250
+ ok: boolean;
251
+ reason: string;
252
+ idempotent?: undefined;
253
+ outcome?: undefined;
254
+ } | {
255
+ ok: boolean;
256
+ idempotent: boolean;
257
+ outcome: string;
258
+ reason?: undefined;
259
+ }>;
260
+ getState(capabilityId: any): any;
261
+ getOperation(operationId: any): any;
262
+ };
263
+ export declare const CAPABILITY_STATE_TABLE = "ep_capability_state";
264
+ export declare const CAPABILITY_OPERATION_TABLE = "ep_capability_operations";
265
+ export declare const CAPABILITY_STATE_DDL = "CREATE TABLE IF NOT EXISTS ep_capability_state (\n capability_id TEXT PRIMARY KEY,\n capability_fingerprint TEXT NOT NULL CHECK (capability_fingerprint ~ '^sha256:[0-9a-f]{64}$'),\n budget_amount BIGINT NOT NULL CHECK (budget_amount >= 0),\n currency TEXT NOT NULL,\n consumed_amount BIGINT NOT NULL DEFAULT 0 CHECK (consumed_amount >= 0),\n reserved_amount BIGINT NOT NULL DEFAULT 0 CHECK (reserved_amount >= 0),\n expires_at TIMESTAMPTZ NOT NULL,\n created_at TIMESTAMPTZ NOT NULL DEFAULT now()\n);\nALTER TABLE ep_capability_state ADD COLUMN IF NOT EXISTS capability_fingerprint TEXT;\nCREATE TABLE IF NOT EXISTS ep_capability_operations (\n operation_id TEXT PRIMARY KEY,\n capability_id TEXT NOT NULL REFERENCES ep_capability_state(capability_id),\n action_digest TEXT NOT NULL CHECK (action_digest ~ '^sha256:[0-9a-f]{64}$'),\n amount BIGINT NOT NULL CHECK (amount > 0),\n currency TEXT NOT NULL,\n status TEXT NOT NULL CHECK (status IN ('reserved', 'committed')),\n reservation_token TEXT NOT NULL,\n outcome TEXT,\n reconciliation_outcome TEXT CHECK (reconciliation_outcome IN ('executed')),\n reconciliation_evidence_digest TEXT CHECK (reconciliation_evidence_digest ~ '^sha256:[0-9a-f]{64}$'),\n reserved_at TIMESTAMPTZ NOT NULL,\n committed_at TIMESTAMPTZ,\n reconciled_at TIMESTAMPTZ,\n CHECK (\n (reconciliation_outcome IS NULL AND reconciliation_evidence_digest IS NULL AND reconciled_at IS NULL)\n OR\n (reconciliation_outcome IS NOT NULL AND reconciliation_evidence_digest IS NOT NULL AND reconciled_at IS NOT NULL)\n )\n);\nCREATE INDEX IF NOT EXISTS ep_capability_operations_capability_idx ON ep_capability_operations(capability_id);";
266
+ export declare const CAPABILITY_SQL: Readonly<{
267
+ register: "INSERT INTO ep_capability_state (capability_id, budget_amount, currency, expires_at, capability_fingerprint) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (capability_id) DO UPDATE SET capability_fingerprint = COALESCE(ep_capability_state.capability_fingerprint, EXCLUDED.capability_fingerprint) WHERE ep_capability_state.budget_amount = EXCLUDED.budget_amount AND ep_capability_state.currency = EXCLUDED.currency AND ep_capability_state.expires_at = EXCLUDED.expires_at";
268
+ readState: "SELECT capability_id, capability_fingerprint, budget_amount, currency, consumed_amount, reserved_amount, expires_at FROM ep_capability_state WHERE capability_id = $1 FOR UPDATE";
269
+ readOperation: "SELECT operation_id, capability_id, action_digest, amount, currency, status, reservation_token, outcome, reconciliation_outcome, reconciliation_evidence_digest, reconciled_at FROM ep_capability_operations WHERE operation_id = $1 FOR UPDATE";
270
+ insertOperation: "INSERT INTO ep_capability_operations (operation_id, capability_id, action_digest, amount, currency, status, reservation_token, reserved_at) VALUES ($1, $2, $3, $4, $5, 'reserved', $6, $7)";
271
+ reserveState: "UPDATE ep_capability_state SET reserved_amount = reserved_amount + $2 WHERE capability_id = $1 AND budget_amount - consumed_amount - reserved_amount >= $2";
272
+ commitOperation: "UPDATE ep_capability_operations SET status = 'committed', outcome = $3, committed_at = $4 WHERE operation_id = $1 AND capability_id = $2 AND status = 'reserved' AND reservation_token = $5";
273
+ reconcileOperation: "UPDATE ep_capability_operations SET reconciliation_outcome = $3, reconciliation_evidence_digest = $4, reconciled_at = $5 WHERE operation_id = $1 AND capability_id = $2 AND status = 'committed' AND outcome = 'indeterminate' AND reconciliation_outcome IS NULL";
274
+ commitState: "UPDATE ep_capability_state SET reserved_amount = reserved_amount - $2, consumed_amount = consumed_amount + $2 WHERE capability_id = $1 AND reserved_amount >= $2";
275
+ }>;
276
+ /**
277
+ * Production adapter. `transaction` MUST run the callback on one database
278
+ * connection with BEGIN/COMMIT/ROLLBACK. The state row is locked before the
279
+ * operation row is inserted, making budget reservation linearizable per
280
+ * capability and refusing all ambiguous database outcomes.
281
+ *
282
+ * @param {object} [options]
283
+ * @param {(callback: (query: Function) => any) => any} [options.transaction]
284
+ */
285
+ export declare function createPostgresCapabilityStore({ transaction }?: {
286
+ transaction?: (callback: (query: Function) => any) => any;
287
+ }): {
288
+ durable: boolean;
289
+ registerCapability(capabilityReceipt: any): Promise<any>;
290
+ reserveSpend({ capabilityId, capabilityFingerprint, operationId, actionDigest, amount, currency, now }: ReserveSpendOptions): Promise<any>;
291
+ commitSpend({ capabilityId, operationId, reservationToken, outcome, now }?: CommitSpendOptions): Promise<any>;
292
+ reconcileSpend({ capabilityId, operationId, actionDigest, evidenceDigest, outcome, now }?: ReconcileSpendOptions): Promise<any>;
293
+ };
294
+ /**
295
+ * Execute one spend under a capability. The base EP receipt is checked on
296
+ * every spend with consumptionMode=none; the capability store is the replay
297
+ * and budget authority. The external function is entered only after the
298
+ * atomic reservation succeeds. `action` is the budget projection; the
299
+ * external function receives only a clone of the exact verified
300
+ * `observedAction ?? action`. Any exception after entry permanently commits
301
+ * the reserved amount as indeterminate.
302
+ *
303
+ * @param {object} [options]
304
+ * @param {object} [options.capabilityReceipt]
305
+ * @param {Buffer|string} [options.secret]
306
+ * @param {{amount:number,currency:string}} [options.action]
307
+ * @param {any} [options.store]
308
+ * @param {Function} [options.executeAction]
309
+ * @param {any} [options.gate]
310
+ * @param {object} [options.selector]
311
+ * @param {object|null} [options.observedAction]
312
+ * @param {string[]} [options.trustedIssuerKeys]
313
+ * @param {Function|null} [options.verifyBaseReceipt]
314
+ * @param {Function|null} [options.resolveCaid]
315
+ * @param {string|null} [options.operationId]
316
+ * @param {number|(() => number)} [options.now]
317
+ * @param {boolean} [options.thresholdSecretVerified]
318
+ */
319
+ export declare function executeWithCapability({ capabilityReceipt, secret, action, store, executeAction, gate, selector, observedAction, trustedIssuerKeys, verifyBaseReceipt, resolveCaid, operationId, now, thresholdSecretVerified, }?: ExecuteWithCapabilityOptions): Promise<{
320
+ ok: boolean;
321
+ reason: string | undefined;
322
+ scope?: undefined;
323
+ authorization?: undefined;
324
+ result?: undefined;
325
+ operation_id?: undefined;
326
+ } | {
327
+ ok: boolean;
328
+ reason: any;
329
+ scope: any;
330
+ authorization?: undefined;
331
+ result?: undefined;
332
+ operation_id?: undefined;
333
+ } | {
334
+ ok: boolean;
335
+ reason: string;
336
+ authorization: any;
337
+ scope?: undefined;
338
+ result?: undefined;
339
+ operation_id?: undefined;
340
+ } | {
341
+ ok: boolean;
342
+ reason: any;
343
+ authorization: Record<string, any> | null;
344
+ scope?: undefined;
345
+ result?: undefined;
346
+ operation_id?: undefined;
347
+ } | {
348
+ ok: boolean;
349
+ reason: string;
350
+ authorization: Record<string, any> | null;
351
+ result: any;
352
+ operation_id: string | null;
353
+ scope?: undefined;
354
+ } | {
355
+ remaining: any;
356
+ caid?: any;
357
+ ok: boolean;
358
+ result: any;
359
+ authorization: Record<string, any> | null;
360
+ operation_id: string | null;
361
+ action_digest: any;
362
+ reason?: undefined;
363
+ scope?: undefined;
364
+ } | {
365
+ caid?: any;
366
+ ok: boolean;
367
+ reason: string;
368
+ authorization: Record<string, any> | null;
369
+ operation_id: string | null;
370
+ action_digest: any;
371
+ scope?: undefined;
372
+ result?: undefined;
373
+ }>;
374
+ /**
375
+ * Execute a capability requiring m-of-n Shamir shares.
376
+ * @param {Record<string, any>} [args] capabilityReceipt, shares, and executeWithCapability passthrough options
377
+ */
378
+ export declare function executeWithThreshold({ capabilityReceipt, shares, ...options }?: ExecuteWithCapabilityOptions & {
379
+ shares?: string[];
380
+ }): Promise<{
381
+ ok: boolean;
382
+ reason: string | undefined;
383
+ scope?: undefined;
384
+ authorization?: undefined;
385
+ result?: undefined;
386
+ operation_id?: undefined;
387
+ } | {
388
+ ok: boolean;
389
+ reason: any;
390
+ scope: any;
391
+ authorization?: undefined;
392
+ result?: undefined;
393
+ operation_id?: undefined;
394
+ } | {
395
+ ok: boolean;
396
+ reason: string;
397
+ authorization: any;
398
+ scope?: undefined;
399
+ result?: undefined;
400
+ operation_id?: undefined;
401
+ } | {
402
+ ok: boolean;
403
+ reason: any;
404
+ authorization: Record<string, any> | null;
405
+ scope?: undefined;
406
+ result?: undefined;
407
+ operation_id?: undefined;
408
+ } | {
409
+ ok: boolean;
410
+ reason: string;
411
+ authorization: Record<string, any> | null;
412
+ result: any;
413
+ operation_id: string | null;
414
+ scope?: undefined;
415
+ } | {
416
+ remaining: any;
417
+ caid?: any;
418
+ ok: boolean;
419
+ result: any;
420
+ authorization: Record<string, any> | null;
421
+ operation_id: string | null;
422
+ action_digest: any;
423
+ reason?: undefined;
424
+ scope?: undefined;
425
+ } | {
426
+ caid?: any;
427
+ ok: boolean;
428
+ reason: string;
429
+ authorization: Record<string, any> | null;
430
+ operation_id: string | null;
431
+ action_digest: any;
432
+ scope?: undefined;
433
+ result?: undefined;
434
+ }>;
435
+ /**
436
+ * Authentically reconcile a committed indeterminate capability operation.
437
+ * The generic path records only a proven `executed` outcome and never restores
438
+ * budget. A deployment that wants to prove the effect boundary was not crossed
439
+ * needs a separate, action-specific negative-evidence profile.
440
+ *
441
+ * @param {object} [options]
442
+ * @param {any} [options.store]
443
+ * @param {string} [options.capabilityId]
444
+ * @param {string} [options.operationId]
445
+ * @param {object} [options.action]
446
+ * @param {object} [options.evidence]
447
+ * @param {Function} [options.verifyEvidence]
448
+ * @param {number|(() => number)} [options.now]
449
+ */
450
+ export declare function reconcileCapabilityOperation({ store, capabilityId, operationId, action, evidence, verifyEvidence, now, }?: {
451
+ store?: Record<string, any>;
452
+ capabilityId?: string;
453
+ operationId?: string;
454
+ action?: Record<string, any>;
455
+ evidence?: Record<string, any>;
456
+ verifyEvidence?: (...args: any[]) => any;
457
+ now?: number | (() => number);
458
+ }): Promise<{
459
+ ok: boolean;
460
+ outcome: string;
461
+ action_digest: any;
462
+ evidence_digest: string;
463
+ idempotent: boolean;
464
+ reason?: undefined;
465
+ } | {
466
+ ok: boolean;
467
+ reason: any;
468
+ outcome?: undefined;
469
+ action_digest?: undefined;
470
+ evidence_digest?: undefined;
471
+ idempotent?: undefined;
472
+ }>;
473
+ /**
474
+ * Issue a bounded child capability from a parent capability.
475
+ *
476
+ * Delegation is issuer-authorized metadata plus an atomic parent spend. The
477
+ * parent budget is committed as `delegated` before the child is registered;
478
+ * if child registration fails, the safe result is an orphaned child issuance
479
+ * that must be reconciled, never a child with unbacked budget.
480
+ *
481
+ * @param {object} [options]
482
+ * @param {object} [options.parentCapabilityReceipt]
483
+ * @param {Buffer|string} [options.parentSecret]
484
+ * @param {KeyMaterial} [options.issuerPrivateKey]
485
+ * @param {CapabilityBudget} [options.budget]
486
+ * @param {string|number} [options.expiry]
487
+ * @param {{m:number,n:number}} [options.threshold]
488
+ * @param {object|null} [options.scope]
489
+ * @param {string} [options.delegateId]
490
+ * @param {string} [options.capabilityId]
491
+ * @param {Buffer|string} [options.secret]
492
+ * @param {any} [options.store]
493
+ * @param {string[]} [options.trustedIssuerKeys]
494
+ * @param {string|null} [options.operationId]
495
+ * @param {number|(() => number)} [options.now]
496
+ */
497
+ export declare function delegateCapabilityReceipt({ parentCapabilityReceipt, parentSecret, issuerPrivateKey, budget, expiry, threshold, scope, delegateId, capabilityId, secret, store, trustedIssuerKeys, operationId, now, }?: {
498
+ parentCapabilityReceipt?: Record<string, any>;
499
+ parentSecret?: Buffer | string;
500
+ issuerPrivateKey?: KeyMaterial;
501
+ budget?: CapabilityBudget;
502
+ expiry?: string | number;
503
+ threshold?: {
504
+ m: number;
505
+ n: number;
506
+ };
507
+ scope?: Record<string, any> | null;
508
+ delegateId?: string;
509
+ capabilityId?: string;
510
+ secret?: Buffer | string;
511
+ store?: Record<string, any>;
512
+ trustedIssuerKeys?: string[];
513
+ operationId?: string | null;
514
+ now?: number | (() => number);
515
+ }): Promise<{
516
+ ok: boolean;
517
+ reason: any;
518
+ operation_id?: undefined;
519
+ capabilityReceipt?: undefined;
520
+ secret?: undefined;
521
+ shares?: undefined;
522
+ remaining?: undefined;
523
+ } | {
524
+ ok: boolean;
525
+ reason: string;
526
+ operation_id: string;
527
+ capabilityReceipt?: undefined;
528
+ secret?: undefined;
529
+ shares?: undefined;
530
+ remaining?: undefined;
531
+ } | {
532
+ ok: boolean;
533
+ capabilityReceipt: Readonly<{
534
+ '@version': string;
535
+ receipt: Record<string, any>;
536
+ capability: {
537
+ version: string;
538
+ id: string;
539
+ secret_hash: string;
540
+ budget: {
541
+ amount: any;
542
+ currency: string;
543
+ };
544
+ consumed: number;
545
+ threshold: {
546
+ m: number;
547
+ n: number;
548
+ };
549
+ scope: {
550
+ [x: string]: any;
551
+ profile: any;
552
+ operation_id_field: string;
553
+ };
554
+ delegation_chain: Record<string, any>[];
555
+ expiry: string;
556
+ };
557
+ capability_signature: {
558
+ algorithm: string;
559
+ public_key: string;
560
+ value: string;
561
+ };
562
+ }>;
563
+ secret: Buffer<ArrayBuffer> | null;
564
+ shares: string[] | null;
565
+ operation_id: string;
566
+ remaining: any;
567
+ reason?: undefined;
568
+ }>;
569
+ declare const _default: {
570
+ CAPABILITY_RECEIPT_VERSION: string;
571
+ CAPABILITY_STATE_VERSION: string;
572
+ CAPABILITY_SHARE_VERSION: string;
573
+ CAPABILITY_SCOPE_PROFILE: string;
574
+ CAPABILITY_CAID_SCOPE_PROFILE: string;
575
+ CAPABILITY_STATE_DDL: string;
576
+ CAPABILITY_SQL: Readonly<{
577
+ register: "INSERT INTO ep_capability_state (capability_id, budget_amount, currency, expires_at, capability_fingerprint) VALUES ($1, $2, $3, $4, $5) ON CONFLICT (capability_id) DO UPDATE SET capability_fingerprint = COALESCE(ep_capability_state.capability_fingerprint, EXCLUDED.capability_fingerprint) WHERE ep_capability_state.budget_amount = EXCLUDED.budget_amount AND ep_capability_state.currency = EXCLUDED.currency AND ep_capability_state.expires_at = EXCLUDED.expires_at";
578
+ readState: "SELECT capability_id, capability_fingerprint, budget_amount, currency, consumed_amount, reserved_amount, expires_at FROM ep_capability_state WHERE capability_id = $1 FOR UPDATE";
579
+ readOperation: "SELECT operation_id, capability_id, action_digest, amount, currency, status, reservation_token, outcome, reconciliation_outcome, reconciliation_evidence_digest, reconciled_at FROM ep_capability_operations WHERE operation_id = $1 FOR UPDATE";
580
+ insertOperation: "INSERT INTO ep_capability_operations (operation_id, capability_id, action_digest, amount, currency, status, reservation_token, reserved_at) VALUES ($1, $2, $3, $4, $5, 'reserved', $6, $7)";
581
+ reserveState: "UPDATE ep_capability_state SET reserved_amount = reserved_amount + $2 WHERE capability_id = $1 AND budget_amount - consumed_amount - reserved_amount >= $2";
582
+ commitOperation: "UPDATE ep_capability_operations SET status = 'committed', outcome = $3, committed_at = $4 WHERE operation_id = $1 AND capability_id = $2 AND status = 'reserved' AND reservation_token = $5";
583
+ reconcileOperation: "UPDATE ep_capability_operations SET reconciliation_outcome = $3, reconciliation_evidence_digest = $4, reconciled_at = $5 WHERE operation_id = $1 AND capability_id = $2 AND status = 'committed' AND outcome = 'indeterminate' AND reconciliation_outcome IS NULL";
584
+ commitState: "UPDATE ep_capability_state SET reserved_amount = reserved_amount - $2, consumed_amount = consumed_amount + $2 WHERE capability_id = $1 AND reserved_amount >= $2";
585
+ }>;
586
+ capabilityBaseReceiptDigest: typeof capabilityBaseReceiptDigest;
587
+ capabilityActionDigest: typeof capabilityActionDigest;
588
+ verifyCapabilityScope: typeof verifyCapabilityScope;
589
+ mintCapabilityReceipt: typeof mintCapabilityReceipt;
590
+ verifyCapabilityReceipt: typeof verifyCapabilityReceipt;
591
+ splitCapabilitySecret: typeof splitCapabilitySecret;
592
+ reconstructCapabilitySecret: typeof reconstructCapabilitySecret;
593
+ createMemoryCapabilityStore: typeof createMemoryCapabilityStore;
594
+ createPostgresCapabilityStore: typeof createPostgresCapabilityStore;
595
+ executeWithCapability: typeof executeWithCapability;
596
+ executeWithThreshold: typeof executeWithThreshold;
597
+ reconcileCapabilityOperation: typeof reconcileCapabilityOperation;
598
+ delegateCapabilityReceipt: typeof delegateCapabilityReceipt;
599
+ };
600
+ export default _default;
601
+ //# sourceMappingURL=capability-receipt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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