@agirails/sdk 2.0.0 → 2.0.1-beta

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 (405) hide show
  1. package/README.md +108 -116
  2. package/dist/ACTPClient.d.ts +33 -456
  3. package/dist/ACTPClient.d.ts.map +1 -1
  4. package/dist/ACTPClient.js +93 -477
  5. package/dist/ACTPClient.js.map +1 -1
  6. package/dist/abi/EscrowVault.json +38 -106
  7. package/dist/builders/DeliveryProofBuilder.d.ts +1 -60
  8. package/dist/builders/DeliveryProofBuilder.d.ts.map +1 -1
  9. package/dist/builders/DeliveryProofBuilder.js +5 -81
  10. package/dist/builders/DeliveryProofBuilder.js.map +1 -1
  11. package/dist/builders/QuoteBuilder.d.ts +0 -101
  12. package/dist/builders/QuoteBuilder.d.ts.map +1 -1
  13. package/dist/builders/QuoteBuilder.js +3 -120
  14. package/dist/builders/QuoteBuilder.js.map +1 -1
  15. package/dist/builders/index.d.ts +0 -4
  16. package/dist/builders/index.d.ts.map +1 -1
  17. package/dist/builders/index.js +0 -4
  18. package/dist/builders/index.js.map +1 -1
  19. package/dist/config/networks.d.ts +0 -28
  20. package/dist/config/networks.d.ts.map +1 -1
  21. package/dist/config/networks.js +12 -60
  22. package/dist/config/networks.js.map +1 -1
  23. package/dist/errors/index.d.ts +2 -165
  24. package/dist/errors/index.d.ts.map +1 -1
  25. package/dist/errors/index.js +2 -260
  26. package/dist/errors/index.js.map +1 -1
  27. package/dist/index.d.ts +13 -61
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +36 -141
  30. package/dist/index.js.map +1 -1
  31. package/dist/protocol/ACTPKernel.d.ts +2 -229
  32. package/dist/protocol/ACTPKernel.d.ts.map +1 -1
  33. package/dist/protocol/ACTPKernel.js +33 -367
  34. package/dist/protocol/ACTPKernel.js.map +1 -1
  35. package/dist/protocol/EASHelper.d.ts +2 -57
  36. package/dist/protocol/EASHelper.d.ts.map +1 -1
  37. package/dist/protocol/EASHelper.js +37 -230
  38. package/dist/protocol/EASHelper.js.map +1 -1
  39. package/dist/protocol/EscrowVault.d.ts +2 -93
  40. package/dist/protocol/EscrowVault.d.ts.map +1 -1
  41. package/dist/protocol/EscrowVault.js +33 -122
  42. package/dist/protocol/EscrowVault.js.map +1 -1
  43. package/dist/protocol/EventMonitor.d.ts +1 -45
  44. package/dist/protocol/EventMonitor.d.ts.map +1 -1
  45. package/dist/protocol/EventMonitor.js +8 -64
  46. package/dist/protocol/EventMonitor.js.map +1 -1
  47. package/dist/protocol/MessageSigner.d.ts +2 -116
  48. package/dist/protocol/MessageSigner.d.ts.map +1 -1
  49. package/dist/protocol/MessageSigner.js +9 -215
  50. package/dist/protocol/MessageSigner.js.map +1 -1
  51. package/dist/protocol/ProofGenerator.d.ts +0 -93
  52. package/dist/protocol/ProofGenerator.d.ts.map +1 -1
  53. package/dist/protocol/ProofGenerator.js +9 -194
  54. package/dist/protocol/ProofGenerator.js.map +1 -1
  55. package/dist/protocol/QuoteBuilder.d.ts +0 -8
  56. package/dist/protocol/QuoteBuilder.d.ts.map +1 -1
  57. package/dist/protocol/QuoteBuilder.js +0 -8
  58. package/dist/protocol/QuoteBuilder.js.map +1 -1
  59. package/dist/types/eip712.d.ts +0 -34
  60. package/dist/types/eip712.d.ts.map +1 -1
  61. package/dist/types/eip712.js +5 -31
  62. package/dist/types/eip712.js.map +1 -1
  63. package/dist/types/escrow.d.ts +10 -17
  64. package/dist/types/escrow.d.ts.map +1 -1
  65. package/dist/types/index.d.ts +0 -5
  66. package/dist/types/index.d.ts.map +1 -1
  67. package/dist/types/index.js +0 -8
  68. package/dist/types/index.js.map +1 -1
  69. package/dist/types/message.d.ts +0 -32
  70. package/dist/types/message.d.ts.map +1 -1
  71. package/dist/types/message.js +0 -4
  72. package/dist/types/message.js.map +1 -1
  73. package/dist/types/state.d.ts +0 -28
  74. package/dist/types/state.d.ts.map +1 -1
  75. package/dist/types/state.js +6 -37
  76. package/dist/types/state.js.map +1 -1
  77. package/dist/types/transaction.d.ts +0 -17
  78. package/dist/types/transaction.d.ts.map +1 -1
  79. package/dist/utils/IPFSClient.d.ts +0 -113
  80. package/dist/utils/IPFSClient.d.ts.map +1 -1
  81. package/dist/utils/IPFSClient.js +7 -128
  82. package/dist/utils/IPFSClient.js.map +1 -1
  83. package/dist/utils/NonceManager.d.ts +1 -234
  84. package/dist/utils/NonceManager.d.ts.map +1 -1
  85. package/dist/utils/NonceManager.js +7 -372
  86. package/dist/utils/NonceManager.js.map +1 -1
  87. package/dist/utils/ReceivedNonceTracker.d.ts +0 -175
  88. package/dist/utils/ReceivedNonceTracker.d.ts.map +1 -1
  89. package/dist/utils/ReceivedNonceTracker.js +5 -261
  90. package/dist/utils/ReceivedNonceTracker.js.map +1 -1
  91. package/dist/utils/canonicalJson.d.ts +0 -22
  92. package/dist/utils/canonicalJson.d.ts.map +1 -1
  93. package/dist/utils/canonicalJson.js +3 -26
  94. package/dist/utils/canonicalJson.js.map +1 -1
  95. package/dist/utils/computeTypeHash.d.ts +0 -14
  96. package/dist/utils/computeTypeHash.d.ts.map +1 -1
  97. package/dist/utils/computeTypeHash.js +2 -19
  98. package/dist/utils/computeTypeHash.js.map +1 -1
  99. package/dist/utils/validation.d.ts +0 -40
  100. package/dist/utils/validation.d.ts.map +1 -1
  101. package/dist/utils/validation.js +7 -184
  102. package/dist/utils/validation.js.map +1 -1
  103. package/package.json +37 -54
  104. package/src/ACTPClient.ts +178 -692
  105. package/src/__tests__/ProofGenerator.test.ts +124 -0
  106. package/src/__tests__/QuoteBuilder.test.ts +516 -0
  107. package/src/__tests__/StateMachine.test.ts +82 -0
  108. package/src/__tests__/builders/DeliveryProofBuilder.test.ts +581 -0
  109. package/src/__tests__/integration/ACTPClient.test.ts +263 -0
  110. package/src/__tests__/integration.test.ts +289 -0
  111. package/src/__tests__/protocol/EASHelper.test.ts +472 -0
  112. package/src/__tests__/protocol/EventMonitor.test.ts +382 -0
  113. package/src/__tests__/security/ACTPKernel.security.test.ts +1167 -0
  114. package/src/__tests__/security/EscrowVault.security.test.ts +570 -0
  115. package/src/__tests__/security/MessageSigner.security.test.ts +286 -0
  116. package/src/__tests__/security/NonceReplay.security.test.ts +501 -0
  117. package/src/__tests__/security/validation.security.test.ts +376 -0
  118. package/src/__tests__/utils/IPFSClient.test.ts +262 -0
  119. package/src/__tests__/utils/NonceManager.test.ts +205 -0
  120. package/src/__tests__/utils/canonicalJson.test.ts +153 -0
  121. package/src/abi/EscrowVault.json +38 -106
  122. package/src/builders/DeliveryProofBuilder.ts +2 -3
  123. package/src/config/networks.ts +9 -32
  124. package/src/errors/index.ts +1 -298
  125. package/src/index.ts +71 -207
  126. package/src/protocol/ACTPKernel.ts +23 -175
  127. package/src/protocol/EASHelper.ts +46 -230
  128. package/src/protocol/EscrowVault.ts +50 -68
  129. package/src/protocol/EventMonitor.ts +15 -44
  130. package/src/protocol/MessageSigner.ts +13 -193
  131. package/src/protocol/ProofGenerator.ts +4 -223
  132. package/src/types/escrow.ts +11 -12
  133. package/src/types/index.ts +1 -5
  134. package/src/types/state.ts +3 -12
  135. package/src/types/transaction.ts +1 -4
  136. package/src/utils/IPFSClient.ts +5 -122
  137. package/src/utils/NonceManager.ts +8 -305
  138. package/src/utils/ReceivedNonceTracker.ts +0 -170
  139. package/src/utils/validation.ts +0 -164
  140. package/LICENSE +0 -190
  141. package/bin/actp +0 -10
  142. package/dist/abi/AgentRegistry.json +0 -782
  143. package/dist/abi/IdentityRegistry.json +0 -316
  144. package/dist/adapters/BaseAdapter.d.ts +0 -231
  145. package/dist/adapters/BaseAdapter.d.ts.map +0 -1
  146. package/dist/adapters/BaseAdapter.js +0 -393
  147. package/dist/adapters/BaseAdapter.js.map +0 -1
  148. package/dist/adapters/BeginnerAdapter.d.ts +0 -152
  149. package/dist/adapters/BeginnerAdapter.d.ts.map +0 -1
  150. package/dist/adapters/BeginnerAdapter.js +0 -168
  151. package/dist/adapters/BeginnerAdapter.js.map +0 -1
  152. package/dist/adapters/IntermediateAdapter.d.ts +0 -211
  153. package/dist/adapters/IntermediateAdapter.d.ts.map +0 -1
  154. package/dist/adapters/IntermediateAdapter.js +0 -260
  155. package/dist/adapters/IntermediateAdapter.js.map +0 -1
  156. package/dist/adapters/index.d.ts +0 -15
  157. package/dist/adapters/index.d.ts.map +0 -1
  158. package/dist/adapters/index.js +0 -26
  159. package/dist/adapters/index.js.map +0 -1
  160. package/dist/cli/commands/balance.d.ts +0 -13
  161. package/dist/cli/commands/balance.d.ts.map +0 -1
  162. package/dist/cli/commands/balance.js +0 -89
  163. package/dist/cli/commands/balance.js.map +0 -1
  164. package/dist/cli/commands/batch.d.ts +0 -24
  165. package/dist/cli/commands/batch.d.ts.map +0 -1
  166. package/dist/cli/commands/batch.js +0 -424
  167. package/dist/cli/commands/batch.js.map +0 -1
  168. package/dist/cli/commands/config.d.ts +0 -13
  169. package/dist/cli/commands/config.d.ts.map +0 -1
  170. package/dist/cli/commands/config.js +0 -192
  171. package/dist/cli/commands/config.js.map +0 -1
  172. package/dist/cli/commands/init.d.ts +0 -19
  173. package/dist/cli/commands/init.d.ts.map +0 -1
  174. package/dist/cli/commands/init.js +0 -143
  175. package/dist/cli/commands/init.js.map +0 -1
  176. package/dist/cli/commands/mint.d.ts +0 -13
  177. package/dist/cli/commands/mint.d.ts.map +0 -1
  178. package/dist/cli/commands/mint.js +0 -91
  179. package/dist/cli/commands/mint.js.map +0 -1
  180. package/dist/cli/commands/pay.d.ts +0 -18
  181. package/dist/cli/commands/pay.d.ts.map +0 -1
  182. package/dist/cli/commands/pay.js +0 -87
  183. package/dist/cli/commands/pay.js.map +0 -1
  184. package/dist/cli/commands/simulate.d.ts +0 -32
  185. package/dist/cli/commands/simulate.d.ts.map +0 -1
  186. package/dist/cli/commands/simulate.js +0 -290
  187. package/dist/cli/commands/simulate.js.map +0 -1
  188. package/dist/cli/commands/time.d.ts +0 -29
  189. package/dist/cli/commands/time.d.ts.map +0 -1
  190. package/dist/cli/commands/time.js +0 -252
  191. package/dist/cli/commands/time.js.map +0 -1
  192. package/dist/cli/commands/tx.d.ts +0 -16
  193. package/dist/cli/commands/tx.d.ts.map +0 -1
  194. package/dist/cli/commands/tx.js +0 -379
  195. package/dist/cli/commands/tx.js.map +0 -1
  196. package/dist/cli/commands/watch.d.ts +0 -20
  197. package/dist/cli/commands/watch.d.ts.map +0 -1
  198. package/dist/cli/commands/watch.js +0 -160
  199. package/dist/cli/commands/watch.js.map +0 -1
  200. package/dist/cli/index.d.ts +0 -17
  201. package/dist/cli/index.d.ts.map +0 -1
  202. package/dist/cli/index.js +0 -104
  203. package/dist/cli/index.js.map +0 -1
  204. package/dist/cli/utils/client.d.ts +0 -70
  205. package/dist/cli/utils/client.d.ts.map +0 -1
  206. package/dist/cli/utils/client.js +0 -240
  207. package/dist/cli/utils/client.js.map +0 -1
  208. package/dist/cli/utils/config.d.ts +0 -91
  209. package/dist/cli/utils/config.d.ts.map +0 -1
  210. package/dist/cli/utils/config.js +0 -240
  211. package/dist/cli/utils/config.js.map +0 -1
  212. package/dist/cli/utils/output.d.ts +0 -174
  213. package/dist/cli/utils/output.d.ts.map +0 -1
  214. package/dist/cli/utils/output.js +0 -380
  215. package/dist/cli/utils/output.js.map +0 -1
  216. package/dist/level0/Provider.d.ts +0 -106
  217. package/dist/level0/Provider.d.ts.map +0 -1
  218. package/dist/level0/Provider.js +0 -10
  219. package/dist/level0/Provider.js.map +0 -1
  220. package/dist/level0/ServiceDirectory.d.ts +0 -74
  221. package/dist/level0/ServiceDirectory.d.ts.map +0 -1
  222. package/dist/level0/ServiceDirectory.js +0 -122
  223. package/dist/level0/ServiceDirectory.js.map +0 -1
  224. package/dist/level0/index.d.ts +0 -10
  225. package/dist/level0/index.d.ts.map +0 -1
  226. package/dist/level0/index.js +0 -15
  227. package/dist/level0/index.js.map +0 -1
  228. package/dist/level0/provide.d.ts +0 -51
  229. package/dist/level0/provide.d.ts.map +0 -1
  230. package/dist/level0/provide.js +0 -113
  231. package/dist/level0/provide.js.map +0 -1
  232. package/dist/level0/request.d.ts +0 -53
  233. package/dist/level0/request.d.ts.map +0 -1
  234. package/dist/level0/request.js +0 -462
  235. package/dist/level0/request.js.map +0 -1
  236. package/dist/level1/Agent.d.ts +0 -472
  237. package/dist/level1/Agent.d.ts.map +0 -1
  238. package/dist/level1/Agent.js +0 -1091
  239. package/dist/level1/Agent.js.map +0 -1
  240. package/dist/level1/index.d.ts +0 -10
  241. package/dist/level1/index.d.ts.map +0 -1
  242. package/dist/level1/index.js +0 -30
  243. package/dist/level1/index.js.map +0 -1
  244. package/dist/level1/pricing/PriceCalculator.d.ts +0 -62
  245. package/dist/level1/pricing/PriceCalculator.d.ts.map +0 -1
  246. package/dist/level1/pricing/PriceCalculator.js +0 -237
  247. package/dist/level1/pricing/PriceCalculator.js.map +0 -1
  248. package/dist/level1/pricing/PricingStrategy.d.ts +0 -179
  249. package/dist/level1/pricing/PricingStrategy.d.ts.map +0 -1
  250. package/dist/level1/pricing/PricingStrategy.js +0 -11
  251. package/dist/level1/pricing/PricingStrategy.js.map +0 -1
  252. package/dist/level1/types/Job.d.ts +0 -166
  253. package/dist/level1/types/Job.d.ts.map +0 -1
  254. package/dist/level1/types/Job.js +0 -11
  255. package/dist/level1/types/Job.js.map +0 -1
  256. package/dist/level1/types/Options.d.ts +0 -258
  257. package/dist/level1/types/Options.d.ts.map +0 -1
  258. package/dist/level1/types/Options.js +0 -8
  259. package/dist/level1/types/Options.js.map +0 -1
  260. package/dist/level1/types/index.d.ts +0 -8
  261. package/dist/level1/types/index.d.ts.map +0 -1
  262. package/dist/level1/types/index.js +0 -8
  263. package/dist/level1/types/index.js.map +0 -1
  264. package/dist/protocol/AgentRegistry.d.ts +0 -177
  265. package/dist/protocol/AgentRegistry.d.ts.map +0 -1
  266. package/dist/protocol/AgentRegistry.js +0 -449
  267. package/dist/protocol/AgentRegistry.js.map +0 -1
  268. package/dist/protocol/DIDManager.d.ts +0 -289
  269. package/dist/protocol/DIDManager.d.ts.map +0 -1
  270. package/dist/protocol/DIDManager.js +0 -481
  271. package/dist/protocol/DIDManager.js.map +0 -1
  272. package/dist/protocol/DIDResolver.d.ts +0 -236
  273. package/dist/protocol/DIDResolver.d.ts.map +0 -1
  274. package/dist/protocol/DIDResolver.js +0 -495
  275. package/dist/protocol/DIDResolver.js.map +0 -1
  276. package/dist/runtime/BlockchainRuntime.d.ts +0 -360
  277. package/dist/runtime/BlockchainRuntime.d.ts.map +0 -1
  278. package/dist/runtime/BlockchainRuntime.js +0 -767
  279. package/dist/runtime/BlockchainRuntime.js.map +0 -1
  280. package/dist/runtime/IACTPRuntime.d.ts +0 -271
  281. package/dist/runtime/IACTPRuntime.d.ts.map +0 -1
  282. package/dist/runtime/IACTPRuntime.js +0 -15
  283. package/dist/runtime/IACTPRuntime.js.map +0 -1
  284. package/dist/runtime/MockRuntime.d.ts +0 -445
  285. package/dist/runtime/MockRuntime.d.ts.map +0 -1
  286. package/dist/runtime/MockRuntime.js +0 -1065
  287. package/dist/runtime/MockRuntime.js.map +0 -1
  288. package/dist/runtime/MockStateManager.d.ts +0 -233
  289. package/dist/runtime/MockStateManager.d.ts.map +0 -1
  290. package/dist/runtime/MockStateManager.js +0 -533
  291. package/dist/runtime/MockStateManager.js.map +0 -1
  292. package/dist/runtime/index.d.ts +0 -14
  293. package/dist/runtime/index.d.ts.map +0 -1
  294. package/dist/runtime/index.js +0 -42
  295. package/dist/runtime/index.js.map +0 -1
  296. package/dist/runtime/types/MockState.d.ts +0 -167
  297. package/dist/runtime/types/MockState.d.ts.map +0 -1
  298. package/dist/runtime/types/MockState.js +0 -43
  299. package/dist/runtime/types/MockState.js.map +0 -1
  300. package/dist/types/agent.d.ts +0 -76
  301. package/dist/types/agent.d.ts.map +0 -1
  302. package/dist/types/agent.js +0 -8
  303. package/dist/types/agent.js.map +0 -1
  304. package/dist/types/did.d.ts +0 -192
  305. package/dist/types/did.d.ts.map +0 -1
  306. package/dist/types/did.js +0 -38
  307. package/dist/types/did.js.map +0 -1
  308. package/dist/utils/ErrorRecoveryGuide.d.ts +0 -125
  309. package/dist/utils/ErrorRecoveryGuide.d.ts.map +0 -1
  310. package/dist/utils/ErrorRecoveryGuide.js +0 -579
  311. package/dist/utils/ErrorRecoveryGuide.js.map +0 -1
  312. package/dist/utils/Helpers.d.ts +0 -453
  313. package/dist/utils/Helpers.d.ts.map +0 -1
  314. package/dist/utils/Helpers.js +0 -623
  315. package/dist/utils/Helpers.js.map +0 -1
  316. package/dist/utils/Logger.d.ts +0 -195
  317. package/dist/utils/Logger.d.ts.map +0 -1
  318. package/dist/utils/Logger.js +0 -382
  319. package/dist/utils/Logger.js.map +0 -1
  320. package/dist/utils/RateLimiter.d.ts +0 -253
  321. package/dist/utils/RateLimiter.d.ts.map +0 -1
  322. package/dist/utils/RateLimiter.js +0 -424
  323. package/dist/utils/RateLimiter.js.map +0 -1
  324. package/dist/utils/SDKLifecycle.d.ts +0 -156
  325. package/dist/utils/SDKLifecycle.d.ts.map +0 -1
  326. package/dist/utils/SDKLifecycle.js +0 -347
  327. package/dist/utils/SDKLifecycle.js.map +0 -1
  328. package/dist/utils/SecureNonce.d.ts +0 -57
  329. package/dist/utils/SecureNonce.d.ts.map +0 -1
  330. package/dist/utils/SecureNonce.js +0 -80
  331. package/dist/utils/SecureNonce.js.map +0 -1
  332. package/dist/utils/Semaphore.d.ts +0 -123
  333. package/dist/utils/Semaphore.d.ts.map +0 -1
  334. package/dist/utils/Semaphore.js +0 -247
  335. package/dist/utils/Semaphore.js.map +0 -1
  336. package/dist/utils/UsedAttestationTracker.d.ts +0 -167
  337. package/dist/utils/UsedAttestationTracker.d.ts.map +0 -1
  338. package/dist/utils/UsedAttestationTracker.js +0 -309
  339. package/dist/utils/UsedAttestationTracker.js.map +0 -1
  340. package/dist/utils/fsSafe.d.ts +0 -14
  341. package/dist/utils/fsSafe.d.ts.map +0 -1
  342. package/dist/utils/fsSafe.js +0 -89
  343. package/dist/utils/fsSafe.js.map +0 -1
  344. package/dist/utils/index.d.ts +0 -15
  345. package/dist/utils/index.d.ts.map +0 -1
  346. package/dist/utils/index.js +0 -51
  347. package/dist/utils/index.js.map +0 -1
  348. package/dist/utils/security.d.ts +0 -147
  349. package/dist/utils/security.d.ts.map +0 -1
  350. package/dist/utils/security.js +0 -391
  351. package/dist/utils/security.js.map +0 -1
  352. package/src/abi/AgentRegistry.json +0 -782
  353. package/src/abi/IdentityRegistry.json +0 -316
  354. package/src/adapters/BaseAdapter.ts +0 -473
  355. package/src/adapters/BeginnerAdapter.ts +0 -232
  356. package/src/adapters/IntermediateAdapter.ts +0 -316
  357. package/src/adapters/index.ts +0 -25
  358. package/src/cli/commands/balance.ts +0 -110
  359. package/src/cli/commands/batch.ts +0 -487
  360. package/src/cli/commands/config.ts +0 -231
  361. package/src/cli/commands/init.ts +0 -161
  362. package/src/cli/commands/mint.ts +0 -116
  363. package/src/cli/commands/pay.ts +0 -113
  364. package/src/cli/commands/simulate.ts +0 -345
  365. package/src/cli/commands/time.ts +0 -303
  366. package/src/cli/commands/tx.ts +0 -448
  367. package/src/cli/commands/watch.ts +0 -211
  368. package/src/cli/index.ts +0 -116
  369. package/src/cli/utils/client.ts +0 -249
  370. package/src/cli/utils/config.ts +0 -282
  371. package/src/cli/utils/output.ts +0 -465
  372. package/src/level0/Provider.ts +0 -117
  373. package/src/level0/ServiceDirectory.ts +0 -131
  374. package/src/level0/index.ts +0 -10
  375. package/src/level0/provide.ts +0 -131
  376. package/src/level0/request.ts +0 -494
  377. package/src/level1/Agent.ts +0 -1432
  378. package/src/level1/index.ts +0 -10
  379. package/src/level1/pricing/PriceCalculator.ts +0 -255
  380. package/src/level1/pricing/PricingStrategy.ts +0 -198
  381. package/src/level1/types/Job.ts +0 -179
  382. package/src/level1/types/Options.ts +0 -291
  383. package/src/level1/types/index.ts +0 -8
  384. package/src/protocol/AgentRegistry.ts +0 -559
  385. package/src/protocol/DIDManager.ts +0 -629
  386. package/src/protocol/DIDResolver.ts +0 -554
  387. package/src/runtime/BlockchainRuntime.ts +0 -993
  388. package/src/runtime/IACTPRuntime.ts +0 -284
  389. package/src/runtime/MockRuntime.ts +0 -1244
  390. package/src/runtime/MockStateManager.ts +0 -576
  391. package/src/runtime/index.ts +0 -25
  392. package/src/runtime/types/MockState.ts +0 -227
  393. package/src/types/agent.ts +0 -79
  394. package/src/types/did.ts +0 -223
  395. package/src/utils/ErrorRecoveryGuide.ts +0 -675
  396. package/src/utils/Helpers.ts +0 -688
  397. package/src/utils/Logger.ts +0 -484
  398. package/src/utils/RateLimiter.ts +0 -534
  399. package/src/utils/SDKLifecycle.ts +0 -416
  400. package/src/utils/SecureNonce.ts +0 -78
  401. package/src/utils/Semaphore.ts +0 -276
  402. package/src/utils/UsedAttestationTracker.ts +0 -387
  403. package/src/utils/fsSafe.ts +0 -75
  404. package/src/utils/index.ts +0 -80
  405. package/src/utils/security.ts +0 -418
@@ -2,83 +2,11 @@ import { keccak256, toUtf8Bytes, AbiCoder, BytesLike } from 'ethers';
2
2
  import { DeliveryProof } from '../types';
3
3
  import { DeliveryProofData, deliveryProofDataFromProof } from '../types/eip712';
4
4
 
5
- /**
6
- * SECURITY FIX (MEDIUM-2): URL validation configuration for SSRF prevention
7
- */
8
- export interface URLValidationConfig {
9
- /**
10
- * Allowed URL protocols (default: ['https:'])
11
- * Set to ['https:', 'http:'] to allow HTTP in development
12
- */
13
- allowedProtocols?: string[];
14
-
15
- /**
16
- * Allow localhost URLs (default: false in production, true in dev)
17
- */
18
- allowLocalhost?: boolean;
19
-
20
- /**
21
- * Maximum response size in bytes (default: 10MB)
22
- */
23
- maxSize?: number;
24
-
25
- /**
26
- * Request timeout in milliseconds (default: 30000)
27
- */
28
- timeout?: number;
29
-
30
- /**
31
- * Blocked hostnames (e.g., internal services)
32
- */
33
- blockedHosts?: string[];
34
- }
35
-
36
- /**
37
- * Default URL validation config - SECURE by default
38
- */
39
- const DEFAULT_URL_CONFIG: Required<URLValidationConfig> = {
40
- allowedProtocols: ['https:'],
41
- allowLocalhost: false,
42
- maxSize: 10 * 1024 * 1024, // 10MB
43
- timeout: 30000, // 30 seconds
44
- blockedHosts: [
45
- 'metadata.google.internal',
46
- '169.254.169.254', // AWS/GCP metadata
47
- 'metadata.aws.internal',
48
- 'localhost',
49
- '127.0.0.1',
50
- '0.0.0.0',
51
- '[::1]',
52
- ],
53
- };
54
-
55
5
  /**
56
6
  * ProofGenerator - Content hashing and delivery proofs
57
7
  * Reference: Yellow Paper §11.4.1
58
- *
59
- * SECURITY FIX (MEDIUM-2): Now includes URL validation for SSRF prevention
60
8
  */
61
9
  export class ProofGenerator {
62
- private readonly urlConfig: Required<URLValidationConfig>;
63
-
64
- /**
65
- * Create ProofGenerator with optional URL validation config
66
- *
67
- * @param urlConfig - URL validation configuration for hashFromUrl()
68
- */
69
- constructor(urlConfig?: URLValidationConfig) {
70
- this.urlConfig = {
71
- ...DEFAULT_URL_CONFIG,
72
- ...urlConfig,
73
- };
74
-
75
- // If localhost is explicitly allowed, remove from blocked hosts
76
- if (urlConfig?.allowLocalhost) {
77
- this.urlConfig.blockedHosts = this.urlConfig.blockedHosts.filter(
78
- (h) => !['localhost', '127.0.0.1', '0.0.0.0', '[::1]'].includes(h)
79
- );
80
- }
81
- }
82
10
  /**
83
11
  * Hash deliverable content
84
12
  * Uses Keccak256 per Yellow Paper §11.4.1
@@ -176,163 +104,16 @@ export class ProofGenerator {
176
104
 
177
105
  /**
178
106
  * Generate content hash from URL (for IPFS/Arweave)
179
- *
180
- * SECURITY FIX (MEDIUM-2): Now includes:
181
- * - Protocol validation (HTTPS only by default)
182
- * - Hostname blocklist (prevents SSRF to internal services)
183
- * - Size limits (prevents DoS via large responses)
184
- * - Request timeout
185
- *
186
- * @param url - URL to fetch content from
187
- * @returns Keccak256 hash of content
188
- * @throws Error if URL is blocked, too large, or fetch fails
189
107
  */
190
108
  async hashFromUrl(url: string): Promise<string> {
191
- // SECURITY FIX (MEDIUM-2): Validate URL before fetching
192
- this.validateUrl(url);
193
-
194
109
  // In browser/Node.js environment with fetch
195
110
  try {
196
- // Create AbortController for timeout
197
- const controller = new AbortController();
198
- const timeoutId = setTimeout(() => controller.abort(), this.urlConfig.timeout);
199
-
200
- try {
201
- const response = await fetch(url, {
202
- signal: controller.signal,
203
- // Prevent following redirects to blocked hosts
204
- redirect: 'follow',
205
- });
206
-
207
- clearTimeout(timeoutId);
208
-
209
- if (!response.ok) {
210
- throw new Error(`HTTP error: ${response.status} ${response.statusText}`);
211
- }
212
-
213
- // SECURITY FIX (MEDIUM-2): Check Content-Length header first
214
- const contentLength = response.headers.get('content-length');
215
- if (contentLength) {
216
- const size = parseInt(contentLength, 10);
217
- if (size > this.urlConfig.maxSize) {
218
- throw new Error(
219
- `Content too large: ${size} bytes exceeds maximum of ${this.urlConfig.maxSize} bytes`
220
- );
221
- }
222
- }
223
-
224
- // SECURITY FIX (MEDIUM-2): Read response with size limit
225
- const chunks: Uint8Array[] = [];
226
- let totalSize = 0;
227
- const reader = response.body?.getReader();
228
-
229
- if (!reader) {
230
- throw new Error('Response body is not readable');
231
- }
232
-
233
- while (true) {
234
- const { done, value } = await reader.read();
235
-
236
- if (done) break;
237
-
238
- totalSize += value.length;
239
-
240
- // Check size limit during streaming
241
- if (totalSize > this.urlConfig.maxSize) {
242
- reader.cancel();
243
- throw new Error(
244
- `Content too large: ${totalSize}+ bytes exceeds maximum of ${this.urlConfig.maxSize} bytes`
245
- );
246
- }
247
-
248
- chunks.push(value);
249
- }
250
-
251
- // Concatenate chunks
252
- const buffer = Buffer.concat(chunks.map(c => Buffer.from(c)));
253
- return this.hashContent(buffer);
254
- } finally {
255
- clearTimeout(timeoutId);
256
- }
111
+ const response = await fetch(url);
112
+ const arrayBuffer = await response.arrayBuffer();
113
+ const buffer = Buffer.from(arrayBuffer);
114
+ return this.hashContent(buffer);
257
115
  } catch (error) {
258
- if (error instanceof Error && error.name === 'AbortError') {
259
- throw new Error(`Request timed out after ${this.urlConfig.timeout}ms for ${url}`);
260
- }
261
116
  throw new Error(`Failed to fetch content from ${url}: ${error}`);
262
117
  }
263
118
  }
264
-
265
- /**
266
- * SECURITY FIX (MEDIUM-2): Validate URL against security rules
267
- *
268
- * @param url - URL to validate
269
- * @throws Error if URL is not allowed
270
- */
271
- private validateUrl(url: string): void {
272
- let parsed: URL;
273
-
274
- try {
275
- parsed = new URL(url);
276
- } catch {
277
- throw new Error(`Invalid URL: ${url}`);
278
- }
279
-
280
- // Check protocol
281
- if (!this.urlConfig.allowedProtocols.includes(parsed.protocol)) {
282
- throw new Error(
283
- `URL protocol "${parsed.protocol}" not allowed. ` +
284
- `Allowed protocols: ${this.urlConfig.allowedProtocols.join(', ')}`
285
- );
286
- }
287
-
288
- // Check blocked hosts
289
- const hostname = parsed.hostname.toLowerCase();
290
- if (this.urlConfig.blockedHosts.includes(hostname)) {
291
- throw new Error(
292
- `URL hostname "${hostname}" is blocked for security reasons. ` +
293
- `This prevents SSRF attacks to internal services.`
294
- );
295
- }
296
-
297
- // Check for private IP ranges (additional SSRF protection)
298
- if (this.isPrivateIP(hostname)) {
299
- throw new Error(
300
- `URL hostname "${hostname}" resolves to a private IP address. ` +
301
- `This is blocked for security reasons (SSRF prevention).`
302
- );
303
- }
304
- }
305
-
306
- /**
307
- * Check if hostname is a private IP address
308
- *
309
- * @param hostname - Hostname to check
310
- * @returns true if hostname is a private IP
311
- */
312
- private isPrivateIP(hostname: string): boolean {
313
- // IPv4 private ranges
314
- const ipv4PrivateRanges = [
315
- /^10\./, // 10.0.0.0 - 10.255.255.255
316
- /^172\.(1[6-9]|2[0-9]|3[0-1])\./, // 172.16.0.0 - 172.31.255.255
317
- /^192\.168\./, // 192.168.0.0 - 192.168.255.255
318
- /^127\./, // 127.0.0.0 - 127.255.255.255 (loopback)
319
- /^169\.254\./, // 169.254.0.0 - 169.254.255.255 (link-local)
320
- /^0\./, // 0.0.0.0/8
321
- ];
322
-
323
- for (const range of ipv4PrivateRanges) {
324
- if (range.test(hostname)) {
325
- return true;
326
- }
327
- }
328
-
329
- return false;
330
- }
331
-
332
- /**
333
- * Get the URL validation config (for testing/inspection)
334
- */
335
- getUrlConfig(): Required<URLValidationConfig> {
336
- return { ...this.urlConfig };
337
- }
338
119
  }
@@ -2,26 +2,25 @@
2
2
  * Escrow creation parameters
3
3
  */
4
4
  export interface CreateEscrowParams {
5
- /** Escrow identifier (bytes32). In ACTP standard this is typically the txId. */
6
- escrowId: string;
7
- /** Consumer/requester who funds the escrow */
8
- requester: string;
9
- /** Provider who receives payout on settlement */
10
- provider: string;
11
- /** Amount locked in escrow (USDC wei, 6 decimals) */
5
+ kernelAddress: string;
6
+ txId: string;
7
+ token: string;
12
8
  amount: bigint;
9
+ beneficiary: string;
13
10
  }
14
11
 
15
12
  /**
16
- * Escrow state (matches on-chain EscrowVault.EscrowData struct)
13
+ * Escrow state
17
14
  */
18
15
  export interface Escrow {
19
16
  escrowId: string;
20
- requester: string;
21
- provider: string;
17
+ kernel: string;
18
+ txId: string;
19
+ token: string;
22
20
  amount: bigint;
23
- releasedAmount: bigint;
24
- active: boolean;
21
+ beneficiary: string;
22
+ createdAt: number;
23
+ released: boolean;
25
24
  }
26
25
 
27
26
 
@@ -7,8 +7,4 @@ export * from './transaction';
7
7
  export * from './escrow';
8
8
  export * from './message';
9
9
  export * from './eip712';
10
- export * from './agent';
11
- export * from './did';
12
- // Note: storage and archive types are not yet implemented in this version
13
- // export * from './storage';
14
- // export * from './archive';
10
+
@@ -17,23 +17,14 @@ export enum State {
17
17
  export class StateMachine {
18
18
  /**
19
19
  * Valid state transitions per Yellow Paper §3.2.2
20
- *
21
- * SECURITY FIX (CRITICAL-1): State machine must match ACTPKernel contract exactly
22
- * Per CLAUDE.md §Architecture Overview - ACTP Protocol State Machine:
23
- * - COMMITTED can transition to IN_PROGRESS, DELIVERED, or CANCELLED
24
- * - IN_PROGRESS can transition to DELIVERED or CANCELLED (not DISPUTED)
25
- * - DISPUTED can only transition to SETTLED (not CANCELLED)
26
20
  */
27
21
  private static readonly TRANSITIONS: Record<State, State[]> = {
28
22
  [State.INITIATED]: [State.QUOTED, State.COMMITTED, State.CANCELLED], // Allow direct INITIATED → COMMITTED (AIP-3)
29
23
  [State.QUOTED]: [State.COMMITTED, State.CANCELLED],
30
- // SECURITY FIX (CRITICAL-1): Add DELIVERED (can skip IN_PROGRESS)
31
- [State.COMMITTED]: [State.IN_PROGRESS, State.DELIVERED, State.CANCELLED],
32
- // SECURITY FIX (CRITICAL-1): Remove DISPUTED, add CANCELLED
33
- [State.IN_PROGRESS]: [State.DELIVERED, State.CANCELLED],
24
+ [State.COMMITTED]: [State.IN_PROGRESS, State.CANCELLED],
25
+ [State.IN_PROGRESS]: [State.DELIVERED, State.DISPUTED],
34
26
  [State.DELIVERED]: [State.SETTLED, State.DISPUTED],
35
- // SECURITY FIX (CRITICAL-1): Remove CANCELLED (disputes resolve to SETTLED only)
36
- [State.DISPUTED]: [State.SETTLED],
27
+ [State.DISPUTED]: [State.SETTLED, State.CANCELLED],
37
28
  [State.SETTLED]: [], // Terminal state
38
29
  [State.CANCELLED]: [] // Terminal state
39
30
  };
@@ -11,15 +11,11 @@ export interface Transaction {
11
11
  amount: bigint;
12
12
  state: State;
13
13
  createdAt: number;
14
- updatedAt: number;
15
14
  deadline: number;
16
15
  disputeWindow: number;
17
16
  escrowContract: string;
18
17
  escrowId: string;
19
- serviceHash: string;
20
- attestationUID: string;
21
18
  metadata: string;
22
- platformFeeBpsLocked: number;
23
19
  }
24
20
 
25
21
  /**
@@ -55,3 +51,4 @@ export interface EconomicParams {
55
51
  providerPenaltyBps: number;
56
52
  }
57
53
 
54
+
@@ -59,24 +59,6 @@ export interface IPFSClientConfig {
59
59
  * Default: 60000 (60 seconds)
60
60
  */
61
61
  timeout?: number;
62
-
63
- /**
64
- * SECURITY FIX (MEDIUM-3): Maximum content size in bytes
65
- * Default: 50MB (50 * 1024 * 1024)
66
- */
67
- maxSize?: number;
68
-
69
- /**
70
- * SECURITY FIX (MEDIUM-3): Allowed URL protocols
71
- * Default: ['http:', 'https:'] (http for localhost, https for remote)
72
- */
73
- allowedProtocols?: string[];
74
-
75
- /**
76
- * SECURITY FIX (MEDIUM-3): Allow localhost URLs
77
- * Default: true (required for local IPFS daemon)
78
- */
79
- allowLocalhost?: boolean;
80
62
  }
81
63
 
82
64
  /**
@@ -99,45 +81,21 @@ export const IPFS_CONFIGS = {
99
81
  /**
100
82
  * IPFS HTTP Client Implementation
101
83
  * Uses ipfs-http-client library
102
- *
103
- * SECURITY FIX (MEDIUM-3): Now includes URL and size validation
104
84
  */
105
85
  export class IPFSHTTPClientImpl implements IPFSClient {
106
86
  private client: IPFSHTTPClient;
107
- private config: Required<IPFSClientConfig>;
108
-
109
- // SECURITY FIX (MEDIUM-3): Default security settings
110
- private static readonly DEFAULT_MAX_SIZE = 50 * 1024 * 1024; // 50MB
111
- private static readonly DEFAULT_ALLOWED_PROTOCOLS = ['http:', 'https:'];
112
- private static readonly BLOCKED_HOSTS = [
113
- 'metadata.google.internal',
114
- '169.254.169.254',
115
- 'metadata.aws.internal',
116
- ];
87
+ private config: IPFSClientConfig;
117
88
 
118
89
  /**
119
90
  * Create IPFS client
120
- *
121
- * SECURITY FIX (MEDIUM-3): Validates URL and adds size limits
122
- *
123
91
  * @param config - IPFS client configuration
124
- * @throws Error if URL is invalid or blocked
125
92
  */
126
93
  constructor(config: IPFSClientConfig = {}) {
127
- const url = config.url || 'http://localhost:5001';
128
-
129
- // SECURITY FIX (MEDIUM-3): Validate URL
130
- this.validateUrl(url, config.allowLocalhost ?? true, config.allowedProtocols);
131
-
132
94
  this.config = {
133
- url,
95
+ url: config.url || 'http://localhost:5001',
134
96
  timeout: config.timeout || 60000,
135
- maxSize: config.maxSize || IPFSHTTPClientImpl.DEFAULT_MAX_SIZE,
136
- allowedProtocols: config.allowedProtocols || IPFSHTTPClientImpl.DEFAULT_ALLOWED_PROTOCOLS,
137
- allowLocalhost: config.allowLocalhost ?? true,
138
- auth: config.auth,
139
- headers: config.headers,
140
- } as Required<IPFSClientConfig>;
97
+ ...config
98
+ };
141
99
 
142
100
  const options: Options = {
143
101
  url: this.config.url,
@@ -159,76 +117,15 @@ export class IPFSHTTPClientImpl implements IPFSClient {
159
117
  this.client = create(options);
160
118
  }
161
119
 
162
- /**
163
- * SECURITY FIX (MEDIUM-3): Validate IPFS endpoint URL
164
- */
165
- private validateUrl(
166
- url: string,
167
- allowLocalhost: boolean,
168
- allowedProtocols?: string[]
169
- ): void {
170
- let parsed: URL;
171
-
172
- try {
173
- parsed = new URL(url);
174
- } catch {
175
- throw new Error(`Invalid IPFS endpoint URL: ${url}`);
176
- }
177
-
178
- const protocols = allowedProtocols || IPFSHTTPClientImpl.DEFAULT_ALLOWED_PROTOCOLS;
179
- if (!protocols.includes(parsed.protocol)) {
180
- throw new Error(
181
- `IPFS endpoint protocol "${parsed.protocol}" not allowed. ` +
182
- `Allowed protocols: ${protocols.join(', ')}`
183
- );
184
- }
185
-
186
- const hostname = parsed.hostname.toLowerCase();
187
-
188
- // Check blocked hosts (cloud metadata endpoints)
189
- if (IPFSHTTPClientImpl.BLOCKED_HOSTS.includes(hostname)) {
190
- throw new Error(
191
- `IPFS endpoint hostname "${hostname}" is blocked for security reasons.`
192
- );
193
- }
194
-
195
- // Check localhost
196
- const isLocalhost = ['localhost', '127.0.0.1', '0.0.0.0', '[::1]'].includes(hostname);
197
- if (isLocalhost && !allowLocalhost) {
198
- throw new Error(
199
- `Localhost IPFS endpoints are disabled. Set allowLocalhost: true to enable.`
200
- );
201
- }
202
-
203
- // For remote hosts, require HTTPS
204
- if (!isLocalhost && parsed.protocol !== 'https:') {
205
- console.warn(
206
- `[SECURITY WARNING] Using non-HTTPS protocol "${parsed.protocol}" for remote IPFS endpoint "${hostname}". ` +
207
- `This may expose data in transit. Consider using HTTPS.`
208
- );
209
- }
210
- }
211
-
212
120
  /**
213
121
  * Upload data to IPFS
214
- *
215
- * SECURITY FIX (MEDIUM-3): Validates size before upload
216
- *
217
122
  * @param data - JSON string or buffer
218
123
  * @returns CIDv1 string (base32)
219
- * @throws Error if data exceeds maxSize
220
124
  */
221
125
  async add(data: string | Buffer): Promise<string> {
222
126
  try {
223
127
  const content = typeof data === 'string' ? Buffer.from(data, 'utf-8') : data;
224
128
 
225
- // SECURITY FIX (MEDIUM-3): Check size before upload
226
- if (content.length > this.config.maxSize) {
227
- throw new Error(
228
- `Content too large: ${content.length} bytes exceeds maximum of ${this.config.maxSize} bytes`
229
- );
230
- }
231
-
232
129
  const result = await this.client.add(content, {
233
130
  cidVersion: 1, // Use CIDv1 (base32)
234
131
  hashAlg: 'sha2-256',
@@ -256,33 +153,19 @@ export class IPFSHTTPClientImpl implements IPFSClient {
256
153
 
257
154
  /**
258
155
  * Retrieve content from IPFS
259
- *
260
- * SECURITY FIX (MEDIUM-3): Validates size during retrieval
261
- *
262
156
  * @param cid - IPFS CID
263
157
  * @returns Content as string
264
- * @throws Error if content exceeds maxSize
265
158
  */
266
159
  async get(cid: string): Promise<string> {
267
160
  try {
268
161
  const chunks: Uint8Array[] = [];
269
- let totalLength = 0;
270
162
 
271
163
  for await (const chunk of this.client.cat(cid)) {
272
- totalLength += chunk.length;
273
-
274
- // SECURITY FIX (MEDIUM-3): Check size during streaming to prevent DoS
275
- if (totalLength > this.config.maxSize) {
276
- throw new Error(
277
- `Content too large: ${totalLength}+ bytes exceeds maximum of ${this.config.maxSize} bytes. ` +
278
- `Consider increasing maxSize in IPFSClientConfig if this is expected.`
279
- );
280
- }
281
-
282
164
  chunks.push(chunk);
283
165
  }
284
166
 
285
167
  // Concatenate all chunks
168
+ const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
286
169
  const result = new Uint8Array(totalLength);
287
170
  let offset = 0;
288
171