@rhinestone/sdk 2.0.0-beta.9 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (615) hide show
  1. package/README.md +2 -2
  2. package/dist/src/accounts/adapter.d.ts +31 -0
  3. package/dist/src/accounts/adapter.d.ts.map +1 -0
  4. package/dist/src/accounts/adapters/eoa.d.ts +4 -0
  5. package/dist/src/accounts/adapters/eoa.d.ts.map +1 -0
  6. package/dist/src/accounts/adapters/eoa.js +45 -0
  7. package/dist/src/accounts/adapters/hca.d.ts +5 -0
  8. package/dist/src/accounts/adapters/hca.d.ts.map +1 -0
  9. package/dist/src/accounts/adapters/hca.js +121 -0
  10. package/dist/src/accounts/adapters/kernel.d.ts +9 -0
  11. package/dist/src/accounts/adapters/kernel.d.ts.map +1 -0
  12. package/dist/src/accounts/adapters/kernel.js +159 -0
  13. package/dist/src/accounts/adapters/nexus.d.ts +16 -0
  14. package/dist/src/accounts/adapters/nexus.d.ts.map +1 -0
  15. package/dist/src/accounts/adapters/nexus.js +212 -0
  16. package/dist/src/accounts/adapters/safe.d.ts +6 -0
  17. package/dist/src/accounts/adapters/safe.d.ts.map +1 -0
  18. package/dist/src/accounts/adapters/safe.js +194 -0
  19. package/dist/src/accounts/adapters/shared.d.ts +9 -0
  20. package/dist/src/accounts/adapters/shared.d.ts.map +1 -0
  21. package/dist/src/accounts/adapters/shared.js +62 -0
  22. package/dist/src/accounts/adapters/startale.d.ts +14 -0
  23. package/dist/src/accounts/adapters/startale.d.ts.map +1 -0
  24. package/dist/src/accounts/adapters/startale.js +165 -0
  25. package/dist/src/accounts/construction.d.ts +25 -0
  26. package/dist/src/accounts/construction.d.ts.map +1 -0
  27. package/dist/src/accounts/construction.js +34 -0
  28. package/dist/src/accounts/deployment.d.ts +12 -0
  29. package/dist/src/accounts/deployment.d.ts.map +1 -0
  30. package/dist/src/accounts/deployment.js +33 -0
  31. package/dist/src/accounts/erc7579-calls.d.ts +4 -0
  32. package/dist/src/accounts/erc7579-calls.d.ts.map +1 -0
  33. package/dist/src/accounts/erc7579-calls.js +57 -0
  34. package/dist/src/accounts/error.d.ts +3 -10
  35. package/dist/src/accounts/error.d.ts.map +1 -1
  36. package/dist/src/accounts/error.js +5 -11
  37. package/dist/src/accounts/legacy.d.ts +14 -0
  38. package/dist/src/accounts/legacy.d.ts.map +1 -0
  39. package/dist/src/accounts/legacy.js +40 -0
  40. package/dist/src/accounts/registry.d.ts +4 -0
  41. package/dist/src/accounts/registry.d.ts.map +1 -0
  42. package/dist/src/accounts/registry.js +22 -0
  43. package/dist/src/accounts/types.d.ts +131 -0
  44. package/dist/src/accounts/types.d.ts.map +1 -0
  45. package/dist/src/accounts/types.js +1 -0
  46. package/dist/src/accounts/wallet-account.d.ts +3 -0
  47. package/dist/src/accounts/wallet-account.d.ts.map +1 -0
  48. package/dist/src/accounts/wallet-account.js +12 -0
  49. package/dist/src/actions/deploy.d.ts +4 -0
  50. package/dist/src/actions/deploy.d.ts.map +1 -0
  51. package/dist/src/actions/deploy.js +8 -0
  52. package/dist/src/actions/ecdsa.d.ts +2 -2
  53. package/dist/src/actions/ecdsa.d.ts.map +1 -1
  54. package/dist/src/actions/ecdsa.js +12 -65
  55. package/dist/src/actions/index.d.ts +2 -16
  56. package/dist/src/actions/index.d.ts.map +1 -1
  57. package/dist/src/actions/index.js +3 -49
  58. package/dist/src/actions/mfa.d.ts +1 -1
  59. package/dist/src/actions/mfa.d.ts.map +1 -1
  60. package/dist/src/actions/mfa.js +30 -10
  61. package/dist/src/actions/modules.d.ts +4 -0
  62. package/dist/src/actions/modules.d.ts.map +1 -0
  63. package/dist/src/actions/modules.js +22 -0
  64. package/dist/src/actions/ownable.d.ts +6 -0
  65. package/dist/src/actions/ownable.d.ts.map +1 -0
  66. package/dist/src/actions/ownable.js +63 -0
  67. package/dist/src/actions/passkeys.d.ts +2 -2
  68. package/dist/src/actions/passkeys.d.ts.map +1 -1
  69. package/dist/src/actions/passkeys.js +23 -78
  70. package/dist/src/actions/recovery.d.ts +58 -24
  71. package/dist/src/actions/recovery.d.ts.map +1 -1
  72. package/dist/src/actions/recovery.js +107 -162
  73. package/dist/src/actions/runtime.d.ts +17 -0
  74. package/dist/src/actions/runtime.d.ts.map +1 -0
  75. package/dist/src/actions/runtime.js +182 -0
  76. package/dist/src/actions/smart-sessions.d.ts +30 -6
  77. package/dist/src/actions/smart-sessions.d.ts.map +1 -1
  78. package/dist/src/actions/smart-sessions.js +69 -18
  79. package/dist/src/actions/webauthn.d.ts +6 -0
  80. package/dist/src/actions/webauthn.d.ts.map +1 -0
  81. package/dist/src/actions/webauthn.js +67 -0
  82. package/dist/src/api/account.d.ts +265 -0
  83. package/dist/src/api/account.d.ts.map +1 -0
  84. package/dist/src/api/account.js +638 -0
  85. package/dist/src/api/accounts.d.ts +12 -0
  86. package/dist/src/api/accounts.d.ts.map +1 -0
  87. package/dist/src/api/accounts.js +17 -0
  88. package/dist/src/api/compose-types.d.ts +147 -0
  89. package/dist/src/api/compose-types.d.ts.map +1 -0
  90. package/dist/src/api/compose-types.js +1 -0
  91. package/dist/src/api/compose.d.ts +6 -0
  92. package/dist/src/api/compose.d.ts.map +1 -0
  93. package/dist/src/api/compose.js +772 -0
  94. package/dist/src/api/direct-signing.d.ts +27 -0
  95. package/dist/src/api/direct-signing.d.ts.map +1 -0
  96. package/dist/src/api/direct-signing.js +191 -0
  97. package/dist/src/api/project-mappers.d.ts +7 -0
  98. package/dist/src/api/project-mappers.d.ts.map +1 -0
  99. package/dist/src/api/project-mappers.js +23 -0
  100. package/dist/src/api/queries/app-fees.d.ts +4 -0
  101. package/dist/src/api/queries/app-fees.d.ts.map +1 -0
  102. package/dist/src/api/queries/app-fees.js +3 -0
  103. package/dist/src/api/queries/portfolio.d.ts +9 -0
  104. package/dist/src/api/queries/portfolio.d.ts.map +1 -0
  105. package/dist/src/api/queries/portfolio.js +28 -0
  106. package/dist/src/api/queries/session.d.ts +8 -0
  107. package/dist/src/api/queries/session.d.ts.map +1 -0
  108. package/dist/src/api/queries/session.js +15 -0
  109. package/dist/src/api/sdk.d.ts +80 -0
  110. package/dist/src/api/sdk.d.ts.map +1 -0
  111. package/dist/src/api/sdk.js +103 -0
  112. package/dist/src/api/signer-selection.d.ts +20 -0
  113. package/dist/src/api/signer-selection.d.ts.map +1 -0
  114. package/dist/src/api/signer-selection.js +159 -0
  115. package/dist/src/calls/normalize.d.ts +9 -0
  116. package/dist/src/calls/normalize.d.ts.map +1 -0
  117. package/dist/src/calls/normalize.js +17 -0
  118. package/dist/src/calls/resolve.d.ts +3 -0
  119. package/dist/src/calls/resolve.d.ts.map +1 -0
  120. package/dist/src/calls/resolve.js +15 -0
  121. package/dist/src/calls/types.d.ts +25 -0
  122. package/dist/src/calls/types.d.ts.map +1 -0
  123. package/dist/src/calls/types.js +1 -0
  124. package/dist/src/chains/caip2.d.ts +10 -0
  125. package/dist/src/chains/caip2.d.ts.map +1 -0
  126. package/dist/src/chains/caip2.js +85 -0
  127. package/dist/src/chains/catalog.d.ts +5 -0
  128. package/dist/src/chains/catalog.d.ts.map +1 -0
  129. package/dist/src/chains/catalog.js +41 -0
  130. package/dist/src/chains/errors.d.ts +15 -0
  131. package/dist/src/chains/errors.d.ts.map +1 -0
  132. package/dist/src/chains/errors.js +21 -0
  133. package/dist/src/{orchestrator/destinations.d.ts → chains/non-evm.d.ts} +9 -6
  134. package/dist/src/chains/non-evm.d.ts.map +1 -0
  135. package/dist/src/chains/non-evm.js +30 -0
  136. package/dist/src/chains/tokens.d.ts +4 -0
  137. package/dist/src/chains/tokens.d.ts.map +1 -0
  138. package/dist/src/chains/tokens.js +22 -0
  139. package/dist/src/chains/types.d.ts +25 -0
  140. package/dist/src/chains/types.d.ts.map +1 -0
  141. package/dist/src/chains/types.js +1 -0
  142. package/dist/src/clients/bundler/client.d.ts +10 -0
  143. package/dist/src/clients/bundler/client.d.ts.map +1 -0
  144. package/dist/src/clients/bundler/client.js +85 -0
  145. package/dist/src/clients/bundler/endpoints.d.ts +3 -0
  146. package/dist/src/clients/bundler/endpoints.d.ts.map +1 -0
  147. package/dist/src/clients/bundler/endpoints.js +18 -0
  148. package/dist/src/clients/bundler/port.d.ts +22 -0
  149. package/dist/src/clients/bundler/port.d.ts.map +1 -0
  150. package/dist/src/clients/bundler/port.js +1 -0
  151. package/dist/src/clients/json-rpc.d.ts +20 -0
  152. package/dist/src/clients/json-rpc.d.ts.map +1 -0
  153. package/dist/src/clients/json-rpc.js +56 -0
  154. package/dist/src/clients/orchestrator/auth.d.ts +7 -0
  155. package/dist/src/clients/orchestrator/auth.d.ts.map +1 -0
  156. package/dist/src/clients/orchestrator/auth.js +27 -0
  157. package/dist/src/clients/orchestrator/chain-catalog.d.ts +36 -0
  158. package/dist/src/clients/orchestrator/chain-catalog.d.ts.map +1 -0
  159. package/dist/src/clients/orchestrator/chain-catalog.js +67 -0
  160. package/dist/src/clients/orchestrator/client.d.ts +13 -0
  161. package/dist/src/clients/orchestrator/client.d.ts.map +1 -0
  162. package/dist/src/clients/orchestrator/client.js +97 -0
  163. package/dist/src/clients/orchestrator/errors.d.ts +238 -0
  164. package/dist/src/clients/orchestrator/errors.d.ts.map +1 -0
  165. package/dist/src/clients/orchestrator/errors.js +525 -0
  166. package/dist/src/clients/orchestrator/fetch.d.ts +7 -0
  167. package/dist/src/clients/orchestrator/fetch.d.ts.map +1 -0
  168. package/dist/src/clients/orchestrator/fetch.js +37 -0
  169. package/dist/src/clients/orchestrator/mappers.d.ts +9 -0
  170. package/dist/src/clients/orchestrator/mappers.d.ts.map +1 -0
  171. package/dist/src/clients/orchestrator/mappers.js +198 -0
  172. package/dist/src/clients/orchestrator/port.d.ts +26 -0
  173. package/dist/src/clients/orchestrator/port.d.ts.map +1 -0
  174. package/dist/src/clients/orchestrator/port.js +1 -0
  175. package/dist/src/{orchestrator/types.d.ts → clients/orchestrator/public.d.ts} +113 -43
  176. package/dist/src/clients/orchestrator/public.d.ts.map +1 -0
  177. package/dist/src/clients/orchestrator/public.js +14 -0
  178. package/dist/src/clients/orchestrator/types.d.ts +144 -0
  179. package/dist/src/clients/orchestrator/types.d.ts.map +1 -0
  180. package/dist/src/clients/orchestrator/types.js +1 -0
  181. package/dist/src/clients/orchestrator/wire.d.ts +19 -0
  182. package/dist/src/clients/orchestrator/wire.d.ts.map +1 -0
  183. package/dist/src/clients/orchestrator/wire.gen.d.ts +6463 -0
  184. package/dist/src/clients/orchestrator/wire.gen.d.ts.map +1 -0
  185. package/dist/src/clients/orchestrator/wire.gen.js +1 -0
  186. package/dist/src/clients/orchestrator/wire.js +1 -0
  187. package/dist/src/clients/paymaster/client.d.ts +8 -0
  188. package/dist/src/clients/paymaster/client.d.ts.map +1 -0
  189. package/dist/src/clients/paymaster/client.js +38 -0
  190. package/dist/src/clients/paymaster/endpoints.d.ts +3 -0
  191. package/dist/src/clients/paymaster/endpoints.d.ts.map +1 -0
  192. package/dist/src/clients/paymaster/endpoints.js +16 -0
  193. package/dist/src/clients/paymaster/port.d.ts +17 -0
  194. package/dist/src/clients/paymaster/port.d.ts.map +1 -0
  195. package/dist/src/clients/paymaster/port.js +1 -0
  196. package/dist/src/clients/rpc/client.d.ts +6 -0
  197. package/dist/src/clients/rpc/client.d.ts.map +1 -0
  198. package/dist/src/clients/rpc/client.js +66 -0
  199. package/dist/src/clients/rpc/compatibility.d.ts +12 -0
  200. package/dist/src/clients/rpc/compatibility.d.ts.map +1 -0
  201. package/dist/src/clients/rpc/compatibility.js +16 -0
  202. package/dist/src/clients/rpc/port.d.ts +13 -0
  203. package/dist/src/clients/rpc/port.d.ts.map +1 -0
  204. package/dist/src/clients/rpc/port.js +1 -0
  205. package/dist/src/clients/rpc/providers.d.ts +3 -0
  206. package/dist/src/clients/rpc/providers.d.ts.map +1 -0
  207. package/dist/src/clients/rpc/providers.js +8 -0
  208. package/dist/src/clients/rpc/transport.d.ts +4 -0
  209. package/dist/src/clients/rpc/transport.d.ts.map +1 -0
  210. package/dist/src/clients/rpc/transport.js +5 -0
  211. package/dist/src/clients/rpc/types.d.ts +23 -0
  212. package/dist/src/clients/rpc/types.d.ts.map +1 -0
  213. package/dist/src/clients/rpc/types.js +1 -0
  214. package/dist/src/config/account-runtime.d.ts +7 -0
  215. package/dist/src/config/account-runtime.d.ts.map +1 -0
  216. package/dist/src/config/account-runtime.js +36 -0
  217. package/dist/src/config/account.d.ts +767 -0
  218. package/dist/src/config/account.d.ts.map +1 -0
  219. package/dist/src/config/account.js +10 -0
  220. package/dist/src/config/defaults.d.ts +14 -0
  221. package/dist/src/config/defaults.d.ts.map +1 -0
  222. package/dist/src/config/defaults.js +26 -0
  223. package/dist/src/config/input.d.ts +59 -0
  224. package/dist/src/config/input.d.ts.map +1 -0
  225. package/dist/src/config/input.js +1 -0
  226. package/dist/src/config/legacy.d.ts +22 -0
  227. package/dist/src/config/legacy.d.ts.map +1 -0
  228. package/dist/src/config/legacy.js +23 -0
  229. package/dist/src/config/resolve.d.ts +13 -0
  230. package/dist/src/config/resolve.d.ts.map +1 -0
  231. package/dist/src/config/resolve.js +200 -0
  232. package/dist/src/config/resolved.d.ts +77 -0
  233. package/dist/src/config/resolved.d.ts.map +1 -0
  234. package/dist/src/config/resolved.js +1 -0
  235. package/dist/src/config/validate.d.ts +3 -0
  236. package/dist/src/config/validate.d.ts.map +1 -0
  237. package/dist/src/config/validate.js +6 -0
  238. package/dist/src/{execution/error.d.ts → errors/execution.d.ts} +47 -9
  239. package/dist/src/errors/execution.d.ts.map +1 -0
  240. package/dist/src/errors/execution.js +131 -0
  241. package/dist/src/errors/index.d.ts +6 -4
  242. package/dist/src/errors/index.d.ts.map +1 -1
  243. package/dist/src/errors/index.js +7 -6
  244. package/dist/src/index.d.ts +14 -84
  245. package/dist/src/index.d.ts.map +1 -1
  246. package/dist/src/index.js +9 -293
  247. package/dist/src/jwt-server/jcs.d.ts +1 -1
  248. package/dist/src/jwt-server/jcs.js +4 -2
  249. package/dist/src/modules/erc7579-abi.d.ts +4 -0
  250. package/dist/src/modules/erc7579-abi.d.ts.map +1 -0
  251. package/dist/src/modules/erc7579-abi.js +12 -0
  252. package/dist/src/modules/intent-executor.d.ts +6 -0
  253. package/dist/src/modules/intent-executor.d.ts.map +1 -0
  254. package/dist/src/modules/intent-executor.js +13 -0
  255. package/dist/src/modules/legacy-core.d.ts +29 -0
  256. package/dist/src/modules/legacy-core.d.ts.map +1 -0
  257. package/dist/src/modules/legacy-core.js +80 -0
  258. package/dist/src/modules/normalize.d.ts +4 -0
  259. package/dist/src/modules/normalize.d.ts.map +1 -0
  260. package/dist/src/modules/normalize.js +15 -0
  261. package/dist/src/modules/plan.d.ts +16 -0
  262. package/dist/src/modules/plan.d.ts.map +1 -0
  263. package/dist/src/modules/plan.js +51 -0
  264. package/dist/src/modules/read-core.d.ts +62 -0
  265. package/dist/src/modules/read-core.d.ts.map +1 -0
  266. package/dist/src/modules/read-core.js +206 -0
  267. package/dist/src/modules/types.d.ts +46 -0
  268. package/dist/src/modules/types.d.ts.map +1 -0
  269. package/dist/src/modules/types.js +1 -0
  270. package/dist/src/modules/validators/capabilities.d.ts +4 -0
  271. package/dist/src/modules/validators/capabilities.d.ts.map +1 -0
  272. package/dist/src/modules/validators/capabilities.js +58 -0
  273. package/dist/src/modules/validators/contribution.d.ts +4 -0
  274. package/dist/src/modules/validators/contribution.d.ts.map +1 -0
  275. package/dist/src/modules/validators/contribution.js +64 -0
  276. package/dist/src/modules/validators/definition.d.ts +3 -0
  277. package/dist/src/modules/validators/definition.d.ts.map +1 -0
  278. package/dist/src/modules/validators/definition.js +68 -0
  279. package/dist/src/modules/validators/ens.d.ts +5 -0
  280. package/dist/src/modules/validators/ens.d.ts.map +1 -0
  281. package/dist/src/modules/validators/ens.js +34 -0
  282. package/dist/src/modules/validators/k1.d.ts +2 -0
  283. package/dist/src/modules/validators/k1.d.ts.map +1 -0
  284. package/dist/src/modules/validators/k1.js +1 -0
  285. package/dist/src/modules/validators/multi-factor.d.ts +18 -0
  286. package/dist/src/modules/validators/multi-factor.d.ts.map +1 -0
  287. package/dist/src/modules/validators/multi-factor.js +79 -0
  288. package/dist/src/modules/validators/ownable.d.ts +26 -0
  289. package/dist/src/modules/validators/ownable.d.ts.map +1 -0
  290. package/dist/src/modules/validators/ownable.js +84 -0
  291. package/dist/src/modules/validators/permissions.d.ts +2 -1
  292. package/dist/src/modules/validators/permissions.d.ts.map +1 -1
  293. package/dist/src/modules/validators/permissions.js +192 -18
  294. package/dist/src/modules/validators/policies/claim/arbiters.d.ts +19 -0
  295. package/dist/src/modules/validators/policies/claim/arbiters.d.ts.map +1 -0
  296. package/dist/src/modules/validators/policies/claim/arbiters.js +82 -0
  297. package/dist/src/modules/validators/resolve.d.ts +5 -0
  298. package/dist/src/modules/validators/resolve.d.ts.map +1 -0
  299. package/dist/src/modules/validators/resolve.js +22 -0
  300. package/dist/src/modules/validators/signer-id.d.ts +5 -0
  301. package/dist/src/modules/validators/signer-id.d.ts.map +1 -0
  302. package/dist/src/modules/validators/signer-id.js +8 -0
  303. package/dist/src/modules/validators/smart-session-signature-types.d.ts +35 -0
  304. package/dist/src/modules/validators/smart-session-signature-types.d.ts.map +1 -0
  305. package/dist/src/modules/validators/smart-session-signature-types.js +1 -0
  306. package/dist/src/modules/validators/smart-sessions/authorization.d.ts +99 -0
  307. package/dist/src/modules/validators/smart-sessions/authorization.d.ts.map +1 -0
  308. package/dist/src/modules/validators/smart-sessions/authorization.js +101 -0
  309. package/dist/src/modules/validators/smart-sessions/calls.d.ts +19 -0
  310. package/dist/src/modules/validators/smart-sessions/calls.d.ts.map +1 -0
  311. package/dist/src/modules/validators/smart-sessions/calls.js +85 -0
  312. package/dist/src/modules/validators/smart-sessions/cross-chain-permits.d.ts +4 -0
  313. package/dist/src/modules/validators/smart-sessions/cross-chain-permits.d.ts.map +1 -0
  314. package/dist/src/modules/validators/smart-sessions/cross-chain-permits.js +77 -0
  315. package/dist/src/modules/validators/smart-sessions/digest.d.ts +5 -0
  316. package/dist/src/modules/validators/smart-sessions/digest.d.ts.map +1 -0
  317. package/dist/src/modules/validators/smart-sessions/digest.js +30 -0
  318. package/dist/src/modules/validators/smart-sessions/mock-signature.d.ts +10 -0
  319. package/dist/src/modules/validators/smart-sessions/mock-signature.d.ts.map +1 -0
  320. package/dist/src/modules/validators/smart-sessions/mock-signature.js +31 -0
  321. package/dist/src/modules/validators/smart-sessions/module.d.ts +11 -0
  322. package/dist/src/modules/validators/smart-sessions/module.d.ts.map +1 -0
  323. package/dist/src/modules/validators/smart-sessions/module.js +18 -0
  324. package/dist/src/modules/validators/smart-sessions/policies/addresses.d.ts +23 -0
  325. package/dist/src/modules/validators/smart-sessions/policies/addresses.d.ts.map +1 -0
  326. package/dist/src/modules/validators/smart-sessions/policies/addresses.js +29 -0
  327. package/dist/src/modules/validators/smart-sessions/policies/claim.d.ts +10 -0
  328. package/dist/src/modules/validators/smart-sessions/policies/claim.d.ts.map +1 -0
  329. package/dist/src/modules/validators/smart-sessions/policies/claim.js +106 -0
  330. package/dist/src/modules/validators/smart-sessions/policies/encode.d.ts +4 -0
  331. package/dist/src/modules/validators/smart-sessions/policies/encode.d.ts.map +1 -0
  332. package/dist/src/modules/validators/smart-sessions/policies/encode.js +197 -0
  333. package/dist/src/modules/validators/smart-sessions/resolve.d.ts +16 -0
  334. package/dist/src/modules/validators/smart-sessions/resolve.d.ts.map +1 -0
  335. package/dist/src/modules/validators/smart-sessions/resolve.js +120 -0
  336. package/dist/src/modules/validators/smart-sessions/signature.d.ts +14 -0
  337. package/dist/src/modules/validators/smart-sessions/signature.d.ts.map +1 -0
  338. package/dist/src/modules/validators/smart-sessions/signature.js +167 -0
  339. package/dist/src/modules/validators/smart-sessions/state.d.ts +19 -0
  340. package/dist/src/modules/validators/smart-sessions/state.d.ts.map +1 -0
  341. package/dist/src/modules/validators/smart-sessions/state.js +42 -0
  342. package/dist/src/modules/validators/smart-sessions/types.d.ts +227 -0
  343. package/dist/src/modules/validators/smart-sessions/types.d.ts.map +1 -0
  344. package/dist/src/modules/validators/smart-sessions/types.js +1 -0
  345. package/dist/src/modules/validators/social-recovery.d.ts +16 -0
  346. package/dist/src/modules/validators/social-recovery.d.ts.map +1 -0
  347. package/dist/src/modules/validators/social-recovery.js +17 -0
  348. package/dist/src/modules/validators/types.d.ts +143 -0
  349. package/dist/src/modules/validators/types.d.ts.map +1 -0
  350. package/dist/src/modules/validators/types.js +1 -0
  351. package/dist/src/modules/validators/webauthn.d.ts +54 -0
  352. package/dist/src/modules/validators/webauthn.d.ts.map +1 -0
  353. package/dist/src/modules/validators/webauthn.js +159 -0
  354. package/dist/src/signing/context.d.ts +25 -0
  355. package/dist/src/signing/context.d.ts.map +1 -0
  356. package/dist/src/signing/context.js +163 -0
  357. package/dist/src/signing/contribution.d.ts +13 -0
  358. package/dist/src/signing/contribution.d.ts.map +1 -0
  359. package/dist/src/signing/contribution.js +83 -0
  360. package/dist/src/signing/eip7702.d.ts +41 -0
  361. package/dist/src/signing/eip7702.d.ts.map +1 -0
  362. package/dist/src/signing/eip7702.js +215 -0
  363. package/dist/src/signing/error.d.ts +27 -0
  364. package/dist/src/signing/error.d.ts.map +1 -0
  365. package/dist/src/signing/error.js +25 -0
  366. package/dist/src/signing/execute.d.ts +17 -0
  367. package/dist/src/signing/execute.d.ts.map +1 -0
  368. package/dist/src/signing/execute.js +138 -0
  369. package/dist/src/signing/intent-plans/assemble.d.ts +15 -0
  370. package/dist/src/signing/intent-plans/assemble.d.ts.map +1 -0
  371. package/dist/src/signing/intent-plans/assemble.js +96 -0
  372. package/dist/src/signing/intent-plans/independent.d.ts +48 -0
  373. package/dist/src/signing/intent-plans/independent.d.ts.map +1 -0
  374. package/dist/src/signing/intent-plans/independent.js +150 -0
  375. package/dist/src/signing/intent-plans/plan.d.ts +14 -0
  376. package/dist/src/signing/intent-plans/plan.d.ts.map +1 -0
  377. package/dist/src/signing/intent-plans/plan.js +187 -0
  378. package/dist/src/signing/intent-plans/types.d.ts +63 -0
  379. package/dist/src/signing/intent-plans/types.d.ts.map +1 -0
  380. package/dist/src/signing/intent-plans/types.js +1 -0
  381. package/dist/src/signing/message.d.ts +28 -0
  382. package/dist/src/signing/message.d.ts.map +1 -0
  383. package/dist/src/signing/message.js +90 -0
  384. package/dist/src/signing/passkeys.d.ts +28 -0
  385. package/dist/src/signing/passkeys.d.ts.map +1 -0
  386. package/dist/src/signing/passkeys.js +17 -0
  387. package/dist/src/signing/plan.d.ts +35 -0
  388. package/dist/src/signing/plan.d.ts.map +1 -0
  389. package/dist/src/signing/plan.js +377 -0
  390. package/dist/src/signing/protocols/erc6492.d.ts +11 -0
  391. package/dist/src/signing/protocols/erc6492.d.ts.map +1 -0
  392. package/dist/src/signing/protocols/erc6492.js +24 -0
  393. package/dist/src/signing/protocols/erc7739.d.ts +17 -0
  394. package/dist/src/signing/protocols/erc7739.d.ts.map +1 -0
  395. package/dist/src/signing/protocols/erc7739.js +84 -0
  396. package/dist/src/signing/session-enable.d.ts +35 -0
  397. package/dist/src/signing/session-enable.d.ts.map +1 -0
  398. package/dist/src/signing/session-enable.js +62 -0
  399. package/dist/src/signing/signers/compatibility.d.ts +4 -0
  400. package/dist/src/signing/signers/compatibility.d.ts.map +1 -0
  401. package/dist/src/signing/signers/compatibility.js +51 -0
  402. package/dist/src/signing/signers/ecdsa.d.ts +14 -0
  403. package/dist/src/signing/signers/ecdsa.d.ts.map +1 -0
  404. package/dist/src/signing/signers/ecdsa.js +54 -0
  405. package/dist/src/signing/signers/registry.d.ts +7 -0
  406. package/dist/src/signing/signers/registry.d.ts.map +1 -0
  407. package/dist/src/signing/signers/registry.js +33 -0
  408. package/dist/src/signing/signers/types.d.ts +16 -0
  409. package/dist/src/signing/signers/types.d.ts.map +1 -0
  410. package/dist/src/signing/signers/types.js +1 -0
  411. package/dist/src/signing/signers/wallet-chain.d.ts +9 -0
  412. package/dist/src/signing/signers/wallet-chain.d.ts.map +1 -0
  413. package/dist/src/signing/signers/wallet-chain.js +15 -0
  414. package/dist/src/signing/signers/webauthn.d.ts +11 -0
  415. package/dist/src/signing/signers/webauthn.d.ts.map +1 -0
  416. package/dist/src/signing/signers/webauthn.js +14 -0
  417. package/dist/src/signing/typed-data.d.ts +39 -0
  418. package/dist/src/signing/typed-data.d.ts.map +1 -0
  419. package/dist/src/signing/typed-data.js +135 -0
  420. package/dist/src/signing/types.d.ts +346 -0
  421. package/dist/src/signing/types.d.ts.map +1 -0
  422. package/dist/src/signing/types.js +1 -0
  423. package/dist/src/signing/user-operation.d.ts +23 -0
  424. package/dist/src/signing/user-operation.d.ts.map +1 -0
  425. package/dist/src/signing/user-operation.js +61 -0
  426. package/dist/src/smart-sessions/index.d.ts +16 -0
  427. package/dist/src/smart-sessions/index.d.ts.map +1 -0
  428. package/dist/src/smart-sessions/index.js +45 -0
  429. package/dist/src/transactions/intents/account.d.ts +15 -0
  430. package/dist/src/transactions/intents/account.d.ts.map +1 -0
  431. package/dist/src/transactions/intents/account.js +48 -0
  432. package/dist/src/transactions/intents/compatibility.d.ts +4 -0
  433. package/dist/src/transactions/intents/compatibility.d.ts.map +1 -0
  434. package/dist/src/transactions/intents/compatibility.js +19 -0
  435. package/dist/src/transactions/intents/normalize.d.ts +5 -0
  436. package/dist/src/transactions/intents/normalize.d.ts.map +1 -0
  437. package/dist/src/transactions/intents/normalize.js +48 -0
  438. package/dist/src/transactions/intents/prepare.d.ts +7 -0
  439. package/dist/src/transactions/intents/prepare.d.ts.map +1 -0
  440. package/dist/src/transactions/intents/prepare.js +249 -0
  441. package/dist/src/transactions/intents/quotes.d.ts +3 -0
  442. package/dist/src/transactions/intents/quotes.d.ts.map +1 -0
  443. package/dist/src/transactions/intents/quotes.js +11 -0
  444. package/dist/src/transactions/intents/request.d.ts +11 -0
  445. package/dist/src/transactions/intents/request.d.ts.map +1 -0
  446. package/dist/src/transactions/intents/request.js +55 -0
  447. package/dist/src/transactions/intents/send.d.ts +3 -0
  448. package/dist/src/transactions/intents/send.d.ts.map +1 -0
  449. package/dist/src/transactions/intents/send.js +22 -0
  450. package/dist/src/transactions/intents/session-signing.d.ts +7 -0
  451. package/dist/src/transactions/intents/session-signing.d.ts.map +1 -0
  452. package/dist/src/transactions/intents/session-signing.js +363 -0
  453. package/dist/src/transactions/intents/sessions.d.ts +17 -0
  454. package/dist/src/transactions/intents/sessions.d.ts.map +1 -0
  455. package/dist/src/transactions/intents/sessions.js +85 -0
  456. package/dist/src/transactions/intents/sign-transaction.d.ts +10 -0
  457. package/dist/src/transactions/intents/sign-transaction.d.ts.map +1 -0
  458. package/dist/src/transactions/intents/sign-transaction.js +386 -0
  459. package/dist/src/transactions/intents/split.d.ts +13 -0
  460. package/dist/src/transactions/intents/split.d.ts.map +1 -0
  461. package/dist/src/transactions/intents/split.js +3 -0
  462. package/dist/src/transactions/intents/status-policy.d.ts +13 -0
  463. package/dist/src/transactions/intents/status-policy.d.ts.map +1 -0
  464. package/dist/src/transactions/intents/status-policy.js +39 -0
  465. package/dist/src/transactions/intents/status.d.ts +4 -0
  466. package/dist/src/transactions/intents/status.d.ts.map +1 -0
  467. package/dist/src/transactions/intents/status.js +50 -0
  468. package/dist/src/transactions/intents/submit.d.ts +3 -0
  469. package/dist/src/transactions/intents/submit.d.ts.map +1 -0
  470. package/dist/src/transactions/intents/submit.js +32 -0
  471. package/dist/src/transactions/intents/types.d.ts +136 -0
  472. package/dist/src/transactions/intents/types.d.ts.map +1 -0
  473. package/dist/src/transactions/intents/types.js +1 -0
  474. package/dist/src/transactions/user-operations/hash.d.ts +5 -0
  475. package/dist/src/transactions/user-operations/hash.d.ts.map +1 -0
  476. package/dist/src/transactions/user-operations/hash.js +9 -0
  477. package/dist/src/transactions/user-operations/nonce.d.ts +18 -0
  478. package/dist/src/transactions/user-operations/nonce.d.ts.map +1 -0
  479. package/dist/src/transactions/user-operations/nonce.js +43 -0
  480. package/dist/src/transactions/user-operations/prepare.d.ts +12 -0
  481. package/dist/src/transactions/user-operations/prepare.d.ts.map +1 -0
  482. package/dist/src/transactions/user-operations/prepare.js +136 -0
  483. package/dist/src/transactions/user-operations/reconstruct.d.ts +28 -0
  484. package/dist/src/transactions/user-operations/reconstruct.d.ts.map +1 -0
  485. package/dist/src/transactions/user-operations/reconstruct.js +52 -0
  486. package/dist/src/transactions/user-operations/send.d.ts +3 -0
  487. package/dist/src/transactions/user-operations/send.d.ts.map +1 -0
  488. package/dist/src/transactions/user-operations/send.js +8 -0
  489. package/dist/src/transactions/user-operations/sign.d.ts +3 -0
  490. package/dist/src/transactions/user-operations/sign.d.ts.map +1 -0
  491. package/dist/src/transactions/user-operations/sign.js +14 -0
  492. package/dist/src/transactions/user-operations/status.d.ts +4 -0
  493. package/dist/src/transactions/user-operations/status.d.ts.map +1 -0
  494. package/dist/src/transactions/user-operations/status.js +37 -0
  495. package/dist/src/transactions/user-operations/submit.d.ts +3 -0
  496. package/dist/src/transactions/user-operations/submit.d.ts.map +1 -0
  497. package/dist/src/transactions/user-operations/submit.js +8 -0
  498. package/dist/src/transactions/user-operations/types.d.ts +68 -0
  499. package/dist/src/transactions/user-operations/types.d.ts.map +1 -0
  500. package/dist/src/transactions/user-operations/types.js +1 -0
  501. package/dist/src/transactions/user-operations/validator-account.d.ts +5 -0
  502. package/dist/src/transactions/user-operations/validator-account.d.ts.map +1 -0
  503. package/dist/src/transactions/user-operations/validator-account.js +26 -0
  504. package/dist/src/utils/index.d.ts +68 -4
  505. package/dist/src/utils/index.d.ts.map +1 -1
  506. package/dist/src/utils/index.js +113 -51
  507. package/package.json +10 -11
  508. package/dist/src/accounts/index.d.ts +0 -51
  509. package/dist/src/accounts/index.d.ts.map +0 -1
  510. package/dist/src/accounts/index.js +0 -589
  511. package/dist/src/accounts/json-rpc/index.d.ts +0 -5
  512. package/dist/src/accounts/json-rpc/index.d.ts.map +0 -1
  513. package/dist/src/accounts/json-rpc/index.js +0 -19
  514. package/dist/src/accounts/json-rpc/providers.d.ts +0 -5
  515. package/dist/src/accounts/json-rpc/providers.d.ts.map +0 -1
  516. package/dist/src/accounts/json-rpc/providers.js +0 -16
  517. package/dist/src/accounts/kernel.d.ts +0 -27
  518. package/dist/src/accounts/kernel.d.ts.map +0 -1
  519. package/dist/src/accounts/kernel.js +0 -272
  520. package/dist/src/accounts/nexus.d.ts +0 -33
  521. package/dist/src/accounts/nexus.d.ts.map +0 -1
  522. package/dist/src/accounts/nexus.js +0 -444
  523. package/dist/src/accounts/safe.d.ts +0 -33
  524. package/dist/src/accounts/safe.d.ts.map +0 -1
  525. package/dist/src/accounts/safe.js +0 -343
  526. package/dist/src/accounts/signing/common.d.ts +0 -32
  527. package/dist/src/accounts/signing/common.d.ts.map +0 -1
  528. package/dist/src/accounts/signing/common.js +0 -184
  529. package/dist/src/accounts/signing/message.d.ts +0 -7
  530. package/dist/src/accounts/signing/message.d.ts.map +0 -1
  531. package/dist/src/accounts/signing/message.js +0 -45
  532. package/dist/src/accounts/signing/passkeys.d.ts +0 -36
  533. package/dist/src/accounts/signing/passkeys.d.ts.map +0 -1
  534. package/dist/src/accounts/signing/passkeys.js +0 -119
  535. package/dist/src/accounts/signing/typedData.d.ts +0 -5
  536. package/dist/src/accounts/signing/typedData.d.ts.map +0 -1
  537. package/dist/src/accounts/signing/typedData.js +0 -33
  538. package/dist/src/accounts/startale.d.ts +0 -26
  539. package/dist/src/accounts/startale.d.ts.map +0 -1
  540. package/dist/src/accounts/startale.js +0 -191
  541. package/dist/src/accounts/utils.d.ts +0 -33
  542. package/dist/src/accounts/utils.d.ts.map +0 -1
  543. package/dist/src/accounts/utils.js +0 -202
  544. package/dist/src/auth/provider.d.ts +0 -7
  545. package/dist/src/auth/provider.d.ts.map +0 -1
  546. package/dist/src/auth/provider.js +0 -38
  547. package/dist/src/execution/compact.d.ts +0 -5
  548. package/dist/src/execution/compact.d.ts.map +0 -1
  549. package/dist/src/execution/compact.js +0 -4
  550. package/dist/src/execution/error.d.ts.map +0 -1
  551. package/dist/src/execution/error.js +0 -85
  552. package/dist/src/execution/index.d.ts +0 -42
  553. package/dist/src/execution/index.d.ts.map +0 -1
  554. package/dist/src/execution/index.js +0 -202
  555. package/dist/src/execution/utils.d.ts +0 -127
  556. package/dist/src/execution/utils.d.ts.map +0 -1
  557. package/dist/src/execution/utils.js +0 -1116
  558. package/dist/src/modules/abi/smart-sessions.d.ts +0 -104
  559. package/dist/src/modules/abi/smart-sessions.d.ts.map +0 -1
  560. package/dist/src/modules/abi/smart-sessions.js +0 -128
  561. package/dist/src/modules/chain-abstraction.d.ts +0 -5
  562. package/dist/src/modules/chain-abstraction.d.ts.map +0 -1
  563. package/dist/src/modules/chain-abstraction.js +0 -3
  564. package/dist/src/modules/common.d.ts +0 -30
  565. package/dist/src/modules/common.d.ts.map +0 -1
  566. package/dist/src/modules/common.js +0 -30
  567. package/dist/src/modules/index.d.ts +0 -11
  568. package/dist/src/modules/index.d.ts.map +0 -1
  569. package/dist/src/modules/index.js +0 -90
  570. package/dist/src/modules/legacy.d.ts +0 -10
  571. package/dist/src/modules/legacy.d.ts.map +0 -1
  572. package/dist/src/modules/legacy.js +0 -62
  573. package/dist/src/modules/read.d.ts +0 -10
  574. package/dist/src/modules/read.d.ts.map +0 -1
  575. package/dist/src/modules/read.js +0 -171
  576. package/dist/src/modules/validators/core.d.ts +0 -31
  577. package/dist/src/modules/validators/core.d.ts.map +0 -1
  578. package/dist/src/modules/validators/core.js +0 -266
  579. package/dist/src/modules/validators/index.d.ts +0 -4
  580. package/dist/src/modules/validators/index.d.ts.map +0 -1
  581. package/dist/src/modules/validators/index.js +0 -3
  582. package/dist/src/modules/validators/smart-sessions.d.ts +0 -196
  583. package/dist/src/modules/validators/smart-sessions.d.ts.map +0 -1
  584. package/dist/src/modules/validators/smart-sessions.js +0 -772
  585. package/dist/src/orchestrator/caip2.d.ts +0 -13
  586. package/dist/src/orchestrator/caip2.d.ts.map +0 -1
  587. package/dist/src/orchestrator/caip2.js +0 -52
  588. package/dist/src/orchestrator/client.d.ts +0 -29
  589. package/dist/src/orchestrator/client.d.ts.map +0 -1
  590. package/dist/src/orchestrator/client.js +0 -293
  591. package/dist/src/orchestrator/consts.d.ts +0 -6
  592. package/dist/src/orchestrator/consts.d.ts.map +0 -1
  593. package/dist/src/orchestrator/consts.js +0 -5
  594. package/dist/src/orchestrator/destinations.d.ts.map +0 -1
  595. package/dist/src/orchestrator/destinations.js +0 -36
  596. package/dist/src/orchestrator/error.d.ts +0 -97
  597. package/dist/src/orchestrator/error.d.ts.map +0 -1
  598. package/dist/src/orchestrator/error.js +0 -173
  599. package/dist/src/orchestrator/index.d.ts +0 -12
  600. package/dist/src/orchestrator/index.d.ts.map +0 -1
  601. package/dist/src/orchestrator/index.js +0 -10
  602. package/dist/src/orchestrator/registry.d.ts +0 -17
  603. package/dist/src/orchestrator/registry.d.ts.map +0 -1
  604. package/dist/src/orchestrator/registry.js +0 -100
  605. package/dist/src/orchestrator/types.d.ts.map +0 -1
  606. package/dist/src/orchestrator/types.js +0 -15
  607. package/dist/src/orchestrator/utils.d.ts +0 -3
  608. package/dist/src/orchestrator/utils.d.ts.map +0 -1
  609. package/dist/src/orchestrator/utils.js +0 -22
  610. package/dist/src/types.d.ts +0 -466
  611. package/dist/src/types.d.ts.map +0 -1
  612. package/dist/src/utils/walletClient.d.ts +0 -34
  613. package/dist/src/utils/walletClient.d.ts.map +0 -1
  614. package/dist/src/utils/walletClient.js +0 -117
  615. /package/dist/src/{types.js → accounts/adapter.js} +0 -0
@@ -1,4 +1,4 @@
1
- import { isAddress, isHex, size, toFunctionSelector, } from 'viem';
1
+ import { isAddress, isHex, padHex, size, toFunctionSelector, } from 'viem';
2
2
  function isStaticAbiType(type) {
3
3
  if (type === 'address' || type === 'bool')
4
4
  return true;
@@ -33,12 +33,53 @@ function toReferenceValue(value, abiType) {
33
33
  if (typeof value === 'string' &&
34
34
  isHex(value) &&
35
35
  size(value) === expectedSize) {
36
- return value;
36
+ // Solidity calldata encodes bytesN (N<32) left-aligned + right-padded
37
+ // inside its 32-byte word, whereas address/uint*/bool are right-aligned
38
+ // + left-padded. Downstream `encodeActionParamRule` unconditionally
39
+ // left-pads with `padHex`, which is correct for the right-aligned types
40
+ // but wrong for bytesN. Pre-encode here to the full 32-byte hex with
41
+ // the correct alignment so the policy's bytes32 == bytes32 comparison
42
+ // matches what's actually in calldata.
43
+ return padHex(value, { size: 32, dir: 'right' });
37
44
  }
38
45
  throw new Error(`Expected ${expectedSize}-byte hex string for ${abiType}`);
39
46
  }
40
47
  throw new Error(`Unsupported ABI type: ${abiType}`);
41
48
  }
49
+ // Right-fold an array of leaves into a right-leaning OR chain:
50
+ // [a, b, c] → OR(a, OR(b, c))
51
+ // Right-leaning is fine because ArgPolicy evaluates with short-circuit; any
52
+ // shape that uses every leaf and respects post-order produces the same result.
53
+ function orChain(leaves) {
54
+ let acc = leaves[leaves.length - 1];
55
+ for (let i = leaves.length - 2; i >= 0; i--) {
56
+ acc = { type: 'or', left: leaves[i], right: acc };
57
+ }
58
+ return acc;
59
+ }
60
+ function andChain(leaves) {
61
+ let acc = leaves[leaves.length - 1];
62
+ for (let i = leaves.length - 2; i >= 0; i--) {
63
+ acc = { type: 'and', left: leaves[i], right: acc };
64
+ }
65
+ return acc;
66
+ }
67
+ // On-chain ERC20SpendingLimitPolicy._isTokenTransferOrApprove matches by
68
+ // 4-byte selector, accepting only these four. Selector-gating here keeps the
69
+ // SDK's accepted set congruent with the contract's — a same-shaped function
70
+ // like `mint(address,uint256)` would otherwise pass argument-type checks and
71
+ // fail every call on-chain.
72
+ const ERC20_SPENDING_LIMIT_SELECTORS = new Set([
73
+ '0x095ea7b3', // approve(address,uint256)
74
+ '0x39509351', // increaseAllowance(address,uint256)
75
+ '0xa9059cbb', // transfer(address,uint256)
76
+ '0x23b872dd', // transferFrom(address,address,uint256)
77
+ ]);
78
+ // Year 2100 in ms — well within uint128 after the encoder's ms→s conversion.
79
+ // Used as the one-sided default for `validUntil` when only `validAfter` is set.
80
+ // Exported so the cross-chain permit expansion (smart-sessions.ts) applies the
81
+ // same always-passing upper bound instead of defaulting to 0 (already expired).
82
+ export const FAR_FUTURE_MS = 4_102_444_800_000;
42
83
  function resolvePermission(permission) {
43
84
  const { abi, address, functions } = permission;
44
85
  const actions = [];
@@ -58,11 +99,57 @@ function resolvePermission(permission) {
58
99
  }
59
100
  const abiEntry = abiEntries[0];
60
101
  const selector = toFunctionSelector(abiEntry);
61
- const policies = config.policies ? [...config.policies] : [];
62
- const params = config.params ?? {};
63
- const paramEntries = Object.entries(params).filter(([, v]) => v !== undefined);
102
+ if (Object.hasOwn(config, 'policies')) {
103
+ throw new Error(`Function "${fnName}": \`policies\` was removed from permission configs. ` +
104
+ 'Use params, maxUses, validUntil/validAfter, valueLimit, or spendingLimit instead.');
105
+ }
106
+ const policies = [];
107
+ // --- Sugar field expansion -----------------------------------------------
108
+ if (config.maxUses !== undefined) {
109
+ policies.push({ type: 'usage-limit', limit: config.maxUses });
110
+ }
111
+ if (config.validUntil !== undefined || config.validAfter !== undefined) {
112
+ const validUntil = config.validUntil !== undefined
113
+ ? config.validUntil.getTime()
114
+ : FAR_FUTURE_MS;
115
+ const validAfter = config.validAfter !== undefined ? config.validAfter.getTime() : 0;
116
+ if (validUntil < validAfter) {
117
+ throw new Error(`Function "${fnName}": validUntil (${validUntil}) is before validAfter (${validAfter}).`);
118
+ }
119
+ policies.push({ type: 'time-frame', validUntil, validAfter });
120
+ }
121
+ if (config.valueLimit !== undefined) {
122
+ // Runtime backstop: payable-gating is enforced at the type level, but
123
+ // users can bypass with `as` casts. valueLimit on a non-payable function
124
+ // is harmless on-chain (msg.value is always 0, the cap always passes)
125
+ // but it leaks intent — throw rather than encode dead weight.
126
+ if (abiEntry.stateMutability !== 'payable') {
127
+ throw new Error(`Function "${fnName}" is not payable — \`valueLimit\` only constrains native ETH ` +
128
+ 'attached to the call, which is always zero for non-payable functions. ' +
129
+ 'Remove `valueLimit`.');
130
+ }
131
+ policies.push({ type: 'value-limit', limit: config.valueLimit });
132
+ }
133
+ if (config.spendingLimit !== undefined) {
134
+ // Runtime backstop: type-level gate restricts shape, but ERC20SpendingLimitPolicy
135
+ // dispatches by selector on-chain — a same-shaped function like
136
+ // mint(address,uint256) would encode successfully and fail every call.
137
+ if (!ERC20_SPENDING_LIMIT_SELECTORS.has(selector)) {
138
+ throw new Error(`Function "${fnName}" (selector ${selector}) is not an ERC-20 transfer/approve ` +
139
+ 'selector; `spendingLimit` only works on approve, increaseAllowance, ' +
140
+ 'transfer, or transferFrom. The on-chain policy dispatches by selector ' +
141
+ 'and would fail every call for other functions.');
142
+ }
143
+ policies.push({
144
+ type: 'spending-limits',
145
+ limits: [config.spendingLimit],
146
+ });
147
+ }
148
+ // --- End sugar field expansion -------------------------------------------
149
+ const rawParams = config.params ?? {};
150
+ const paramEntries = Object.entries(rawParams).filter(([, v]) => v !== undefined);
64
151
  if (paramEntries.length > 0) {
65
- const rules = paramEntries.map(([paramName, rule]) => {
152
+ const normalized = paramEntries.map(([paramName, rule]) => {
66
153
  const paramIndex = abiEntry.inputs.findIndex((p) => p.name === paramName);
67
154
  if (paramIndex === -1) {
68
155
  throw new Error(`Parameter "${paramName}" not found in function "${fnName}". ` +
@@ -75,21 +162,79 @@ function resolvePermission(permission) {
75
162
  '(address, bool, uint*, int*, bytes1–bytes32).');
76
163
  }
77
164
  const calldataOffset = BigInt(paramIndex) * 32n;
78
- const referenceValue = toReferenceValue(rule.value, param.type);
165
+ if (rule.anyOf !== undefined) {
166
+ if (rule.anyOf.length === 0) {
167
+ throw new Error(`Parameter "${paramName}" has empty anyOf — provide at least one value.`);
168
+ }
169
+ return {
170
+ paramName,
171
+ calldataOffset,
172
+ abiType: param.type,
173
+ anyOf: rule.anyOf,
174
+ };
175
+ }
79
176
  return {
80
- condition: rule.condition,
177
+ paramName,
81
178
  calldataOffset,
82
- referenceValue,
83
- ...(rule.usageLimit !== undefined
84
- ? { usageLimit: rule.usageLimit }
85
- : {}),
179
+ abiType: param.type,
180
+ condition: rule.condition,
181
+ value: rule.value,
182
+ usageLimit: rule.usageLimit,
86
183
  };
87
184
  });
88
- policies.push({
89
- type: 'universal-action',
90
- valueLimitPerUse: config.valueLimitPerUse ?? 0n,
91
- rules: rules,
92
- });
185
+ const usesArgPolicy = normalized.some((n) => n.anyOf !== undefined);
186
+ // UniActionPolicy/ArgPolicy reject `msg.value > valueLimitPerUse`, so a
187
+ // default of 0 would block any non-zero msg.value before the standalone
188
+ // value-limit policy (sugar) could allow it. Inherit the sugar's cap so
189
+ // the per-use gate matches user intent; value-limit still enforces the
190
+ // cumulative cap on top.
191
+ const embeddedValueLimit = config.valueLimitPerUse ?? config.valueLimit ?? 0n;
192
+ if (usesArgPolicy) {
193
+ // One sub-expression per param, then AND across params.
194
+ const perParam = normalized.map((n) => {
195
+ if (n.anyOf !== undefined) {
196
+ const leaves = n.anyOf.map((v) => ({
197
+ type: 'rule',
198
+ rule: {
199
+ condition: 'equal',
200
+ calldataOffset: n.calldataOffset,
201
+ referenceValue: toReferenceValue(v, n.abiType),
202
+ },
203
+ }));
204
+ return leaves.length === 1 ? leaves[0] : orChain(leaves);
205
+ }
206
+ return {
207
+ type: 'rule',
208
+ rule: {
209
+ condition: n.condition,
210
+ calldataOffset: n.calldataOffset,
211
+ referenceValue: toReferenceValue(n.value, n.abiType),
212
+ ...(n.usageLimit !== undefined
213
+ ? { usageLimit: n.usageLimit }
214
+ : {}),
215
+ },
216
+ };
217
+ });
218
+ policies.push({
219
+ type: 'arg-policy',
220
+ valueLimitPerUse: embeddedValueLimit,
221
+ expression: perParam.length === 1 ? perParam[0] : andChain(perParam),
222
+ });
223
+ }
224
+ else {
225
+ // Flat AND-of-rules — cheaper to init via UniActionPolicy.
226
+ const rules = normalized.map((n) => ({
227
+ condition: n.condition,
228
+ calldataOffset: n.calldataOffset,
229
+ referenceValue: toReferenceValue(n.value, n.abiType),
230
+ ...(n.usageLimit !== undefined ? { usageLimit: n.usageLimit } : {}),
231
+ }));
232
+ policies.push({
233
+ type: 'universal-action',
234
+ valueLimitPerUse: embeddedValueLimit,
235
+ rules: rules,
236
+ });
237
+ }
93
238
  }
94
239
  else if (config.valueLimitPerUse !== undefined) {
95
240
  policies.push({
@@ -105,7 +250,36 @@ function resolvePermission(permission) {
105
250
  }
106
251
  return actions;
107
252
  }
253
+ // Error-path only: recover the function name behind a selector for the
254
+ // duplicate-permission message.
255
+ function findFunctionName(permission, selector) {
256
+ return Object.keys(permission.functions).find((name) => {
257
+ const entry = permission.abi.find((e) => e.type === 'function' &&
258
+ e.name === name);
259
+ return entry !== undefined && toFunctionSelector(entry) === selector;
260
+ });
261
+ }
108
262
  function resolvePermissions(permissions) {
109
- return permissions.flatMap(resolvePermission);
263
+ // On-chain, actions are keyed by keccak(target, selector): two permission
264
+ // entries for the same function on the same contract share one actionId,
265
+ // and the later entry's `initializeWithMultiplexer` silently overwrites the
266
+ // earlier one's policy config. Reject at build time instead of letting the
267
+ // collision surface as an opaque InvalidSignature() at execution.
268
+ const seen = new Set();
269
+ return permissions.flatMap((permission) => {
270
+ const actions = resolvePermission(permission);
271
+ for (const action of actions) {
272
+ const key = `${action.target.toLowerCase()}:${action.selector.toLowerCase()}`;
273
+ if (seen.has(key)) {
274
+ const fnName = findFunctionName(permission, action.selector);
275
+ throw new Error(`Duplicate permission for function "${fnName}" (selector ${action.selector}) ` +
276
+ `on ${action.target}: permission entries for the same function on the same ` +
277
+ "contract share one on-chain action, so the later entry's policies would " +
278
+ 'silently overwrite the earlier ones. Merge them into a single entry.');
279
+ }
280
+ seen.add(key);
281
+ }
282
+ return actions;
283
+ });
110
284
  }
111
285
  export { resolvePermissions, resolvePermission };
@@ -0,0 +1,19 @@
1
+ import type { Address } from 'viem';
2
+ import type { CrossChainSettlementLayer } from '../../smart-sessions/types.js';
3
+ /**
4
+ * Collects every distinct arbiter address for the given settlement layers. The
5
+ * resulting whitelist is what the Permit2 claim policy enforces on-chain — a
6
+ * session signed once with this whitelist is valid against any of those
7
+ * arbiters.
8
+ *
9
+ * **"Any" means any of the *supported* settlement layers**, not any address on
10
+ * earth. When `layers` is empty or undefined, this expands to the union of
11
+ * every layer in {@link SETTLEMENT_LAYER_CONTRACT_KEYS}, so the on-chain arbiter
12
+ * check stays meaningful (the worst case is still a Rhinestone-blessed arbiter).
13
+ *
14
+ * @param layers Settlement layers the session is permitted to use.
15
+ * Empty/undefined ⇒ all supported layers.
16
+ * @param useDevContracts Pull from the dev address book instead of mainnet.
17
+ */
18
+ export declare function getArbitersForSettlementLayers(layers: readonly CrossChainSettlementLayer[] | undefined, useDevContracts?: boolean): Address[] | undefined;
19
+ //# sourceMappingURL=arbiters.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"arbiters.d.ts","sourceRoot":"","sources":["../../../../../../modules/validators/policies/claim/arbiters.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AACnC,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,4BAA4B,CAAA;AAoD3E;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,SAAS,yBAAyB,EAAE,GAAG,SAAS,EACxD,eAAe,CAAC,EAAE,OAAO,GACxB,OAAO,EAAE,GAAG,SAAS,CA6BvB"}
@@ -0,0 +1,82 @@
1
+ /**
2
+ * The arbiter contract keys that each settlement layer expands to. `ACROSS`
3
+ * whitelists both arbiter impls so a session is permissioned for the 7579 and
4
+ * multicall paths regardless of which one the orchestrator picks at intent time.
5
+ */
6
+ const SETTLEMENT_LAYER_CONTRACT_KEYS = {
7
+ SAME_CHAIN: ['samechainArbiter'],
8
+ ECO: ['ecoArbiter'],
9
+ ACROSS: ['across7579Arbiter', 'acrossMulticallArbiter'],
10
+ };
11
+ /**
12
+ * Bundled arbiter allow-set — the deployed arbiter addresses per key, per
13
+ * environment (the union across chains).
14
+ *
15
+ * v2: this is a small, signed-path **constant** bundled in the SDK rather than
16
+ * read from `@rhinestone/shared-configs`. The arbiter is baked into the user's
17
+ * Permit2 session signature, so it must stay **client-trusted** — never sourced
18
+ * from the orchestrator you transact against. Rhinestone's arbiters are CREATE2
19
+ * and near-uniform across chains, so this is a handful of addresses per key
20
+ * (e.g. `ecoArbiter` has a mainnet and a testnet address). A new *chain* reuses
21
+ * these; only a contract redeploy or a new settlement layer changes them.
22
+ */
23
+ const ARBITER_ADDRESSES = {
24
+ prod: {
25
+ samechainArbiter: ['0x000000000006e2569CaF8Ff021810790e0A0D740'],
26
+ ecoArbiter: [
27
+ '0x2e7627CCfAe4eDb336eEb5a70f08415B0F1a2b8C',
28
+ '0xA212A6ACCC8db0e4cdf4394D0A851c70Fc27A8F0',
29
+ ],
30
+ across7579Arbiter: ['0x28a4D41776968c1201A807ec51fFB405362B8882'],
31
+ acrossMulticallArbiter: ['0xA162fabb9a0EeF2736485A587aAAB3d015e14224'],
32
+ },
33
+ dev: {
34
+ samechainArbiter: ['0x8fA7720Eee299223f25De8DC03C68A28541dCD10'],
35
+ ecoArbiter: [
36
+ '0x1BeBAfb3D05d84A5Bfd94800c88d1342f755d8AB',
37
+ '0x8A061029AE4c5Cf69b5368119B3b0C80B31F55fE',
38
+ ],
39
+ across7579Arbiter: ['0x1b19973F7a29E950ad4FaF8872745B6378005517'],
40
+ acrossMulticallArbiter: ['0x8343FBBA0526deC1c952A098057021027648bcf9'],
41
+ },
42
+ };
43
+ /**
44
+ * Collects every distinct arbiter address for the given settlement layers. The
45
+ * resulting whitelist is what the Permit2 claim policy enforces on-chain — a
46
+ * session signed once with this whitelist is valid against any of those
47
+ * arbiters.
48
+ *
49
+ * **"Any" means any of the *supported* settlement layers**, not any address on
50
+ * earth. When `layers` is empty or undefined, this expands to the union of
51
+ * every layer in {@link SETTLEMENT_LAYER_CONTRACT_KEYS}, so the on-chain arbiter
52
+ * check stays meaningful (the worst case is still a Rhinestone-blessed arbiter).
53
+ *
54
+ * @param layers Settlement layers the session is permitted to use.
55
+ * Empty/undefined ⇒ all supported layers.
56
+ * @param useDevContracts Pull from the dev address book instead of mainnet.
57
+ */
58
+ export function getArbitersForSettlementLayers(layers, useDevContracts) {
59
+ const effectiveLayers = !layers || layers.length === 0
60
+ ? Object.keys(SETTLEMENT_LAYER_CONTRACT_KEYS)
61
+ : layers;
62
+ const book = ARBITER_ADDRESSES[useDevContracts ? 'dev' : 'prod'];
63
+ const keys = effectiveLayers.flatMap((l) => SETTLEMENT_LAYER_CONTRACT_KEYS[l]);
64
+ const seen = new Set();
65
+ const addresses = [];
66
+ // The same logical arbiter often shares an address across chains, but a given
67
+ // key may have multiple addresses live (e.g. a mainnet + testnet deployment).
68
+ // Collect every unique address for the requested keys, deduped
69
+ // case-insensitively.
70
+ for (const key of keys) {
71
+ // `keys` are `SETTLEMENT_LAYER_CONTRACT_KEYS` values, so `book` always has
72
+ // an entry for each — no missing-key fallback needed.
73
+ for (const addr of book[key]) {
74
+ const norm = addr.toLowerCase();
75
+ if (seen.has(norm))
76
+ continue;
77
+ seen.add(norm);
78
+ addresses.push(addr);
79
+ }
80
+ }
81
+ return addresses.length ? addresses : undefined;
82
+ }
@@ -0,0 +1,5 @@
1
+ import type { ResolvedModule } from '../types.js';
2
+ import type { AtomicValidatorDefinition, ResolvedValidatorDefinition } from './types.js';
3
+ export declare function resolveAtomicValidator(definition: AtomicValidatorDefinition): ResolvedModule;
4
+ export declare function resolveValidator(definition: ResolvedValidatorDefinition): ResolvedModule;
5
+ //# sourceMappingURL=resolve.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve.d.ts","sourceRoot":"","sources":["../../../../modules/validators/resolve.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAA;AAI9C,OAAO,KAAK,EACV,yBAAyB,EACzB,2BAA2B,EAC5B,MAAM,SAAS,CAAA;AAGhB,wBAAgB,sBAAsB,CACpC,UAAU,EAAE,yBAAyB,GACpC,cAAc,CAYhB;AAED,wBAAgB,gBAAgB,CAC9B,UAAU,EAAE,2BAA2B,GACtC,cAAc,CAIhB"}
@@ -0,0 +1,22 @@
1
+ import { resolveEnsValidator } from './ens.js';
2
+ import { resolveMultiFactorValidator } from './multi-factor.js';
3
+ import { resolveOwnableValidator } from './ownable.js';
4
+ import { resolveWebauthnValidator } from './webauthn.js';
5
+ export function resolveAtomicValidator(definition) {
6
+ switch (definition.kind) {
7
+ case 'ecdsa':
8
+ return resolveOwnableValidator(definition);
9
+ case 'ens':
10
+ return resolveEnsValidator(definition);
11
+ case 'passkey':
12
+ return resolveWebauthnValidator(definition);
13
+ case 'k1':
14
+ case 'smart-session':
15
+ throw new Error(`Validator ${definition.kind} requires feature input`);
16
+ }
17
+ }
18
+ export function resolveValidator(definition) {
19
+ return definition.kind === 'multi-factor'
20
+ ? resolveMultiFactorValidator(definition, resolveAtomicValidator)
21
+ : resolveAtomicValidator(definition);
22
+ }
@@ -0,0 +1,5 @@
1
+ import type { Account, Address, Hex } from 'viem';
2
+ import type { WebAuthnAccount } from 'viem/account-abstraction';
3
+ export declare function ecdsaSignerId(account: Account | Address): string;
4
+ export declare function webauthnSignerId(account: WebAuthnAccount | Hex): string;
5
+ //# sourceMappingURL=signer-id.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signer-id.d.ts","sourceRoot":"","sources":["../../../../modules/validators/signer-id.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACjD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE/D,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,GAAG,MAAM,CAGhE;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,eAAe,GAAG,GAAG,GAAG,MAAM,CAGvE"}
@@ -0,0 +1,8 @@
1
+ export function ecdsaSignerId(account) {
2
+ const address = typeof account === 'string' ? account : account.address;
3
+ return `ecdsa:${address.toLowerCase()}`;
4
+ }
5
+ export function webauthnSignerId(account) {
6
+ const publicKey = typeof account === 'string' ? account : account.publicKey;
7
+ return `webauthn:${publicKey.toLowerCase()}`;
8
+ }
@@ -0,0 +1,35 @@
1
+ import type { Address, Hex } from 'viem';
2
+ interface SmartSessionPolicyData {
3
+ readonly policy: Address;
4
+ readonly initData: Hex;
5
+ }
6
+ interface SmartSessionActionData {
7
+ readonly actionTargetSelector: Hex;
8
+ readonly actionTarget: Address;
9
+ readonly actionPolicies: readonly SmartSessionPolicyData[];
10
+ }
11
+ interface SmartSessionErc7739PolicyData {
12
+ readonly allowedERC7739Content: readonly {
13
+ readonly appDomainSeparator: Hex;
14
+ readonly contentNames: readonly string[];
15
+ }[];
16
+ readonly erc1271Policies: readonly SmartSessionPolicyData[];
17
+ }
18
+ export interface SmartSessionEnableContributionData {
19
+ readonly userSignature: Hex;
20
+ readonly hashesAndChainIds: readonly {
21
+ readonly chainId: bigint;
22
+ readonly sessionDigest: Hex;
23
+ }[];
24
+ readonly sessionToEnableIndex: number;
25
+ readonly session: {
26
+ readonly sessionValidator: Address;
27
+ readonly sessionValidatorInitData: Hex;
28
+ readonly salt: Hex;
29
+ readonly erc7739Policies: SmartSessionErc7739PolicyData;
30
+ readonly actions: readonly SmartSessionActionData[];
31
+ readonly claimPolicies: readonly SmartSessionPolicyData[];
32
+ };
33
+ }
34
+ export {};
35
+ //# sourceMappingURL=smart-session-signature-types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"smart-session-signature-types.d.ts","sourceRoot":"","sources":["../../../../modules/validators/smart-session-signature-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAExC,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAA;IACxB,QAAQ,CAAC,QAAQ,EAAE,GAAG,CAAA;CACvB;AAED,UAAU,sBAAsB;IAC9B,QAAQ,CAAC,oBAAoB,EAAE,GAAG,CAAA;IAClC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAA;IAC9B,QAAQ,CAAC,cAAc,EAAE,SAAS,sBAAsB,EAAE,CAAA;CAC3D;AAED,UAAU,6BAA6B;IACrC,QAAQ,CAAC,qBAAqB,EAAE,SAAS;QACvC,QAAQ,CAAC,kBAAkB,EAAE,GAAG,CAAA;QAChC,QAAQ,CAAC,YAAY,EAAE,SAAS,MAAM,EAAE,CAAA;KACzC,EAAE,CAAA;IACH,QAAQ,CAAC,eAAe,EAAE,SAAS,sBAAsB,EAAE,CAAA;CAC5D;AAED,MAAM,WAAW,kCAAkC;IACjD,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAA;IAC3B,QAAQ,CAAC,iBAAiB,EAAE,SAAS;QACnC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAA;QACxB,QAAQ,CAAC,aAAa,EAAE,GAAG,CAAA;KAC5B,EAAE,CAAA;IACH,QAAQ,CAAC,oBAAoB,EAAE,MAAM,CAAA;IACrC,QAAQ,CAAC,OAAO,EAAE;QAChB,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAA;QAClC,QAAQ,CAAC,wBAAwB,EAAE,GAAG,CAAA;QACtC,QAAQ,CAAC,IAAI,EAAE,GAAG,CAAA;QAClB,QAAQ,CAAC,eAAe,EAAE,6BAA6B,CAAA;QACvD,QAAQ,CAAC,OAAO,EAAE,SAAS,sBAAsB,EAAE,CAAA;QACnD,QAAQ,CAAC,aAAa,EAAE,SAAS,sBAAsB,EAAE,CAAA;KAC1D,CAAA;CACF"}
@@ -0,0 +1,99 @@
1
+ import { type Address } from 'viem';
2
+ import type { Session, SessionDetails } from './types.js';
3
+ export declare const SESSION_LOCK_TAG: "0x000000000000000000000000";
4
+ export declare const types: {
5
+ readonly PolicyData: readonly [{
6
+ readonly name: "policy";
7
+ readonly type: "address";
8
+ }, {
9
+ readonly name: "initData";
10
+ readonly type: "bytes";
11
+ }];
12
+ readonly ActionData: readonly [{
13
+ readonly name: "actionTargetSelector";
14
+ readonly type: "bytes4";
15
+ }, {
16
+ readonly name: "actionTarget";
17
+ readonly type: "address";
18
+ }, {
19
+ readonly name: "actionPolicies";
20
+ readonly type: "PolicyData[]";
21
+ }];
22
+ readonly ERC7739Context: readonly [{
23
+ readonly name: "appDomainSeparator";
24
+ readonly type: "bytes32";
25
+ }, {
26
+ readonly name: "contentName";
27
+ readonly type: "string[]";
28
+ }];
29
+ readonly ERC7739Data: readonly [{
30
+ readonly name: "allowedERC7739Content";
31
+ readonly type: "ERC7739Context[]";
32
+ }, {
33
+ readonly name: "erc1271Policies";
34
+ readonly type: "PolicyData[]";
35
+ }];
36
+ readonly LockTagData: readonly [{
37
+ readonly name: "lockTag";
38
+ readonly type: "bytes12";
39
+ }, {
40
+ readonly name: "claimPolicies";
41
+ readonly type: "PolicyData[]";
42
+ }];
43
+ readonly SignedPermissions: readonly [{
44
+ readonly name: "actions";
45
+ readonly type: "ActionData[]";
46
+ }, {
47
+ readonly name: "erc7739Policies";
48
+ readonly type: "ERC7739Data";
49
+ }, {
50
+ readonly name: "lockTagPolicies";
51
+ readonly type: "LockTagData";
52
+ }, {
53
+ readonly name: "permitGenericPolicy";
54
+ readonly type: "bool";
55
+ }];
56
+ readonly SignedSession: readonly [{
57
+ readonly name: "account";
58
+ readonly type: "address";
59
+ }, {
60
+ readonly name: "expires";
61
+ readonly type: "uint256";
62
+ }, {
63
+ readonly name: "nonce";
64
+ readonly type: "uint256";
65
+ }, {
66
+ readonly name: "permissions";
67
+ readonly type: "SignedPermissions";
68
+ }, {
69
+ readonly name: "salt";
70
+ readonly type: "bytes32";
71
+ }, {
72
+ readonly name: "sessionValidator";
73
+ readonly type: "address";
74
+ }, {
75
+ readonly name: "sessionValidatorInitData";
76
+ readonly type: "bytes";
77
+ }, {
78
+ readonly name: "smartSessionEmissary";
79
+ readonly type: "address";
80
+ }];
81
+ readonly ChainSession: readonly [{
82
+ readonly name: "chainId";
83
+ readonly type: "uint64";
84
+ }, {
85
+ readonly name: "session";
86
+ readonly type: "SignedSession";
87
+ }];
88
+ readonly MultiChainSession: readonly [{
89
+ readonly name: "sessionsAndChainIds";
90
+ readonly type: "ChainSession[]";
91
+ }];
92
+ };
93
+ export declare function getSessionDetails(input: {
94
+ readonly account: Address;
95
+ readonly sessions: readonly Session[];
96
+ readonly environment: 'production' | 'development';
97
+ readonly readNonce: (session: Session) => Promise<bigint>;
98
+ }): Promise<SessionDetails>;
99
+ //# sourceMappingURL=authorization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"authorization.d.ts","sourceRoot":"","sources":["../../../../../modules/validators/smart-sessions/authorization.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EAIb,MAAM,MAAM,CAAA;AAOb,OAAO,KAAK,EAAE,OAAO,EAAe,cAAc,EAAE,MAAM,SAAS,CAAA;AAEnE,eAAO,MAAM,gBAAgB,EAAG,4BAAqC,CAAA;AAErE,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2CR,CAAA;AAyCV,wBAAsB,iBAAiB,CAAC,KAAK,EAAE;IAC7C,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAA;IACrC,QAAQ,CAAC,WAAW,EAAE,YAAY,GAAG,aAAa,CAAA;IAClD,QAAQ,CAAC,SAAS,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,CAAA;CAC1D,GAAG,OAAO,CAAC,cAAc,CAAC,CA8B1B"}
@@ -0,0 +1,101 @@
1
+ import { hashStruct, maxUint256, } from 'viem';
2
+ import { getSessionData } from './digest.js';
3
+ import { getSmartSessionEmissaryAddress } from './module.js';
4
+ import { SMART_SESSIONS_FALLBACK_TARGET_FLAG, SMART_SESSIONS_FALLBACK_TARGET_SELECTOR_FLAG, } from './resolve.js';
5
+ export const SESSION_LOCK_TAG = '0x000000000000000000000000';
6
+ export const types = {
7
+ PolicyData: [
8
+ { name: 'policy', type: 'address' },
9
+ { name: 'initData', type: 'bytes' },
10
+ ],
11
+ ActionData: [
12
+ { name: 'actionTargetSelector', type: 'bytes4' },
13
+ { name: 'actionTarget', type: 'address' },
14
+ { name: 'actionPolicies', type: 'PolicyData[]' },
15
+ ],
16
+ ERC7739Context: [
17
+ { name: 'appDomainSeparator', type: 'bytes32' },
18
+ { name: 'contentName', type: 'string[]' },
19
+ ],
20
+ ERC7739Data: [
21
+ { name: 'allowedERC7739Content', type: 'ERC7739Context[]' },
22
+ { name: 'erc1271Policies', type: 'PolicyData[]' },
23
+ ],
24
+ LockTagData: [
25
+ { name: 'lockTag', type: 'bytes12' },
26
+ { name: 'claimPolicies', type: 'PolicyData[]' },
27
+ ],
28
+ SignedPermissions: [
29
+ { name: 'actions', type: 'ActionData[]' },
30
+ { name: 'erc7739Policies', type: 'ERC7739Data' },
31
+ { name: 'lockTagPolicies', type: 'LockTagData' },
32
+ { name: 'permitGenericPolicy', type: 'bool' },
33
+ ],
34
+ SignedSession: [
35
+ { name: 'account', type: 'address' },
36
+ { name: 'expires', type: 'uint256' },
37
+ { name: 'nonce', type: 'uint256' },
38
+ { name: 'permissions', type: 'SignedPermissions' },
39
+ { name: 'salt', type: 'bytes32' },
40
+ { name: 'sessionValidator', type: 'address' },
41
+ { name: 'sessionValidatorInitData', type: 'bytes' },
42
+ { name: 'smartSessionEmissary', type: 'address' },
43
+ ],
44
+ ChainSession: [
45
+ { name: 'chainId', type: 'uint64' },
46
+ { name: 'session', type: 'SignedSession' },
47
+ ],
48
+ MultiChainSession: [{ name: 'sessionsAndChainIds', type: 'ChainSession[]' }],
49
+ };
50
+ function signedSession(account, data, nonce, environment) {
51
+ return {
52
+ account,
53
+ permissions: {
54
+ permitGenericPolicy: data.actions.some((action) => action.actionTarget === SMART_SESSIONS_FALLBACK_TARGET_FLAG &&
55
+ action.actionTargetSelector ===
56
+ SMART_SESSIONS_FALLBACK_TARGET_SELECTOR_FLAG),
57
+ lockTagPolicies: {
58
+ lockTag: SESSION_LOCK_TAG,
59
+ claimPolicies: data.claimPolicies,
60
+ },
61
+ erc7739Policies: {
62
+ allowedERC7739Content: data.erc7739Policies.allowedERC7739Content.map((content) => ({
63
+ contentName: content.contentNames,
64
+ appDomainSeparator: content.appDomainSeparator,
65
+ })),
66
+ erc1271Policies: data.erc7739Policies.erc1271Policies,
67
+ },
68
+ actions: data.actions,
69
+ },
70
+ sessionValidator: data.sessionValidator,
71
+ sessionValidatorInitData: data.sessionValidatorInitData,
72
+ salt: data.salt,
73
+ smartSessionEmissary: getSmartSessionEmissaryAddress(environment),
74
+ expires: maxUint256,
75
+ nonce,
76
+ };
77
+ }
78
+ export async function getSessionDetails(input) {
79
+ const nonces = await Promise.all(input.sessions.map(input.readNonce));
80
+ const signed = input.sessions.map((session, index) => signedSession(input.account, getSessionData(session), nonces[index], input.environment));
81
+ const hashesAndChainIds = signed.map((session, index) => ({
82
+ chainId: BigInt(input.sessions[index].chain.id),
83
+ sessionDigest: hashStruct({
84
+ types,
85
+ primaryType: 'SignedSession',
86
+ data: session,
87
+ }),
88
+ }));
89
+ const data = {
90
+ domain: { name: 'SmartSessionEmissary', version: '1' },
91
+ types,
92
+ primaryType: 'MultiChainSession',
93
+ message: {
94
+ sessionsAndChainIds: signed.map((session, index) => ({
95
+ chainId: BigInt(input.sessions[index].chain.id),
96
+ session,
97
+ })),
98
+ },
99
+ };
100
+ return { nonces, hashesAndChainIds, data };
101
+ }