@ixo/editor 7.3.0 → 7.5.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 (321) hide show
  1. package/dist/{BidConfig-YZWE5HMW.js → BidConfig-7OPADSLJ.js} +10 -10
  2. package/dist/{BidFlowDetail-GGCQSJGT.js → BidFlowDetail-CLGN6RFS.js} +15 -15
  3. package/dist/{CalendarEventCreateConfig-MG5KEVT5.js → CalendarEventCreateConfig-HFHRPWXW.js} +11 -11
  4. package/dist/{CalendarEventCreateFlowDetail-NJIVXYZE.js → CalendarEventCreateFlowDetail-ZXPHYLF4.js} +12 -12
  5. package/dist/{CalendarEventListConfig-47DCJ4JN.js → CalendarEventListConfig-LYPXEDYO.js} +11 -11
  6. package/dist/{CalendarEventListFlowDetail-6LN4I3SI.js → CalendarEventListFlowDetail-3P5I6NWJ.js} +5 -5
  7. package/dist/{CalendarEventUpdateConfig-JBSY4IQI.js → CalendarEventUpdateConfig-FZNZRRCQ.js} +11 -11
  8. package/dist/{CalendarEventUpdateFlowDetail-RW2PQCVL.js → CalendarEventUpdateFlowDetail-SBODZKHB.js} +12 -12
  9. package/dist/{ClaimConfig-ASGZFCTD.js → ClaimConfig-T7KRYXOU.js} +13 -13
  10. package/dist/{ClaimFlowDetail-LVHNKNPE.js → ClaimFlowDetail-DI27NHDH.js} +15 -15
  11. package/dist/{CollectionLifecycleConfig-YPTZZJ3S.js → CollectionLifecycleConfig-SLU7TWJI.js} +4 -4
  12. package/dist/{CollectionLifecycleFlowDetail-RP6BNX4F.js → CollectionLifecycleFlowDetail-NHMR566C.js} +14 -14
  13. package/dist/{CollectionUsersConfig-FHB7GXYE.js → CollectionUsersConfig-XUIJ6DSW.js} +10 -10
  14. package/dist/{CollectionUsersFlowDetail-EZE5ADLN.js → CollectionUsersFlowDetail-IM3YWT6E.js} +16 -16
  15. package/dist/{CredentialStoreConfig-A7P27LZ5.js → CredentialStoreConfig-KAST7NSD.js} +8 -8
  16. package/dist/{CredentialStoreFlowDetail-5LRH7NH5.js → CredentialStoreFlowDetail-FKIAQZJ7.js} +7 -7
  17. package/dist/{DesignPodFlowDetail-ECFMDZZ3.js → DesignPodFlowDetail-UXGGFJRH.js} +5 -5
  18. package/dist/{DomainCardPreviewFlowDetail-M7FPXS4N.js → DomainCardPreviewFlowDetail-IT2OJF46.js} +7 -7
  19. package/dist/{DomainIndexerLookupFlowDetail-L6GSDWLI.js → DomainIndexerLookupFlowDetail-Y7JRRKD5.js} +5 -5
  20. package/dist/{DomainSignFlowDetail-5ERYSTPG.js → DomainSignFlowDetail-T5PZHM6M.js} +8 -8
  21. package/dist/{DomainSingleSelectionConfig-DTHYPZBO.js → DomainSingleSelectionConfig-H7RSNYC2.js} +4 -4
  22. package/dist/{DomainSingleSelectionFlowDetail-JKNAC2RY.js → DomainSingleSelectionFlowDetail-JHSD5G3A.js} +5 -5
  23. package/dist/{EmailSendConfig-ZH5BS4AE.js → EmailSendConfig-6RJNKNVV.js} +10 -10
  24. package/dist/{EntityCreateOracleFlowDetail-6XJ4UEL5.js → EntityCreateOracleFlowDetail-LZPSS3GS.js} +7 -7
  25. package/dist/{EntitySingleSelectionFlowDetail-5BDIVHQV.js → EntitySingleSelectionFlowDetail-HMCMVXKR.js} +5 -5
  26. package/dist/{EntityTransferFlowDetail-DY2UZ5VA.js → EntityTransferFlowDetail-RSFDF5PB.js} +7 -7
  27. package/dist/{EvalEngineConfig-BJOMRKZE.js → EvalEngineConfig-7JSFDMQR.js} +16 -14
  28. package/dist/{EvalEngineConfig-BJOMRKZE.js.map → EvalEngineConfig-7JSFDMQR.js.map} +1 -1
  29. package/dist/{EvalEngineFlowDetail-UFIMDVZY.js → EvalEngineFlowDetail-OAM3AGN2.js} +15 -13
  30. package/dist/{EvalEngineFlowDetail-UFIMDVZY.js.map → EvalEngineFlowDetail-OAM3AGN2.js.map} +1 -1
  31. package/dist/{EvaluateBidConfig-I6OIVCXE.js → EvaluateBidConfig-WYWY3SSW.js} +10 -10
  32. package/dist/{EvaluateBidFlowDetail-YWCXV4OS.js → EvaluateBidFlowDetail-QMSIAFG5.js} +14 -14
  33. package/dist/{EvaluateClaimConfig-Q6CV2ZU4.js → EvaluateClaimConfig-FMGZ3UG7.js} +10 -10
  34. package/dist/{EvaluateClaimFlowDetail-J3C3M4F2.js → EvaluateClaimFlowDetail-AL6AL5FV.js} +760 -275
  35. package/dist/EvaluateClaimFlowDetail-AL6AL5FV.js.map +1 -0
  36. package/dist/{FormSubmitFlowDetail-CVSUWEAW.js → FormSubmitFlowDetail-ICG3GSOA.js} +59 -10
  37. package/dist/FormSubmitFlowDetail-ICG3GSOA.js.map +1 -0
  38. package/dist/{GovernanceAuthzExecFlowDetail-GWKPT7QW.js → GovernanceAuthzExecFlowDetail-IW76KM4Q.js} +8 -8
  39. package/dist/{GovernanceAuthzGrantFlowDetail-L7EPQQZ6.js → GovernanceAuthzGrantFlowDetail-BTCMC2ZN.js} +9 -9
  40. package/dist/{GovernanceAuthzRevokeFlowDetail-X2VQHRCB.js → GovernanceAuthzRevokeFlowDetail-7DVXQWXC.js} +9 -9
  41. package/dist/{GovernanceChainVoteFlowDetail-BO3DJNDF.js → GovernanceChainVoteFlowDetail-CIBRJPP6.js} +8 -8
  42. package/dist/{GovernanceConfigFlowDetail-FZB4R54G.js → GovernanceConfigFlowDetail-6P7GLUT4.js} +5 -5
  43. package/dist/{GovernanceContractExecuteFlowDetail-JHIXCNXS.js → GovernanceContractExecuteFlowDetail-4Q32MNXQ.js} +9 -9
  44. package/dist/{GovernanceContractInstantiateFlowDetail-XWSI2HXG.js → GovernanceContractInstantiateFlowDetail-GOFRJNS6.js} +9 -9
  45. package/dist/{GovernanceContractManageCw20FlowDetail-5QI3FBNT.js → GovernanceContractManageCw20FlowDetail-QYFC2CBY.js} +8 -8
  46. package/dist/{GovernanceContractMigrateFlowDetail-W2DEBKKU.js → GovernanceContractMigrateFlowDetail-YS575HJK.js} +9 -9
  47. package/dist/{GovernanceContractUpdateAdminFlowDetail-VZ6245TK.js → GovernanceContractUpdateAdminFlowDetail-YNN5VVUN.js} +8 -8
  48. package/dist/{GovernanceCustomMessageFlowDetail-NNTHVM5D.js → GovernanceCustomMessageFlowDetail-AP2DYHPG.js} +9 -9
  49. package/dist/{GovernanceDaoAcceptToMarketplaceFlowDetail-EO3CFNLA.js → GovernanceDaoAcceptToMarketplaceFlowDetail-WHC2GXB7.js} +9 -9
  50. package/dist/{GovernanceDaoAdminExecFlowDetail-YQCDUW2V.js → GovernanceDaoAdminExecFlowDetail-5545VOCJ.js} +10 -10
  51. package/dist/{GovernanceDaoCreateEntityFlowDetail-RSFFRATK.js → GovernanceDaoCreateEntityFlowDetail-QKSNQHT3.js} +9 -9
  52. package/dist/{GovernanceDaoJoinFlowDetail-GJWWQPD2.js → GovernanceDaoJoinFlowDetail-ZIZA4CHJ.js} +9 -9
  53. package/dist/{GovernanceDaoManageStorageFlowDetail-KGMWUB4Z.js → GovernanceDaoManageStorageFlowDetail-V7CNBFD5.js} +8 -8
  54. package/dist/{GovernanceDaoManageSubDaosFlowDetail-3WTI6AX7.js → GovernanceDaoManageSubDaosFlowDetail-U6HCZEWB.js} +9 -9
  55. package/dist/{GovernanceDaoUpdateInfoFlowDetail-2DCOJGYV.js → GovernanceDaoUpdateInfoFlowDetail-YGVZWXYR.js} +8 -8
  56. package/dist/{GovernanceMemberProposalConfig-LW6KNHVY.js → GovernanceMemberProposalConfig-3HKKBDJ5.js} +5 -5
  57. package/dist/{GovernanceMemberProposalFlowDetail-JNO3RPDW.js → GovernanceMemberProposalFlowDetail-5DYOTEMZ.js} +9 -9
  58. package/dist/{GovernanceNftBurnFlowDetail-MG3S2DZB.js → GovernanceNftBurnFlowDetail-ZHL6NSBB.js} +8 -8
  59. package/dist/{GovernanceNftManageCollectionsFlowDetail-FB5BRSLF.js → GovernanceNftManageCollectionsFlowDetail-YKWXV6PI.js} +8 -8
  60. package/dist/{GovernanceNftTransferFlowDetail-27CRQVTA.js → GovernanceNftTransferFlowDetail-SQ5ZSKIK.js} +9 -9
  61. package/dist/{GovernanceSettingsProposalConfig-WBOTSKNF.js → GovernanceSettingsProposalConfig-IZFFFRHS.js} +5 -5
  62. package/dist/{GovernanceSettingsProposalFlowDetail-W2KXBQM2.js → GovernanceSettingsProposalFlowDetail-72OGJWPM.js} +8 -8
  63. package/dist/{GovernanceStakingStakeFlowDetail-Z7MCDZDV.js → GovernanceStakingStakeFlowDetail-TQT6JVX5.js} +8 -8
  64. package/dist/{GovernanceStakingStakeToGroupFlowDetail-EC6JGRMB.js → GovernanceStakingStakeToGroupFlowDetail-RHW3KT4J.js} +8 -8
  65. package/dist/{GovernanceSubmissionConfigProposalFlowDetail-YHO3F7TI.js → GovernanceSubmissionConfigProposalFlowDetail-ELSE6QV6.js} +8 -8
  66. package/dist/{GovernanceTransactionMintFlowDetail-K6PPDCH6.js → GovernanceTransactionMintFlowDetail-3I7F3FSC.js} +9 -9
  67. package/dist/{GovernanceTransactionPerformTokenSwapFlowDetail-6PEN4FED.js → GovernanceTransactionPerformTokenSwapFlowDetail-5UTYTE3P.js} +8 -8
  68. package/dist/{GovernanceTransactionSendFundsConfig-JRROE44J.js → GovernanceTransactionSendFundsConfig-UITDQIEX.js} +5 -5
  69. package/dist/{GovernanceTransactionSendFundsFlowDetail-Z57XAY3D.js → GovernanceTransactionSendFundsFlowDetail-FUHTFFYK.js} +9 -9
  70. package/dist/{GovernanceTransactionSendGroupTokenFlowDetail-OSEHM66P.js → GovernanceTransactionSendGroupTokenFlowDetail-JEGHRGVA.js} +9 -9
  71. package/dist/{GovernanceTransactionWithdrawTokenSwapFlowDetail-AZFHSIBD.js → GovernanceTransactionWithdrawTokenSwapFlowDetail-IGKD3XFX.js} +8 -8
  72. package/dist/{GovernanceValidatorActionsFlowDetail-3YSPIIVG.js → GovernanceValidatorActionsFlowDetail-XFJM4T54.js} +8 -8
  73. package/dist/{HarvestConfig-L37MMZE5.js → HarvestConfig-MQCRQM6E.js} +9 -9
  74. package/dist/{HarvestFlowDetail-Y2AJWJKR.js → HarvestFlowDetail-4AGZTR7Z.js} +7 -7
  75. package/dist/{HttpRequestConfig-C74HRIO5.js → HttpRequestConfig-24VT44SK.js} +8 -8
  76. package/dist/{HttpRequestFlowDetail-VWD64O3P.js → HttpRequestFlowDetail-LGWILJCS.js} +5 -5
  77. package/dist/{IdentityCreateFlowDetail-CGE66IXY.js → IdentityCreateFlowDetail-6UVA3GLT.js} +13 -13
  78. package/dist/{IidCreateFlowDetail-J4PKJMSA.js → IidCreateFlowDetail-6DMLKXSP.js} +13 -13
  79. package/dist/{KycVerifyConfig-YPTVDVAM.js → KycVerifyConfig-QKU3GYXH.js} +8 -8
  80. package/dist/{KycVerifyFlowDetail-CFWXA3AT.js → KycVerifyFlowDetail-MJB5DFB5.js} +13 -13
  81. package/dist/{ListDomainFlowsFlowDetail-PJQCAY3I.js → ListDomainFlowsFlowDetail-PDUSV2TD.js} +5 -5
  82. package/dist/{LoadBatchesFlowDetail-TL4TQDZ5.js → LoadBatchesFlowDetail-SXLSDRVT.js} +7 -7
  83. package/dist/{MatrixDmConfig-DRY27FAM.js → MatrixDmConfig-XCS2HCGZ.js} +4 -4
  84. package/dist/{MatrixRegisterFlowDetail-RXHGTTQF.js → MatrixRegisterFlowDetail-7JMBMOTF.js} +7 -7
  85. package/dist/{MemberMultiSelectFlowDetail-N64ZK7GE.js → MemberMultiSelectFlowDetail-DLAKXCRC.js} +5 -5
  86. package/dist/{OracleConfig-J3NN2EP4.js → OracleConfig-RU6N4JBF.js} +8 -8
  87. package/dist/{OracleConfigureOracleFlowDetail-3ER4XIAB.js → OracleConfigureOracleFlowDetail-AET56AV6.js} +13 -13
  88. package/dist/{OracleContractFlowDetail-D2XZYWVG.js → OracleContractFlowDetail-4RWSGCLI.js} +7 -7
  89. package/dist/{OracleDeployFlowDetail-TCFIJYP7.js → OracleDeployFlowDetail-2HOKGJEO.js} +7 -7
  90. package/dist/{OracleDeploySetupFlowDetail-KMGBPIND.js → OracleDeploySetupFlowDetail-AOUCBEJK.js} +7 -7
  91. package/dist/{OracleDeployStartFlowDetail-DTK5PLC5.js → OracleDeployStartFlowDetail-5R5O54VE.js} +7 -7
  92. package/dist/{OracleFlowDetail-FEPE3YYU.js → OracleFlowDetail-REP3CDHK.js} +7 -7
  93. package/dist/{OraclePromptFlowDetail-2B55RVOO.js → OraclePromptFlowDetail-RWGI7Y46.js} +7 -7
  94. package/dist/{OracleStoreConfigFlowDetail-Q6PTB2TR.js → OracleStoreConfigFlowDetail-F2E4ZEVA.js} +7 -7
  95. package/dist/{OracleStoreSecretsAndConfigFlowDetail-7U6RI2A2.js → OracleStoreSecretsAndConfigFlowDetail-6X4CPXKW.js} +13 -13
  96. package/dist/{OracleStoreSecretsFlowDetail-6HEZJZ3R.js → OracleStoreSecretsFlowDetail-DYPIPYIT.js} +13 -13
  97. package/dist/{ProposalCreateConfig-ZQIK6PZB.js → ProposalCreateConfig-DRYE2AKJ.js} +10 -10
  98. package/dist/{ProposalCreateFlowDetail-3JNI7S6E.js → ProposalCreateFlowDetail-CHIA2XWY.js} +14 -14
  99. package/dist/{ProposalVoteConfig-TZ3FGE4A.js → ProposalVoteConfig-7UNWFROZ.js} +10 -10
  100. package/dist/{ProposalVoteFlowDetail-6BOYU4XJ.js → ProposalVoteFlowDetail-DSMBVP3E.js} +8 -8
  101. package/dist/{ProtocolSelectFlowDetail-IKYJQZAO.js → ProtocolSelectFlowDetail-NTLOLTSO.js} +4 -4
  102. package/dist/{RetireConfig-YKFKGNOR.js → RetireConfig-BF2DX5IS.js} +9 -9
  103. package/dist/{RetireFlowDetail-SP5GBJSA.js → RetireFlowDetail-LY77O4VE.js} +7 -7
  104. package/dist/{SandboxProvisionFlowDetail-CQ7XZWNA.js → SandboxProvisionFlowDetail-QPRFK7N3.js} +7 -7
  105. package/dist/{WalletFundConfig-T5S6B2HH.js → WalletFundConfig-QF2D65SA.js} +5 -5
  106. package/dist/{WalletFundFlowDetail-WLQLJS34.js → WalletFundFlowDetail-CTWM57AK.js} +8 -8
  107. package/dist/{WalletGenerateAndFundFlowDetail-7LEBWWEA.js → WalletGenerateAndFundFlowDetail-TY3HOGEU.js} +5 -5
  108. package/dist/{WalletGenerateFlowDetail-CBAVDW7Z.js → WalletGenerateFlowDetail-F5LNH4VY.js} +5 -5
  109. package/dist/{XeroContactCreateConfig-N6YU7YEX.js → XeroContactCreateConfig-GTRMV4MO.js} +11 -11
  110. package/dist/{XeroContactCreateFlowDetail-NO65PRXE.js → XeroContactCreateFlowDetail-4IFZRJOF.js} +12 -12
  111. package/dist/{XeroInvoiceCreateConfig-VHJMWKY2.js → XeroInvoiceCreateConfig-HVMMNUU4.js} +11 -11
  112. package/dist/{XeroInvoiceCreateFlowDetail-UJDEUWH6.js → XeroInvoiceCreateFlowDetail-4UPL55DU.js} +14 -14
  113. package/dist/{XeroInvoiceListConfig-CEECA5U7.js → XeroInvoiceListConfig-IMXZZTNF.js} +11 -11
  114. package/dist/{XeroInvoiceListFlowDetail-YPU6MFSX.js → XeroInvoiceListFlowDetail-SUWMEU7K.js} +5 -5
  115. package/dist/{XeroPaymentCreateConfig-KULFUA66.js → XeroPaymentCreateConfig-ONPADVHN.js} +8 -8
  116. package/dist/{XeroPaymentCreateFlowDetail-BRRQJ67R.js → XeroPaymentCreateFlowDetail-52FOC77L.js} +13 -13
  117. package/dist/action-manifest.json +491 -7
  118. package/dist/{chunk-JDNOVB6L.js → chunk-3S6HH3LV.js} +2 -2
  119. package/dist/{chunk-H4SFPUJT.js → chunk-5JEXVSJG.js} +11 -129
  120. package/dist/chunk-5JEXVSJG.js.map +1 -0
  121. package/dist/chunk-5WYFQEOS.js +49 -0
  122. package/dist/chunk-5WYFQEOS.js.map +1 -0
  123. package/dist/{chunk-ZIT2N7CI.js → chunk-6332CJVF.js} +2 -2
  124. package/dist/{chunk-RQS3KQLQ.js → chunk-66EWPWA5.js} +2 -2
  125. package/dist/{chunk-ZGMXAWTQ.js → chunk-66XW6TQT.js} +590 -8
  126. package/dist/chunk-66XW6TQT.js.map +1 -0
  127. package/dist/{chunk-UW3DNXM7.js → chunk-6OBTZWYM.js} +3 -3
  128. package/dist/{chunk-FJ36VM6S.js → chunk-7XB6INJ4.js} +2 -2
  129. package/dist/{chunk-MSPUTDZC.js → chunk-ALJO4A2R.js} +3006 -863
  130. package/dist/chunk-ALJO4A2R.js.map +1 -0
  131. package/dist/{chunk-QSUE3ZFB.js → chunk-AZGVSR3T.js} +2 -2
  132. package/dist/{chunk-MQAJXYIS.js → chunk-DMWXSWLO.js} +2 -2
  133. package/dist/{chunk-AAPXJGX7.js → chunk-FYPDR7DJ.js} +2010 -1891
  134. package/dist/chunk-FYPDR7DJ.js.map +1 -0
  135. package/dist/{chunk-C376YPPE.js → chunk-HPHWYDGB.js} +3 -3
  136. package/dist/{chunk-JWC4VVY7.js → chunk-JCI46234.js} +2 -2
  137. package/dist/{chunk-A7L3NJK6.js → chunk-KIAAAFZF.js} +2 -2
  138. package/dist/{chunk-BAQA4AZN.js → chunk-KSITH7AN.js} +3 -3
  139. package/dist/chunk-KSITH7AN.js.map +1 -0
  140. package/dist/{chunk-MY22PTP4.js → chunk-LMQT3VUE.js} +2 -2
  141. package/dist/{chunk-RV7QJFSE.js → chunk-M5ELO3A5.js} +2 -2
  142. package/dist/{chunk-RETGBEFM.js → chunk-M7XUQCKC.js} +2 -2
  143. package/dist/{chunk-A5ZITS4O.js → chunk-MDCOAGIF.js} +11 -17
  144. package/dist/chunk-MDCOAGIF.js.map +1 -0
  145. package/dist/{chunk-2KOJBMG5.js → chunk-MFUWKWMA.js} +21 -4
  146. package/dist/chunk-MFUWKWMA.js.map +1 -0
  147. package/dist/{chunk-6JOBSAZF.js → chunk-P365VW4X.js} +2 -2
  148. package/dist/{chunk-SRSVMD6E.js → chunk-PCRDF4BQ.js} +2 -2
  149. package/dist/{chunk-SZRWCNGA.js → chunk-PNS4Y2PQ.js} +2 -2
  150. package/dist/{chunk-J6AWMFEF.js → chunk-PWPTKUNE.js} +2 -2
  151. package/dist/{chunk-S2ETTOE5.js → chunk-SAOQXHK6.js} +2 -2
  152. package/dist/{chunk-EH7EYO4N.js → chunk-SI2AUBY5.js} +4 -4
  153. package/dist/{chunk-CMG6TZKH.js → chunk-TGRBWL3B.js} +3 -3
  154. package/dist/{chunk-76VIZL5D.js → chunk-TGTS2R2O.js} +5 -5
  155. package/dist/{chunk-JK6RAKE3.js → chunk-UOYPASUI.js} +2 -2
  156. package/dist/{chunk-7TVYQNOR.js → chunk-VD4HSZSN.js} +2 -2
  157. package/dist/chunk-VD4HSZSN.js.map +1 -0
  158. package/dist/{chunk-L7WHIPGC.js → chunk-VOBXFJLM.js} +2 -2
  159. package/dist/{chunk-M3GHFF5N.js → chunk-X5BU6FRG.js} +3 -47
  160. package/dist/chunk-X5BU6FRG.js.map +1 -0
  161. package/dist/{chunk-QW7LA67J.js → chunk-X5W725D3.js} +11 -4
  162. package/dist/chunk-X5W725D3.js.map +1 -0
  163. package/dist/{chunk-X23SZR5N.js → chunk-XUJPJRLW.js} +2 -2
  164. package/dist/{connections-tcxJgB1K.d.ts → connections-Dx7agyTM.d.ts} +2 -2
  165. package/dist/core/index.cjs +611 -27
  166. package/dist/core/index.cjs.map +1 -1
  167. package/dist/core/index.d.ts +6 -4
  168. package/dist/core/index.js +12 -12
  169. package/dist/{graphql-client-VK7-KGDc.d.ts → graphql-client-VfvdQc02.d.ts} +1 -1
  170. package/dist/index.d.ts +3 -3
  171. package/dist/index.js +23 -21
  172. package/dist/index.js.map +1 -1
  173. package/dist/mantine/index.d.ts +3 -3
  174. package/dist/mantine/index.js +22 -20
  175. package/dist/mantine/index.js.map +1 -1
  176. package/dist/{types-CYtPUWc7.d.ts → types-BjlQ_0i3.d.ts} +590 -0
  177. package/package.json +1 -1
  178. package/dist/EvaluateClaimFlowDetail-J3C3M4F2.js.map +0 -1
  179. package/dist/FormSubmitFlowDetail-CVSUWEAW.js.map +0 -1
  180. package/dist/chunk-2KOJBMG5.js.map +0 -1
  181. package/dist/chunk-7TVYQNOR.js.map +0 -1
  182. package/dist/chunk-A5ZITS4O.js.map +0 -1
  183. package/dist/chunk-AAPXJGX7.js.map +0 -1
  184. package/dist/chunk-BAQA4AZN.js.map +0 -1
  185. package/dist/chunk-H4SFPUJT.js.map +0 -1
  186. package/dist/chunk-M3GHFF5N.js.map +0 -1
  187. package/dist/chunk-MSPUTDZC.js.map +0 -1
  188. package/dist/chunk-QW7LA67J.js.map +0 -1
  189. package/dist/chunk-ZGMXAWTQ.js.map +0 -1
  190. /package/dist/{BidConfig-YZWE5HMW.js.map → BidConfig-7OPADSLJ.js.map} +0 -0
  191. /package/dist/{BidFlowDetail-GGCQSJGT.js.map → BidFlowDetail-CLGN6RFS.js.map} +0 -0
  192. /package/dist/{CalendarEventCreateConfig-MG5KEVT5.js.map → CalendarEventCreateConfig-HFHRPWXW.js.map} +0 -0
  193. /package/dist/{CalendarEventCreateFlowDetail-NJIVXYZE.js.map → CalendarEventCreateFlowDetail-ZXPHYLF4.js.map} +0 -0
  194. /package/dist/{CalendarEventListConfig-47DCJ4JN.js.map → CalendarEventListConfig-LYPXEDYO.js.map} +0 -0
  195. /package/dist/{CalendarEventListFlowDetail-6LN4I3SI.js.map → CalendarEventListFlowDetail-3P5I6NWJ.js.map} +0 -0
  196. /package/dist/{CalendarEventUpdateConfig-JBSY4IQI.js.map → CalendarEventUpdateConfig-FZNZRRCQ.js.map} +0 -0
  197. /package/dist/{CalendarEventUpdateFlowDetail-RW2PQCVL.js.map → CalendarEventUpdateFlowDetail-SBODZKHB.js.map} +0 -0
  198. /package/dist/{ClaimConfig-ASGZFCTD.js.map → ClaimConfig-T7KRYXOU.js.map} +0 -0
  199. /package/dist/{ClaimFlowDetail-LVHNKNPE.js.map → ClaimFlowDetail-DI27NHDH.js.map} +0 -0
  200. /package/dist/{CollectionLifecycleConfig-YPTZZJ3S.js.map → CollectionLifecycleConfig-SLU7TWJI.js.map} +0 -0
  201. /package/dist/{CollectionLifecycleFlowDetail-RP6BNX4F.js.map → CollectionLifecycleFlowDetail-NHMR566C.js.map} +0 -0
  202. /package/dist/{CollectionUsersConfig-FHB7GXYE.js.map → CollectionUsersConfig-XUIJ6DSW.js.map} +0 -0
  203. /package/dist/{CollectionUsersFlowDetail-EZE5ADLN.js.map → CollectionUsersFlowDetail-IM3YWT6E.js.map} +0 -0
  204. /package/dist/{CredentialStoreConfig-A7P27LZ5.js.map → CredentialStoreConfig-KAST7NSD.js.map} +0 -0
  205. /package/dist/{CredentialStoreFlowDetail-5LRH7NH5.js.map → CredentialStoreFlowDetail-FKIAQZJ7.js.map} +0 -0
  206. /package/dist/{DesignPodFlowDetail-ECFMDZZ3.js.map → DesignPodFlowDetail-UXGGFJRH.js.map} +0 -0
  207. /package/dist/{DomainCardPreviewFlowDetail-M7FPXS4N.js.map → DomainCardPreviewFlowDetail-IT2OJF46.js.map} +0 -0
  208. /package/dist/{DomainIndexerLookupFlowDetail-L6GSDWLI.js.map → DomainIndexerLookupFlowDetail-Y7JRRKD5.js.map} +0 -0
  209. /package/dist/{DomainSignFlowDetail-5ERYSTPG.js.map → DomainSignFlowDetail-T5PZHM6M.js.map} +0 -0
  210. /package/dist/{DomainSingleSelectionConfig-DTHYPZBO.js.map → DomainSingleSelectionConfig-H7RSNYC2.js.map} +0 -0
  211. /package/dist/{DomainSingleSelectionFlowDetail-JKNAC2RY.js.map → DomainSingleSelectionFlowDetail-JHSD5G3A.js.map} +0 -0
  212. /package/dist/{EmailSendConfig-ZH5BS4AE.js.map → EmailSendConfig-6RJNKNVV.js.map} +0 -0
  213. /package/dist/{EntityCreateOracleFlowDetail-6XJ4UEL5.js.map → EntityCreateOracleFlowDetail-LZPSS3GS.js.map} +0 -0
  214. /package/dist/{EntitySingleSelectionFlowDetail-5BDIVHQV.js.map → EntitySingleSelectionFlowDetail-HMCMVXKR.js.map} +0 -0
  215. /package/dist/{EntityTransferFlowDetail-DY2UZ5VA.js.map → EntityTransferFlowDetail-RSFDF5PB.js.map} +0 -0
  216. /package/dist/{EvaluateBidConfig-I6OIVCXE.js.map → EvaluateBidConfig-WYWY3SSW.js.map} +0 -0
  217. /package/dist/{EvaluateBidFlowDetail-YWCXV4OS.js.map → EvaluateBidFlowDetail-QMSIAFG5.js.map} +0 -0
  218. /package/dist/{EvaluateClaimConfig-Q6CV2ZU4.js.map → EvaluateClaimConfig-FMGZ3UG7.js.map} +0 -0
  219. /package/dist/{GovernanceAuthzExecFlowDetail-GWKPT7QW.js.map → GovernanceAuthzExecFlowDetail-IW76KM4Q.js.map} +0 -0
  220. /package/dist/{GovernanceAuthzGrantFlowDetail-L7EPQQZ6.js.map → GovernanceAuthzGrantFlowDetail-BTCMC2ZN.js.map} +0 -0
  221. /package/dist/{GovernanceAuthzRevokeFlowDetail-X2VQHRCB.js.map → GovernanceAuthzRevokeFlowDetail-7DVXQWXC.js.map} +0 -0
  222. /package/dist/{GovernanceChainVoteFlowDetail-BO3DJNDF.js.map → GovernanceChainVoteFlowDetail-CIBRJPP6.js.map} +0 -0
  223. /package/dist/{GovernanceConfigFlowDetail-FZB4R54G.js.map → GovernanceConfigFlowDetail-6P7GLUT4.js.map} +0 -0
  224. /package/dist/{GovernanceContractExecuteFlowDetail-JHIXCNXS.js.map → GovernanceContractExecuteFlowDetail-4Q32MNXQ.js.map} +0 -0
  225. /package/dist/{GovernanceContractInstantiateFlowDetail-XWSI2HXG.js.map → GovernanceContractInstantiateFlowDetail-GOFRJNS6.js.map} +0 -0
  226. /package/dist/{GovernanceContractManageCw20FlowDetail-5QI3FBNT.js.map → GovernanceContractManageCw20FlowDetail-QYFC2CBY.js.map} +0 -0
  227. /package/dist/{GovernanceContractMigrateFlowDetail-W2DEBKKU.js.map → GovernanceContractMigrateFlowDetail-YS575HJK.js.map} +0 -0
  228. /package/dist/{GovernanceContractUpdateAdminFlowDetail-VZ6245TK.js.map → GovernanceContractUpdateAdminFlowDetail-YNN5VVUN.js.map} +0 -0
  229. /package/dist/{GovernanceCustomMessageFlowDetail-NNTHVM5D.js.map → GovernanceCustomMessageFlowDetail-AP2DYHPG.js.map} +0 -0
  230. /package/dist/{GovernanceDaoAcceptToMarketplaceFlowDetail-EO3CFNLA.js.map → GovernanceDaoAcceptToMarketplaceFlowDetail-WHC2GXB7.js.map} +0 -0
  231. /package/dist/{GovernanceDaoAdminExecFlowDetail-YQCDUW2V.js.map → GovernanceDaoAdminExecFlowDetail-5545VOCJ.js.map} +0 -0
  232. /package/dist/{GovernanceDaoCreateEntityFlowDetail-RSFFRATK.js.map → GovernanceDaoCreateEntityFlowDetail-QKSNQHT3.js.map} +0 -0
  233. /package/dist/{GovernanceDaoJoinFlowDetail-GJWWQPD2.js.map → GovernanceDaoJoinFlowDetail-ZIZA4CHJ.js.map} +0 -0
  234. /package/dist/{GovernanceDaoManageStorageFlowDetail-KGMWUB4Z.js.map → GovernanceDaoManageStorageFlowDetail-V7CNBFD5.js.map} +0 -0
  235. /package/dist/{GovernanceDaoManageSubDaosFlowDetail-3WTI6AX7.js.map → GovernanceDaoManageSubDaosFlowDetail-U6HCZEWB.js.map} +0 -0
  236. /package/dist/{GovernanceDaoUpdateInfoFlowDetail-2DCOJGYV.js.map → GovernanceDaoUpdateInfoFlowDetail-YGVZWXYR.js.map} +0 -0
  237. /package/dist/{GovernanceMemberProposalConfig-LW6KNHVY.js.map → GovernanceMemberProposalConfig-3HKKBDJ5.js.map} +0 -0
  238. /package/dist/{GovernanceMemberProposalFlowDetail-JNO3RPDW.js.map → GovernanceMemberProposalFlowDetail-5DYOTEMZ.js.map} +0 -0
  239. /package/dist/{GovernanceNftBurnFlowDetail-MG3S2DZB.js.map → GovernanceNftBurnFlowDetail-ZHL6NSBB.js.map} +0 -0
  240. /package/dist/{GovernanceNftManageCollectionsFlowDetail-FB5BRSLF.js.map → GovernanceNftManageCollectionsFlowDetail-YKWXV6PI.js.map} +0 -0
  241. /package/dist/{GovernanceNftTransferFlowDetail-27CRQVTA.js.map → GovernanceNftTransferFlowDetail-SQ5ZSKIK.js.map} +0 -0
  242. /package/dist/{GovernanceSettingsProposalConfig-WBOTSKNF.js.map → GovernanceSettingsProposalConfig-IZFFFRHS.js.map} +0 -0
  243. /package/dist/{GovernanceSettingsProposalFlowDetail-W2KXBQM2.js.map → GovernanceSettingsProposalFlowDetail-72OGJWPM.js.map} +0 -0
  244. /package/dist/{GovernanceStakingStakeFlowDetail-Z7MCDZDV.js.map → GovernanceStakingStakeFlowDetail-TQT6JVX5.js.map} +0 -0
  245. /package/dist/{GovernanceStakingStakeToGroupFlowDetail-EC6JGRMB.js.map → GovernanceStakingStakeToGroupFlowDetail-RHW3KT4J.js.map} +0 -0
  246. /package/dist/{GovernanceSubmissionConfigProposalFlowDetail-YHO3F7TI.js.map → GovernanceSubmissionConfigProposalFlowDetail-ELSE6QV6.js.map} +0 -0
  247. /package/dist/{GovernanceTransactionMintFlowDetail-K6PPDCH6.js.map → GovernanceTransactionMintFlowDetail-3I7F3FSC.js.map} +0 -0
  248. /package/dist/{GovernanceTransactionPerformTokenSwapFlowDetail-6PEN4FED.js.map → GovernanceTransactionPerformTokenSwapFlowDetail-5UTYTE3P.js.map} +0 -0
  249. /package/dist/{GovernanceTransactionSendFundsConfig-JRROE44J.js.map → GovernanceTransactionSendFundsConfig-UITDQIEX.js.map} +0 -0
  250. /package/dist/{GovernanceTransactionSendFundsFlowDetail-Z57XAY3D.js.map → GovernanceTransactionSendFundsFlowDetail-FUHTFFYK.js.map} +0 -0
  251. /package/dist/{GovernanceTransactionSendGroupTokenFlowDetail-OSEHM66P.js.map → GovernanceTransactionSendGroupTokenFlowDetail-JEGHRGVA.js.map} +0 -0
  252. /package/dist/{GovernanceTransactionWithdrawTokenSwapFlowDetail-AZFHSIBD.js.map → GovernanceTransactionWithdrawTokenSwapFlowDetail-IGKD3XFX.js.map} +0 -0
  253. /package/dist/{GovernanceValidatorActionsFlowDetail-3YSPIIVG.js.map → GovernanceValidatorActionsFlowDetail-XFJM4T54.js.map} +0 -0
  254. /package/dist/{HarvestConfig-L37MMZE5.js.map → HarvestConfig-MQCRQM6E.js.map} +0 -0
  255. /package/dist/{HarvestFlowDetail-Y2AJWJKR.js.map → HarvestFlowDetail-4AGZTR7Z.js.map} +0 -0
  256. /package/dist/{HttpRequestConfig-C74HRIO5.js.map → HttpRequestConfig-24VT44SK.js.map} +0 -0
  257. /package/dist/{HttpRequestFlowDetail-VWD64O3P.js.map → HttpRequestFlowDetail-LGWILJCS.js.map} +0 -0
  258. /package/dist/{IdentityCreateFlowDetail-CGE66IXY.js.map → IdentityCreateFlowDetail-6UVA3GLT.js.map} +0 -0
  259. /package/dist/{IidCreateFlowDetail-J4PKJMSA.js.map → IidCreateFlowDetail-6DMLKXSP.js.map} +0 -0
  260. /package/dist/{KycVerifyConfig-YPTVDVAM.js.map → KycVerifyConfig-QKU3GYXH.js.map} +0 -0
  261. /package/dist/{KycVerifyFlowDetail-CFWXA3AT.js.map → KycVerifyFlowDetail-MJB5DFB5.js.map} +0 -0
  262. /package/dist/{ListDomainFlowsFlowDetail-PJQCAY3I.js.map → ListDomainFlowsFlowDetail-PDUSV2TD.js.map} +0 -0
  263. /package/dist/{LoadBatchesFlowDetail-TL4TQDZ5.js.map → LoadBatchesFlowDetail-SXLSDRVT.js.map} +0 -0
  264. /package/dist/{MatrixDmConfig-DRY27FAM.js.map → MatrixDmConfig-XCS2HCGZ.js.map} +0 -0
  265. /package/dist/{MatrixRegisterFlowDetail-RXHGTTQF.js.map → MatrixRegisterFlowDetail-7JMBMOTF.js.map} +0 -0
  266. /package/dist/{MemberMultiSelectFlowDetail-N64ZK7GE.js.map → MemberMultiSelectFlowDetail-DLAKXCRC.js.map} +0 -0
  267. /package/dist/{OracleConfig-J3NN2EP4.js.map → OracleConfig-RU6N4JBF.js.map} +0 -0
  268. /package/dist/{OracleConfigureOracleFlowDetail-3ER4XIAB.js.map → OracleConfigureOracleFlowDetail-AET56AV6.js.map} +0 -0
  269. /package/dist/{OracleContractFlowDetail-D2XZYWVG.js.map → OracleContractFlowDetail-4RWSGCLI.js.map} +0 -0
  270. /package/dist/{OracleDeployFlowDetail-TCFIJYP7.js.map → OracleDeployFlowDetail-2HOKGJEO.js.map} +0 -0
  271. /package/dist/{OracleDeploySetupFlowDetail-KMGBPIND.js.map → OracleDeploySetupFlowDetail-AOUCBEJK.js.map} +0 -0
  272. /package/dist/{OracleDeployStartFlowDetail-DTK5PLC5.js.map → OracleDeployStartFlowDetail-5R5O54VE.js.map} +0 -0
  273. /package/dist/{OracleFlowDetail-FEPE3YYU.js.map → OracleFlowDetail-REP3CDHK.js.map} +0 -0
  274. /package/dist/{OraclePromptFlowDetail-2B55RVOO.js.map → OraclePromptFlowDetail-RWGI7Y46.js.map} +0 -0
  275. /package/dist/{OracleStoreConfigFlowDetail-Q6PTB2TR.js.map → OracleStoreConfigFlowDetail-F2E4ZEVA.js.map} +0 -0
  276. /package/dist/{OracleStoreSecretsAndConfigFlowDetail-7U6RI2A2.js.map → OracleStoreSecretsAndConfigFlowDetail-6X4CPXKW.js.map} +0 -0
  277. /package/dist/{OracleStoreSecretsFlowDetail-6HEZJZ3R.js.map → OracleStoreSecretsFlowDetail-DYPIPYIT.js.map} +0 -0
  278. /package/dist/{ProposalCreateConfig-ZQIK6PZB.js.map → ProposalCreateConfig-DRYE2AKJ.js.map} +0 -0
  279. /package/dist/{ProposalCreateFlowDetail-3JNI7S6E.js.map → ProposalCreateFlowDetail-CHIA2XWY.js.map} +0 -0
  280. /package/dist/{ProposalVoteConfig-TZ3FGE4A.js.map → ProposalVoteConfig-7UNWFROZ.js.map} +0 -0
  281. /package/dist/{ProposalVoteFlowDetail-6BOYU4XJ.js.map → ProposalVoteFlowDetail-DSMBVP3E.js.map} +0 -0
  282. /package/dist/{ProtocolSelectFlowDetail-IKYJQZAO.js.map → ProtocolSelectFlowDetail-NTLOLTSO.js.map} +0 -0
  283. /package/dist/{RetireConfig-YKFKGNOR.js.map → RetireConfig-BF2DX5IS.js.map} +0 -0
  284. /package/dist/{RetireFlowDetail-SP5GBJSA.js.map → RetireFlowDetail-LY77O4VE.js.map} +0 -0
  285. /package/dist/{SandboxProvisionFlowDetail-CQ7XZWNA.js.map → SandboxProvisionFlowDetail-QPRFK7N3.js.map} +0 -0
  286. /package/dist/{WalletFundConfig-T5S6B2HH.js.map → WalletFundConfig-QF2D65SA.js.map} +0 -0
  287. /package/dist/{WalletFundFlowDetail-WLQLJS34.js.map → WalletFundFlowDetail-CTWM57AK.js.map} +0 -0
  288. /package/dist/{WalletGenerateAndFundFlowDetail-7LEBWWEA.js.map → WalletGenerateAndFundFlowDetail-TY3HOGEU.js.map} +0 -0
  289. /package/dist/{WalletGenerateFlowDetail-CBAVDW7Z.js.map → WalletGenerateFlowDetail-F5LNH4VY.js.map} +0 -0
  290. /package/dist/{XeroContactCreateConfig-N6YU7YEX.js.map → XeroContactCreateConfig-GTRMV4MO.js.map} +0 -0
  291. /package/dist/{XeroContactCreateFlowDetail-NO65PRXE.js.map → XeroContactCreateFlowDetail-4IFZRJOF.js.map} +0 -0
  292. /package/dist/{XeroInvoiceCreateConfig-VHJMWKY2.js.map → XeroInvoiceCreateConfig-HVMMNUU4.js.map} +0 -0
  293. /package/dist/{XeroInvoiceCreateFlowDetail-UJDEUWH6.js.map → XeroInvoiceCreateFlowDetail-4UPL55DU.js.map} +0 -0
  294. /package/dist/{XeroInvoiceListConfig-CEECA5U7.js.map → XeroInvoiceListConfig-IMXZZTNF.js.map} +0 -0
  295. /package/dist/{XeroInvoiceListFlowDetail-YPU6MFSX.js.map → XeroInvoiceListFlowDetail-SUWMEU7K.js.map} +0 -0
  296. /package/dist/{XeroPaymentCreateConfig-KULFUA66.js.map → XeroPaymentCreateConfig-ONPADVHN.js.map} +0 -0
  297. /package/dist/{XeroPaymentCreateFlowDetail-BRRQJ67R.js.map → XeroPaymentCreateFlowDetail-52FOC77L.js.map} +0 -0
  298. /package/dist/{chunk-JDNOVB6L.js.map → chunk-3S6HH3LV.js.map} +0 -0
  299. /package/dist/{chunk-ZIT2N7CI.js.map → chunk-6332CJVF.js.map} +0 -0
  300. /package/dist/{chunk-RQS3KQLQ.js.map → chunk-66EWPWA5.js.map} +0 -0
  301. /package/dist/{chunk-UW3DNXM7.js.map → chunk-6OBTZWYM.js.map} +0 -0
  302. /package/dist/{chunk-FJ36VM6S.js.map → chunk-7XB6INJ4.js.map} +0 -0
  303. /package/dist/{chunk-QSUE3ZFB.js.map → chunk-AZGVSR3T.js.map} +0 -0
  304. /package/dist/{chunk-MQAJXYIS.js.map → chunk-DMWXSWLO.js.map} +0 -0
  305. /package/dist/{chunk-C376YPPE.js.map → chunk-HPHWYDGB.js.map} +0 -0
  306. /package/dist/{chunk-JWC4VVY7.js.map → chunk-JCI46234.js.map} +0 -0
  307. /package/dist/{chunk-A7L3NJK6.js.map → chunk-KIAAAFZF.js.map} +0 -0
  308. /package/dist/{chunk-MY22PTP4.js.map → chunk-LMQT3VUE.js.map} +0 -0
  309. /package/dist/{chunk-RV7QJFSE.js.map → chunk-M5ELO3A5.js.map} +0 -0
  310. /package/dist/{chunk-RETGBEFM.js.map → chunk-M7XUQCKC.js.map} +0 -0
  311. /package/dist/{chunk-6JOBSAZF.js.map → chunk-P365VW4X.js.map} +0 -0
  312. /package/dist/{chunk-SRSVMD6E.js.map → chunk-PCRDF4BQ.js.map} +0 -0
  313. /package/dist/{chunk-SZRWCNGA.js.map → chunk-PNS4Y2PQ.js.map} +0 -0
  314. /package/dist/{chunk-J6AWMFEF.js.map → chunk-PWPTKUNE.js.map} +0 -0
  315. /package/dist/{chunk-S2ETTOE5.js.map → chunk-SAOQXHK6.js.map} +0 -0
  316. /package/dist/{chunk-EH7EYO4N.js.map → chunk-SI2AUBY5.js.map} +0 -0
  317. /package/dist/{chunk-CMG6TZKH.js.map → chunk-TGRBWL3B.js.map} +0 -0
  318. /package/dist/{chunk-76VIZL5D.js.map → chunk-TGTS2R2O.js.map} +0 -0
  319. /package/dist/{chunk-JK6RAKE3.js.map → chunk-UOYPASUI.js.map} +0 -0
  320. /package/dist/{chunk-L7WHIPGC.js.map → chunk-VOBXFJLM.js.map} +0 -0
  321. /package/dist/{chunk-X23SZR5N.js.map → chunk-XUJPJRLW.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/mantine/blocks/action/actionTypes/formSubmit/FormSubmitFlowDetail.tsx"],"sourcesContent":["import { useRunRuntimeReader } from '@/mantine/hooks/useRunRuntimeReader';\nimport React, { useCallback, useEffect, useMemo, useState } from 'react';\nimport { Loader, Stack, Text } from '@mantine/core';\nimport { DismissibleAlert as Alert } from '@/mantine/components/Base/DismissibleAlert';\nimport { SurveyModel } from '@ixo/surveys';\nimport { StableSurvey } from '@/mantine/components/StableSurvey';\nimport { surveyTheme } from '@/mantine/blocks/claim/flow/theme';\nimport { useBlocknoteHandlers } from '@/mantine/context/BlocknoteContext';\nimport { resolveReferences } from '@/mantine/utils/referenceResolver';\nimport type { ActionTypeFlowProps } from '../../actionTypeUI';\nimport { parseFormSubmitActionInputs } from './types';\nimport { actionAlertStyles } from '../../alertStyles';\n\ninterface SkillContext {\n cid: string;\n name?: string;\n}\n\nfunction parsePrimarySkill(rawSkill: unknown): SkillContext | null {\n const coerce = (candidate: any): SkillContext | null => {\n if (!candidate || typeof candidate !== 'object') return null;\n const cid = String(candidate.cid || '').trim();\n const name = String(candidate.name || '').trim();\n if (!cid) return null;\n return name ? { cid, name } : { cid };\n };\n\n if (!rawSkill) return null;\n\n if (typeof rawSkill === 'object') {\n if (Array.isArray(rawSkill)) {\n for (const entry of rawSkill) {\n const skill = coerce(entry);\n if (skill) return skill;\n }\n return null;\n }\n return coerce(rawSkill);\n }\n\n if (typeof rawSkill === 'string') {\n const trimmed = rawSkill.trim();\n if (!trimmed) return null;\n try {\n const parsed = JSON.parse(trimmed);\n return parsePrimarySkill(parsed);\n } catch {\n return null;\n }\n }\n\n return null;\n}\n\nfunction buildCompanionPrompt(params: { skill: SkillContext; blockTitle: string; blockDescription: string; answers: Record<string, any> }): string {\n const answersJson = JSON.stringify(params.answers || {}, null, 2);\n return [\n 'Use the skill with this form context.',\n 'IMPORTANT: First read the flow context and settings — the flow may contain parameters required by the skill. Also review all blocks in the flow to understand the basic workflow before executing.',\n `Skill name: ${params.skill.name || '(not provided)'}`,\n `Skill CID: ${params.skill.cid}`,\n `Action block title: ${params.blockTitle || 'Form Submit Action'}`,\n `Action block description: ${params.blockDescription || 'Complete the form to execute this action.'}`,\n `Form answers JSON:\\n${answersJson}`,\n ].join('\\n');\n}\n\nexport const FormSubmitFlowDetail: React.FC<ActionTypeFlowProps> = ({ inputs, editor, block, runtime, isDisabled, executeAction }) => {\n const handlers = useBlocknoteHandlers();\n\n const parsed = useMemo(() => parseFormSubmitActionInputs(inputs), [inputs]);\n const editorDocument = editor?.document || [];\n const runtimeReader = useRunRuntimeReader(editor);\n const resolveOpts = useMemo(() => ({ yRuntime: runtimeReader }), [runtimeReader]);\n const resolvedSchemaString = useMemo(() => resolveReferences(parsed.surveySchema || '', editorDocument, resolveOpts).trim(), [parsed.surveySchema, editorDocument, resolveOpts]);\n\n const [submitting, setSubmitting] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const parsedSchema = useMemo(() => {\n if (!resolvedSchemaString) return null;\n try {\n const schema = JSON.parse(resolvedSchemaString);\n if (!schema || typeof schema !== 'object' || Array.isArray(schema)) return null;\n return schema;\n } catch {\n return null;\n }\n }, [resolvedSchemaString]);\n\n const isCompleted = runtime.state === 'completed';\n const savedAnswers = isCompleted && runtime.output?.answers && typeof runtime.output.answers === 'object' ? (runtime.output.answers as Record<string, any>) : null;\n\n const surveyModel = useMemo(() => {\n if (!parsedSchema) return null;\n const model = new SurveyModel(parsedSchema);\n model.applyTheme(surveyTheme);\n model.showQuestionNumbers = 'off';\n model.questionsOnPageMode = 'singlePage';\n model.completeText = 'Execute';\n if (savedAnswers) {\n model.data = savedAnswers;\n model.mode = 'display';\n model.showCompleteButton = false;\n } else if (isDisabled || submitting) {\n model.mode = 'display';\n model.showCompleteButton = false;\n }\n return model;\n }, [parsedSchema, isDisabled, submitting, savedAnswers]);\n\n const handleSurveyComplete = useCallback(\n async (sender: SurveyModel) => {\n if (isDisabled || submitting) return;\n\n const actionType = String(block?.props?.actionType || 'qi/form.submit');\n if (!executeAction) {\n setError(`${actionType} executor is unavailable`);\n return;\n }\n\n setSubmitting(true);\n setError(null);\n\n try {\n const skill = parsePrimarySkill(block?.props?.skill);\n if (skill && typeof handlers?.askCompanion === 'function') {\n const prompt = buildCompanionPrompt({\n skill,\n blockTitle: String(block?.props?.title || ''),\n blockDescription: String(block?.props?.description || ''),\n answers: (sender.data || {}) as Record<string, any>,\n });\n handlers.askCompanion(prompt).catch((askError) => {\n console.error('askCompanion failed during form submit execution', askError);\n });\n }\n\n const outcome = await executeAction({\n runtimeInputs: { answers: sender.data || {} },\n });\n\n if (!outcome.success) {\n throw new Error(outcome.error || 'Form submit execution failed');\n }\n } catch (err) {\n const message = err instanceof Error ? err.message : 'Failed to execute form submit';\n setError(message);\n } finally {\n setSubmitting(false);\n }\n },\n [block, executeAction, handlers, isDisabled, submitting]\n );\n\n useEffect(() => {\n if (!surveyModel) return undefined;\n surveyModel.onComplete.add(handleSurveyComplete);\n return () => {\n surveyModel.onComplete.remove(handleSurveyComplete);\n };\n }, [surveyModel, handleSurveyComplete]);\n\n const statusMessage = runtime.state === 'completed' ? 'Last execution completed.' : submitting ? 'Executing...' : null;\n\n return (\n <Stack gap=\"md\">\n {!resolvedSchemaString ? (\n <Alert color=\"yellow\" styles={actionAlertStyles}>\n Configure Survey Schema JSON in template mode before running this action.\n </Alert>\n ) : !parsedSchema ? (\n <Alert color=\"red\" styles={actionAlertStyles}>\n Survey schema is invalid JSON. Fix it in template mode.\n </Alert>\n ) : (\n <StableSurvey model={surveyModel} />\n )}\n\n {statusMessage && (\n <Stack gap={4}>\n {submitting && <Loader size=\"xs\" />}\n <Text size=\"xs\" c=\"dimmed\">\n {statusMessage}\n </Text>\n </Stack>\n )}\n\n {error && (\n <Alert color=\"red\" styles={actionAlertStyles}>\n {error}\n </Alert>\n )}\n {runtime.error?.message && (\n <Alert color=\"red\" styles={actionAlertStyles}>\n {runtime.error.message}\n </Alert>\n )}\n </Stack>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,OAAO,SAAS,aAAa,WAAW,SAAS,gBAAgB;AACjE,SAAS,QAAQ,OAAO,YAAY;AAEpC,SAAS,mBAAmB;AAc5B,SAAS,kBAAkB,UAAwC;AACjE,QAAM,SAAS,CAAC,cAAwC;AACtD,QAAI,CAAC,aAAa,OAAO,cAAc,SAAU,QAAO;AACxD,UAAM,MAAM,OAAO,UAAU,OAAO,EAAE,EAAE,KAAK;AAC7C,UAAM,OAAO,OAAO,UAAU,QAAQ,EAAE,EAAE,KAAK;AAC/C,QAAI,CAAC,IAAK,QAAO;AACjB,WAAO,OAAO,EAAE,KAAK,KAAK,IAAI,EAAE,IAAI;AAAA,EACtC;AAEA,MAAI,CAAC,SAAU,QAAO;AAEtB,MAAI,OAAO,aAAa,UAAU;AAChC,QAAI,MAAM,QAAQ,QAAQ,GAAG;AAC3B,iBAAW,SAAS,UAAU;AAC5B,cAAM,QAAQ,OAAO,KAAK;AAC1B,YAAI,MAAO,QAAO;AAAA,MACpB;AACA,aAAO;AAAA,IACT;AACA,WAAO,OAAO,QAAQ;AAAA,EACxB;AAEA,MAAI,OAAO,aAAa,UAAU;AAChC,UAAM,UAAU,SAAS,KAAK;AAC9B,QAAI,CAAC,QAAS,QAAO;AACrB,QAAI;AACF,YAAM,SAAS,KAAK,MAAM,OAAO;AACjC,aAAO,kBAAkB,MAAM;AAAA,IACjC,QAAQ;AACN,aAAO;AAAA,IACT;AAAA,EACF;AAEA,SAAO;AACT;AAEA,SAAS,qBAAqB,QAAqH;AACjJ,QAAM,cAAc,KAAK,UAAU,OAAO,WAAW,CAAC,GAAG,MAAM,CAAC;AAChE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,eAAe,OAAO,MAAM,QAA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Q,IAAI,UAAU;AACrD,iBAAS,OAAO;AAAA,MAClB,UAAE;AACA,sBAAc,KAAK;AAAA,MACrB;AAAA,IACF;AAAA,IACA,CAAC,OAAO,eAAe,UAAU,YAAY,UAAU;AAAA,EACzD;AAEA,YAAU,MAAM;AACd,QAAI,CAAC,YAAa,QAAO;AACzB,gBAAY,WAAW,IAAI,oBAAoB;AAC/C,WAAO,MAAM;AACX,kBAAY,WAAW,OAAO,oBAAoB;AAAA,IACpD;AAAA,EACF,GAAG,CAAC,aAAa,oBAAoB,CAAC;AAEtC,QAAM,gBAAgB,QAAQ,UAAU,cAAc,8BAA8B,aAAa,iBAAiB;AAElH,SACE,oCAAC,SAAM,KAAI,QACR,CAAC,uBACA,oCAAC,oBAAM,OAAM,UAAS,QAAQ,qBAAmB,2EAEjD,IACE,CAAC,eACH,oCAAC,oBAAM,OAAM,OAAM,QAAQ,qBAAmB,yDAE9C,IAEA,oCAAC,gBAAa,OAAO,aAAa,GAGnC,iBACC,oCAAC,SAAM,KAAK,KACT,cAAc,oCAAC,UAAO,MAAK,MAAK,GACjC,oCAAC,QAAK,MAAK,MAAK,GAAE,YACf,aACH,CACF,GAGD,SACC,oCAAC,oBAAM,OAAM,OAAM,QAAQ,qBACxB,KACH,GAED,QAAQ,OAAO,WACd,oCAAC,oBAAM,OAAM,OAAM,QAAQ,qBACxB,QAAQ,MAAM,OACjB,CAEJ;AAEJ;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/core/lib/ucanDelegationStore.ts","../src/core/lib/ucan/requestProofs.ts","../src/core/lib/ucan/signedChain.ts","../src/core/services/ucanService.ts","../src/core/lib/ucan/verificationEnv.ts","../src/core/lib/ucan/flowAuthorityIndex.ts","../src/core/lib/ucan/receiptVerifier.ts"],"sourcesContent":["import type { Map as YMap } from 'yjs';\nimport type { StoredDelegation } from '../types/ucan';\n\nconst ROOT_DELEGATION_KEY = '__root__';\nconst STORE_VERSION_KEY = '__version__';\nconst CURRENT_VERSION = 2;\n\n/**\n * Stored entry in Y.Map\n */\ninterface StoredEntry {\n v: number;\n data: StoredDelegation;\n}\n\n/**\n * UCAN Delegation Store — stores CAR-serialized delegations\n */\nexport interface UcanDelegationStore {\n // Core operations\n get: (cid: string) => StoredDelegation | null;\n set: (delegation: StoredDelegation) => void;\n remove: (cid: string) => void;\n has: (cid: string) => boolean;\n\n // Root management\n getRoot: () => StoredDelegation | null;\n setRootCid: (cid: string) => void;\n getRootCid: () => string | null;\n\n // Query operations\n getAll: () => StoredDelegation[];\n getByAudience: (audienceDid: string) => StoredDelegation[];\n getByIssuer: (issuerDid: string) => StoredDelegation[];\n findByCapability: (can: string, withUri: string) => StoredDelegation[];\n}\n\nfunction normalizeAbility(value: string): string {\n const trimmed = value.trim();\n const lastDot = trimmed.lastIndexOf('.');\n return !trimmed.includes('/') && lastDot > 0 ? `${trimmed.slice(0, lastDot)}/${trimmed.slice(lastDot + 1)}` : trimmed;\n}\n\nfunction abilityCovers(granted: string, requested: string): boolean {\n const pattern = normalizeAbility(granted);\n const target = normalizeAbility(requested);\n if (pattern === '*' || pattern === target) return true;\n return pattern.endsWith('/*') && target.startsWith(pattern.slice(0, -1));\n}\n\nfunction resourceCovers(granted: string, requested: string): boolean {\n if (granted === '*' || granted === requested) return true;\n return granted.endsWith('*') && requested.startsWith(granted.slice(0, -1));\n}\n\nfunction canonicalCaveat(value: unknown): string {\n if (!value || typeof value !== 'object') return JSON.stringify(value ?? null);\n if (Array.isArray(value)) return `[${value.map(canonicalCaveat).join(',')}]`;\n return `{${Object.entries(value as Record<string, unknown>)\n .sort(([left], [right]) => left.localeCompare(right))\n .map(([key, entry]) => `${JSON.stringify(key)}:${canonicalCaveat(entry)}`)\n .join(',')}}`;\n}\n\n/** A stored grant covers a request only when ability, resource, and caveats all cover it. */\nexport function ucanCapabilityCovers(granted: StoredDelegation['capabilities'][number], requested: StoredDelegation['capabilities'][number]): boolean {\n if (!abilityCovers(granted.can, requested.can) || !resourceCovers(granted.with, requested.with)) return false;\n if (granted.nb === undefined) return true;\n return canonicalCaveat(granted.nb) === canonicalCaveat(requested.nb);\n}\n\nconst isValidEntry = (value: unknown): value is StoredEntry => {\n if (!value || typeof value !== 'object') return false;\n const entry = value as StoredEntry;\n return entry.v === CURRENT_VERSION && entry.data !== undefined;\n};\n\nconst isReservedKey = (key: string): boolean => key === ROOT_DELEGATION_KEY || key === STORE_VERSION_KEY;\n\n/**\n * Create a UCAN delegation store backed by Y.Map\n */\nexport const createUcanDelegationStore = (yMap: YMap<unknown>): UcanDelegationStore => {\n const get = (cid: string): StoredDelegation | null => {\n if (isReservedKey(cid)) return null;\n const raw = yMap.get(cid);\n if (!raw) return null;\n if (isValidEntry(raw)) return raw.data;\n return null;\n };\n\n const set = (delegation: StoredDelegation): void => {\n const entry: StoredEntry = { v: CURRENT_VERSION, data: delegation };\n yMap.set(delegation.cid, entry);\n };\n\n const remove = (cid: string): void => {\n yMap.delete(cid);\n };\n\n const has = (cid: string): boolean => {\n return yMap.has(cid) && !isReservedKey(cid);\n };\n\n const getRoot = (): StoredDelegation | null => {\n const rootCid = yMap.get(ROOT_DELEGATION_KEY) as string | undefined;\n if (!rootCid) return null;\n return get(rootCid);\n };\n\n const setRootCid = (cid: string): void => {\n yMap.set(ROOT_DELEGATION_KEY, cid);\n };\n\n const getRootCid = (): string | null => {\n return (yMap.get(ROOT_DELEGATION_KEY) as string) || null;\n };\n\n const getAll = (): StoredDelegation[] => {\n const delegations: StoredDelegation[] = [];\n yMap.forEach((value, key) => {\n if (isReservedKey(key)) return;\n if (isValidEntry(value)) {\n delegations.push(value.data);\n }\n });\n return delegations;\n };\n\n const getByAudience = (audienceDid: string): StoredDelegation[] => {\n return getAll().filter((d) => d.audienceDid === audienceDid);\n };\n\n const getByIssuer = (issuerDid: string): StoredDelegation[] => {\n return getAll().filter((d) => d.issuerDid === issuerDid);\n };\n\n const findByCapability = (can: string, withUri: string): StoredDelegation[] => {\n return getAll().filter((d) => d.capabilities.some((capability) => ucanCapabilityCovers(capability, { can, with: withUri })));\n };\n\n return {\n get,\n set,\n remove,\n has,\n getRoot,\n setRootCid,\n getRootCid,\n getAll,\n getByAudience,\n getByIssuer,\n findByCapability,\n };\n};\n\n/**\n * Create an in-memory UCAN delegation store (for testing)\n */\nexport const createMemoryUcanDelegationStore = (): UcanDelegationStore => {\n const store = new Map<string, unknown>();\n\n const get = (cid: string): StoredDelegation | null => {\n if (isReservedKey(cid)) return null;\n const raw = store.get(cid);\n if (!raw) return null;\n if (isValidEntry(raw)) return raw.data;\n return null;\n };\n\n const set = (delegation: StoredDelegation): void => {\n const entry: StoredEntry = { v: CURRENT_VERSION, data: delegation };\n store.set(delegation.cid, entry);\n };\n\n const remove = (cid: string): void => {\n store.delete(cid);\n };\n\n const has = (cid: string): boolean => {\n return store.has(cid) && !isReservedKey(cid);\n };\n\n const getRoot = (): StoredDelegation | null => {\n const rootCid = store.get(ROOT_DELEGATION_KEY) as string | undefined;\n if (!rootCid) return null;\n return get(rootCid);\n };\n\n const setRootCid = (cid: string): void => {\n store.set(ROOT_DELEGATION_KEY, cid);\n };\n\n const getRootCid = (): string | null => {\n return (store.get(ROOT_DELEGATION_KEY) as string) || null;\n };\n\n const getAll = (): StoredDelegation[] => {\n const delegations: StoredDelegation[] = [];\n store.forEach((value, key) => {\n if (isReservedKey(key)) return;\n if (isValidEntry(value)) {\n delegations.push(value.data);\n }\n });\n return delegations;\n };\n\n const getByAudience = (audienceDid: string): StoredDelegation[] => {\n return getAll().filter((d) => d.audienceDid === audienceDid);\n };\n\n const getByIssuer = (issuerDid: string): StoredDelegation[] => {\n return getAll().filter((d) => d.issuerDid === issuerDid);\n };\n\n const findByCapability = (can: string, withUri: string): StoredDelegation[] => {\n return getAll().filter((d) => d.capabilities.some((capability) => ucanCapabilityCovers(capability, { can, with: withUri })));\n };\n\n return {\n get,\n set,\n remove,\n has,\n getRoot,\n setRootCid,\n getRootCid,\n getAll,\n getByAudience,\n getByIssuer,\n findByCapability,\n };\n};\n","/**\n * Requester proofs: who asked for something the flow-manager does (contract §1).\n *\n * When a person starts or closes a session, asks for a step to be (re)run,\n * answers an input request, or arms a schedule, the flow-manager acts on it\n * later, as itself. Until now nothing recorded who asked in a form anyone\n * could check. Each such request is now a UCAN invocation signed by the\n * requester, addressed to the flow-manager, exercising exactly the capability\n * the request needs, with the request's details bound in its signed facts and\n * a five-minute expiry. It is stored in the Y.Doc map `qi.flow.requests`,\n * keyed by the invocation's CID, and the thing it authorizes points back at\n * it by `requestId`.\n */\nimport type { Doc as YDoc } from 'yjs';\n\nimport type { UcanService } from '../../services/ucanService';\nimport type { UcanCapability } from '../../types/ucan';\nimport { digestCanonicalJson, type CanonicalJsonValue } from '../flowEngine/vnext/canonical';\nimport { getRunMeta, resetActionState } from '../flowEngine/runs';\n\nexport const FLOW_REQUESTS_MAP_KEY = 'qi.flow.requests';\n\nexport type FlowRequestKind = 'run.start' | 'run.close' | 'step.request' | 'input.respond' | 'schedule.arm';\n\nexport interface FlowRequestRecordV1 {\n v: 1;\n requestId: string;\n kind: FlowRequestKind;\n /** '' for a schedule arm, which is not about a run. */\n runId: string;\n stepId?: string;\n requesterDid: string;\n invocationCid: string;\n /** Base64 CAR, including the proof blocks. */\n invocation: string;\n createdAt: number;\n}\n\n/** The signed facts object (contract §1). */\nexport interface FlowRequestFactsV1 {\n type: 'qi.flow.request';\n v: 1;\n kind: FlowRequestKind;\n roomId: string;\n docId: string;\n /** Absent for a schedule arm. */\n runId?: string;\n stepId?: string;\n defHash: string;\n inputDigest?: string;\n requestId: string;\n answerDigest?: string;\n requestEventId?: string;\n scheduleId?: string;\n scheduleRevision?: number;\n nonce: string;\n}\n\nexport interface CreateFlowRequestParams {\n kind: FlowRequestKind;\n requesterDid: string;\n /** The flow-manager's ORACLE_DID: the audience of every request. */\n flowManagerDid: string;\n roomId: string;\n docId: string;\n /** Required for every kind but `schedule.arm`. */\n runId?: string;\n stepId?: string;\n /** Hash of the flow definition the request was made against. */\n defHash: string;\n /** Inputs the request binds. Digested as `sha256:<hex>` of their RFC 8785 JSON. */\n input?: unknown;\n answerDigest?: string;\n requestEventId?: string;\n scheduleId?: string;\n scheduleRevision?: number;\n pin: string;\n /** Defaults to a fresh random id. */\n requestId?: string;\n now?: () => number;\n}\n\n/** The one capability each kind of request exercises (contract §1). */\nexport function capabilityForRequest(kind: FlowRequestKind, docId: string, stepId?: string): UcanCapability {\n const flow = `ixo:flow:${docId}`;\n switch (kind) {\n case 'run.start':\n return { can: 'flow/run.start', with: flow };\n case 'run.close':\n return { can: 'flow/run.close', with: flow };\n case 'schedule.arm':\n return { can: 'flow/run.start-scheduled', with: flow };\n case 'step.request':\n case 'input.respond':\n if (!stepId) throw new Error(`A ${kind} request needs the step it is about.`);\n return { can: 'flow/block/execute', with: `${flow}:${stepId}` };\n }\n}\n\n/** `sha256:<hex>` of the value's RFC 8785 canonical JSON — what `inputDigest` and `answerDigest` hold. */\nexport function digestRequestValue(value: unknown): Promise<string> {\n return digestCanonicalJson(JSON.parse(JSON.stringify(value ?? null)) as CanonicalJsonValue);\n}\n\n/**\n * `answerDigest` for an input response: the digest of the whole\n * `ixo.flow.work.input.response` content EXCEPT its `authorization` key\n * (which carries this very invocation, contract §7.1).\n */\nexport function digestInputResponse(content: Record<string, unknown>): Promise<string> {\n const { authorization: _authorization, ...rest } = content;\n return digestRequestValue(rest);\n}\n\nfunction randomRequestId(): string {\n const bytes = new Uint8Array(16);\n globalThis.crypto.getRandomValues(bytes);\n return `req-${Array.from(bytes, (byte) => byte.toString(16).padStart(2, '0')).join('')}`;\n}\n\n/**\n * Sign a request as its requester. The service refuses a requester who does\n * not hold the capability (checked from signed grants) and verifies the\n * invocation it minted before returning it.\n */\nexport async function createFlowRequest(ucanService: UcanService, params: CreateFlowRequestParams): Promise<FlowRequestRecordV1> {\n if (!params.flowManagerDid.startsWith('did:')) throw new Error('The flow-manager is not known, so this request cannot be addressed to it.');\n if (params.kind !== 'schedule.arm' && !params.runId) throw new Error(`A ${params.kind} request needs the run it is about.`);\n if (params.kind === 'schedule.arm' && (!params.scheduleId || params.scheduleRevision === undefined)) {\n throw new Error('A schedule arm request needs the schedule and its current revision.');\n }\n const requestId = params.requestId ?? randomRequestId();\n const capability = capabilityForRequest(params.kind, params.docId, params.stepId);\n const facts: Omit<FlowRequestFactsV1, 'nonce'> = {\n type: 'qi.flow.request',\n v: 1,\n kind: params.kind,\n roomId: params.roomId,\n docId: params.docId,\n ...(params.runId ? { runId: params.runId } : {}),\n ...(params.stepId ? { stepId: params.stepId } : {}),\n defHash: params.defHash,\n ...(params.input !== undefined ? { inputDigest: await digestRequestValue(params.input) } : {}),\n requestId,\n ...(params.answerDigest ? { answerDigest: params.answerDigest } : {}),\n ...(params.requestEventId ? { requestEventId: params.requestEventId } : {}),\n ...(params.scheduleId ? { scheduleId: params.scheduleId } : {}),\n ...(params.scheduleRevision !== undefined ? { scheduleRevision: params.scheduleRevision } : {}),\n };\n const result = await ucanService.createAndValidateInvocation(\n {\n invokerDid: params.requesterDid,\n invokerType: 'user',\n audience: params.flowManagerDid,\n capability,\n proofs: [],\n facts: facts as unknown as Record<string, unknown>,\n pin: params.pin,\n },\n params.docId,\n params.stepId\n );\n if (!result.valid || !result.cid || !result.invocation) {\n throw new Error(result.error || 'Your request could not be signed.');\n }\n return {\n v: 1,\n requestId,\n kind: params.kind,\n runId: params.runId ?? '',\n ...(params.stepId ? { stepId: params.stepId } : {}),\n requesterDid: params.requesterDid,\n invocationCid: result.cid,\n invocation: result.invocation,\n createdAt: (params.now ?? Date.now)(),\n };\n}\n\nexport function writeFlowRequest(yDoc: YDoc, record: FlowRequestRecordV1): void {\n yDoc.getMap<FlowRequestRecordV1>(FLOW_REQUESTS_MAP_KEY).set(record.invocationCid, record);\n}\n\nexport function readFlowRequest(yDoc: YDoc, requestId: string): FlowRequestRecordV1 | undefined {\n let found: FlowRequestRecordV1 | undefined;\n yDoc.getMap<FlowRequestRecordV1>(FLOW_REQUESTS_MAP_KEY).forEach((record) => {\n if (!found && record && typeof record === 'object' && record.requestId === requestId) found = record;\n });\n return found;\n}\n\n/**\n * A run start/close proof signer for `startRun` / `migrateFlowToSessions` /\n * `closeRun` / `cancelRun` (`requestProof`). The PIN is asked for only when\n * the signer needs it, and only once the run id is known.\n */\nexport function lifecycleRequestProof(options: {\n ucanService: UcanService;\n kind: 'run.start' | 'run.close';\n requesterDid: string;\n flowManagerDid: string;\n roomId: string;\n docId: string;\n /** Resolve the PIN to sign with ('' when a signer is already unlocked). */\n getPin: () => Promise<string>;\n}): (context: { runId: string; defHash: string }) => Promise<FlowRequestRecordV1> {\n return async ({ runId, defHash }) =>\n options.ucanService.createRequestInvocation({\n kind: options.kind,\n requesterDid: options.requesterDid,\n flowManagerDid: options.flowManagerDid,\n roomId: options.roomId,\n docId: options.docId,\n runId,\n defHash,\n pin: await options.getPin(),\n });\n}\n\n/**\n * Ask for a step to be run again (retry / reset) as a signed `step.request`\n * (contract §1). The step is reset to idle in the run with `requestId`\n * pointing at the request, so the flow-manager picks it up on the word of the\n * person who asked — and only if that person is allowed on the step (the\n * service refuses to sign otherwise). `input`, when given, is bound by\n * `inputDigest` (decision 4: only manual steps take requested inputs).\n */\nexport async function requestStepRun(\n yDoc: YDoc,\n params: {\n ucanService: UcanService;\n runId: string;\n stepId: string;\n requesterDid: string;\n flowManagerDid: string;\n roomId: string;\n pin: string;\n input?: unknown;\n defHash?: string;\n }\n): Promise<FlowRequestRecordV1> {\n const docId = yDoc.getMap('root').get('doc_id');\n if (typeof docId !== 'string' || !docId) throw new Error('The flow has no id yet, so a step request cannot be signed for it.');\n const record = await createFlowRequest(params.ucanService, {\n kind: 'step.request',\n requesterDid: params.requesterDid,\n flowManagerDid: params.flowManagerDid,\n roomId: params.roomId,\n docId,\n runId: params.runId,\n stepId: params.stepId,\n defHash: params.defHash ?? getRunMeta(yDoc, params.runId)?.manifest?.defHash ?? '',\n ...(params.input !== undefined ? { input: params.input } : {}),\n pin: params.pin,\n });\n yDoc.transact(() => {\n writeFlowRequest(yDoc, record);\n resetActionState(yDoc, params.runId, params.stepId, { state: 'idle', requestId: record.requestId });\n });\n return record;\n}\n","/**\n * Verify flow authority from the SIGNED UCAN CAR, never from the JSON copy.\n *\n * Every grant in the `delegations` map and every receipt in the `invocations`\n * map is stored twice: once as a signed CAR and once as JSON fields\n * (`issuerDid`, `audienceDid`, `capabilities`, `expiration`, `proofCids`)\n * written next to it for display. Anyone who can write to the room can edit\n * the JSON. Only the CAR is signed, so this module reads the CAR and nothing\n * else: a record with no CAR, or whose CAR has a different CID from the key\n * it is stored under, proves nothing and is refused.\n *\n * The chain must lead back to the flow owner, which is the Matrix room\n * creator (see `flowOwner.ts`), never the `root.flowOwnerDid` field.\n *\n * Two time modes:\n * - present (`at` omitted): uses `@ixo/ucan`'s validator, the same code the\n * services use, with an expiry required and revocation checked fail-closed.\n * - past (`at` given): the validator checks `exp` against the wall clock, so\n * a receipt signed yesterday with a 5-minute expiry could never pass it. The\n * past path verifies the same things itself — every signature against the\n * issuer's resolved keys, every link, `nbf <= at < exp` on every node — and\n * reports revocation separately, because \"was it valid when it ran\" and \"is\n * it still valid\" are different questions the step panel shows apart.\n */\nimport { createUCANValidator, defineCapability, ed25519, type DIDKeyResolver, type RevocationChecker } from '@ixo/ucan';\nimport { Delegation as UcantoDelegation, UCAN } from '@ucanto/core';\n\nimport { normalizeDid } from './normalizeDid';\n\nexport interface UcanVerificationEnv {\n /** Resolves did:ixo (and other non-did:key) DIDs to their did:key verification keys. */\n didResolver?: DIDKeyResolver;\n /**\n * Asked about every CID in a chain. Required: without it nothing verifies,\n * because a revoked grant must never read as allowed.\n */\n revocationChecker?: RevocationChecker;\n}\n\nexport type ChainFailureCode =\n | 'MISSING_CAR'\n | 'INVALID_FORMAT'\n | 'CID_MISMATCH'\n | 'NO_OWNER'\n | 'WRONG_AUDIENCE'\n | 'WRONG_INVOKER'\n | 'BROKEN_LINK'\n | 'NOT_ROOTED_AT_OWNER'\n | 'EXCEEDS_PARENT'\n | 'CAPABILITY_NOT_COVERED'\n | 'FACTS_MISMATCH'\n | 'INVALID_SIGNATURE'\n | 'EXPIRED'\n | 'NOT_YET_VALID'\n | 'NO_EXPIRATION'\n | 'NO_TIME_ANCHOR'\n | 'REVOKED'\n | 'REVOCATION_CHECK_FAILED'\n | 'NO_REVOCATION_CHECKER'\n | 'UNAUTHORIZED';\n\nexport interface ChainFailure {\n ok: false;\n code: ChainFailureCode;\n /** Plain words, shown to people. */\n reason: string;\n}\n\nexport interface SignedCapability {\n can: string;\n with: string;\n nb?: Record<string, unknown>;\n}\n\nexport interface VerifiedGrant {\n cid: string;\n issuerDid: string;\n audienceDid: string;\n /** Read off the signed CAR. */\n capabilities: SignedCapability[];\n /** Earliest `exp` across the signed chain, epoch milliseconds. Undefined only on the past path for grants minted without one. */\n expiresAt?: number;\n /** DIDs from the owner (first) to this grant's issuer (last). */\n proofChain: string[];\n /** CIDs of the verified chain, parents first, this grant last. */\n proofChainCids: string[];\n}\n\nexport type GrantVerdict = { ok: true; grant: VerifiedGrant; revokedNow?: string } | ChainFailure;\n\nexport interface VerifiedInvocation {\n cid: string;\n invokerDid: string;\n audienceDid: string;\n capability: SignedCapability;\n facts: Record<string, unknown>[];\n /** Epoch milliseconds, or undefined for legacy receipts minted with no expiry. */\n expiresAt?: number;\n /** Earliest expiry of the grants it was made under (not the invocation itself), epoch ms; undefined when none expires. */\n grantsExpireAt?: number;\n proofChain: string[];\n proofChainCids: string[];\n}\n\nexport type InvocationVerdict =\n | {\n ok: true;\n invocation: VerifiedInvocation;\n /** Set on the past path when a CID in the chain has been revoked since. */\n revokedNow?: string;\n /** Set on the past path for legacy receipts with no `exp`: signatures check out, but the time is only the unsigned record's word. */\n noTimeAnchor?: boolean;\n }\n | ChainFailure;\n\nexport interface VerifyGrantOptions {\n /** The map key the record is stored under. The CAR's own CID must equal it. */\n cid: string;\n actorDid: string;\n ownerDid: string;\n required: { can: string; with: string };\n env: UcanVerificationEnv;\n /** Epoch ms. Omit for \"valid right now\". */\n at?: number;\n /**\n * 'exercise' (default): the grant must name the resource exactly or with a\n * trailing `*`, as the flow-manager requires. 'hierarchical': a grant on a\n * resource also covers what is addressed beneath it with `:` — used only to\n * recognise the owner's own `flow/*` root.\n */\n coverage?: 'exercise' | 'hierarchical';\n}\n\nexport interface VerifyInvocationOptions {\n cid: string;\n expectedAudience: string;\n ownerDid: string;\n /** The invoker the record claims. When given, the signed issuer must be this DID. */\n actorDid?: string;\n required: { can: string; with: string };\n /** Every key here must appear with the same value in one signed fact object. */\n expectedFacts?: Record<string, unknown>;\n env: UcanVerificationEnv;\n at?: number;\n /**\n * The flow-manager's fallback for an unfenced action: its invocation of the\n * action's own ability is covered by a grant of `flow/block/execute` on the\n * same step. Only for reading the flow-manager's authority records.\n */\n allowBlockExecuteFallback?: boolean;\n}\n\n/**\n * Past-path receipts carry `exp = signedAt + 300s`; the anchor time must fall\n * inside that signed window (with slack for clock skew), so an unsigned\n * `executedAt` cannot be moved to a time the signer never chose.\n */\nconst RECEIPT_ANCHOR_WINDOW_MS = 10 * 60 * 1000;\n\nconst fail = (code: ChainFailureCode, reason: string): ChainFailure => ({ ok: false, code, reason });\n\n// ---------------------------------------------------------------------------\n// Decoding\n// ---------------------------------------------------------------------------\n\n/** base64 or base64url, the same tolerance as the design-pod verifier. */\nexport function decodeCarBase64(value: string): Uint8Array {\n let normalized = value.replace(/-/g, '+').replace(/_/g, '/');\n if (normalized.length % 4) normalized += '='.repeat(4 - (normalized.length % 4));\n const binary = globalThis.atob(normalized);\n return Uint8Array.from(binary, (character) => character.charCodeAt(0));\n}\n\n/** Structural view of a parsed ucanto delegation/invocation. */\ninterface SignedNode {\n cid: { toString(): string };\n issuer: { did(): string };\n audience: { did(): string };\n capabilities: readonly unknown[];\n proofs?: readonly unknown[];\n expiration?: number;\n notBefore?: number;\n facts?: readonly unknown[];\n data: unknown;\n}\n\nfunction isSignedNode(value: unknown): value is SignedNode {\n const node = value as Partial<SignedNode> | null;\n return Boolean(node && typeof node === 'object' && node.cid && typeof node.issuer?.did === 'function' && typeof node.audience?.did === 'function');\n}\n\nasync function decodeSigned(car: string | undefined | null, cid: string): Promise<{ ok: true; node: SignedNode } | ChainFailure> {\n if (typeof car !== 'string' || car.length === 0) {\n return fail('MISSING_CAR', 'This record has no signed copy, so it proves nothing.');\n }\n let extracted: Awaited<ReturnType<typeof UcantoDelegation.extract>>;\n try {\n extracted = await UcantoDelegation.extract(decodeCarBase64(car));\n } catch (error) {\n return fail('INVALID_FORMAT', `The signed copy could not be read: ${error instanceof Error ? error.message : String(error)}`);\n }\n if (extracted.error || !isSignedNode(extracted.ok)) {\n return fail('INVALID_FORMAT', `The signed copy could not be read: ${extracted.error?.message ?? 'unknown format'}`);\n }\n const node = extracted.ok as unknown as SignedNode;\n if (node.cid.toString() !== cid) {\n return fail('CID_MISMATCH', `The signed copy is a different grant (${node.cid.toString()}) from the one it is stored as (${cid}).`);\n }\n return { ok: true, node };\n}\n\n// ---------------------------------------------------------------------------\n// Capability attenuation (ported from the flow-manager's reader so both sides\n// read a chain the same way: FM apps/flow-runner/src/reader/delegation.ts)\n// ---------------------------------------------------------------------------\n\nfunction signedCapabilities(node: unknown): SignedCapability[] {\n const item = node as { capabilities?: readonly unknown[] };\n return [...(item.capabilities ?? [])].flatMap((entry) => {\n const capability = entry && typeof entry === 'object' ? (entry as Record<string, unknown>) : null;\n if (!capability || typeof capability.can !== 'string' || typeof capability.with !== 'string') return [];\n const nb = capability.nb && typeof capability.nb === 'object' && !Array.isArray(capability.nb) ? (capability.nb as Record<string, unknown>) : undefined;\n return [{ can: capability.can, with: capability.with, ...(nb ? { nb } : {}) }];\n });\n}\n\nfunction abilityCovers(parent: string, child: string): boolean {\n if (parent === '*' || parent === child) return true;\n return parent.endsWith('/*') && child.startsWith(parent.slice(0, -1));\n}\n\n/**\n * A resource covers itself, anything addressed beneath it with `:` (the root\n * `ixo:flow:<doc>` covers `ixo:flow:<doc>:<step>`), and — with a trailing `*`\n * — anything starting with the text before it (`ixo:flow:<doc>:*`).\n */\nfunction resourceCovers(parent: string, child: string): boolean {\n return parent === '*' || parent === child || child.startsWith(`${parent}:`) || (parent.endsWith('*') && child.startsWith(parent.slice(0, -1)));\n}\n\nfunction caveatsAttenuate(parent: Record<string, unknown> | undefined, child: Record<string, unknown> | undefined): boolean {\n if (!parent || Object.keys(parent).length === 0) return true;\n if (!child) return false;\n return Object.entries(parent).every(([key, value]) => JSON.stringify(child[key]) === JSON.stringify(value));\n}\n\nexport function signedCapabilityCovers(parent: SignedCapability, child: SignedCapability): boolean {\n return abilityCovers(parent.can, child.can) && resourceCovers(parent.with, child.with) && caveatsAttenuate(parent.nb, child.nb);\n}\n\n/**\n * Whether a grant covers the capability being exercised, the way the\n * flow-manager's library matcher reads it: the resource must match exactly or\n * through a trailing `*`. A grant on the bare flow (`ixo:flow:<doc>`) does NOT\n * cover a step (`ixo:flow:<doc>:<step>`) — step grants name the step or\n * `ixo:flow:<doc>:*` (contract §7.2). The `:` hierarchy above only applies to\n * attenuation up the chain (a `flow/*` root on the bare flow may issue step\n * grants beneath it).\n */\nexport function grantCoversExercise(granted: SignedCapability, required: SignedCapability): boolean {\n const resourceMatches = granted.with === '*' || granted.with === required.with || (granted.with.endsWith('*') && required.with.startsWith(granted.with.slice(0, -1)));\n return abilityCovers(granted.can, required.can) && resourceMatches && caveatsAttenuate(granted.nb, required.nb);\n}\n\ninterface ChainWalk {\n ok: true;\n /** Owner first, this node's issuer last. */\n dids: string[];\n /** Parents first, this node last. */\n cids: string[];\n nodes: SignedNode[];\n}\n\n/**\n * Walk a signed node up to the owner. The owner's own signature is the root\n * of authority: a node the owner issued ends the walk, whatever it carries as\n * proofs. Every other node must carry its parents inside the CAR, each parent\n * addressed to this node's issuer, and every capability it claims must be\n * covered by a parent's signed capability. Every parent must itself reach the\n * owner — one bad parent refuses the node (fail closed).\n */\nfunction walkToOwner(node: SignedNode, ownerDid: string, seen = new Set<string>(), leafFallback = false): ChainWalk | ChainFailure {\n const cid = node.cid.toString();\n if (seen.has(cid)) return fail('BROKEN_LINK', 'The signed chain loops back on itself.');\n const issuer = normalizeDid(node.issuer.did());\n const proofs = node.proofs ?? [];\n if (issuer === ownerDid) {\n // The owner's signature is enough. A parent the owner stapled on anyway\n // (the self-issued `__root__` every Portal grant carries) is still part\n // of the chain when it too reaches the owner, so revoking the root\n // revokes everything under it, and its signature and dates are checked.\n for (const proof of proofs) {\n if (!isSignedNode(proof) || normalizeDid(proof.audience.did()) !== issuer) continue;\n const walked = walkToOwner(proof, ownerDid, new Set(seen).add(cid));\n if (walked.ok) return { ok: true, dids: [...walked.dids, issuer], cids: [...walked.cids, cid], nodes: [...walked.nodes, node] };\n }\n return { ok: true, dids: [issuer], cids: [cid], nodes: [node] };\n }\n\n if (proofs.length === 0) {\n return fail('NOT_ROOTED_AT_OWNER', `The chain starts with ${issuer}, who did not create this flow (${ownerDid}).`);\n }\n const nextSeen = new Set(seen).add(cid);\n // Only a parent addressed to this node's issuer can give it anything. The\n // Portal staples the whole chain (grant AND root) onto an invocation, so a\n // proof addressed to someone else is not an error — it simply grants this\n // issuer nothing and is not walked.\n const parents = proofs.filter((proof): proof is SignedNode => isSignedNode(proof) && normalizeDid(proof.audience.did()) === issuer);\n if (parents.length === 0) {\n const referencedOnly = proofs.some((proof) => !isSignedNode(proof));\n return fail(\n 'BROKEN_LINK',\n referencedOnly\n ? 'A grant in the chain is referenced but not included in the signed copy.'\n : `Nothing in the chain was given to ${issuer}, who signed this.`\n );\n }\n const parentCapabilities = parents.flatMap(signedCapabilities);\n for (const child of signedCapabilities(node)) {\n // The flow-manager's rule for an unfenced action: a parent holding\n // `flow/block/execute` on the step covers the action's own ability there\n // (only for the invocation itself, never further up the chain).\n const coveredByFallback = (parent: SignedCapability) =>\n leafFallback && abilityCovers(parent.can, 'flow/block/execute') && resourceCovers(parent.with, child.with) && caveatsAttenuate(parent.nb, child.nb);\n if (!parentCapabilities.some((parent) => signedCapabilityCovers(parent, child) || coveredByFallback(parent))) {\n return fail('EXCEEDS_PARENT', `${child.can} on ${child.with} is wider than what ${issuer} was given.`);\n }\n }\n let first: ChainWalk | null = null;\n const cids: string[] = [];\n const nodes: SignedNode[] = [];\n for (const parent of parents) {\n const walked = walkToOwner(parent, ownerDid, nextSeen);\n if (!walked.ok) return walked;\n first ??= walked;\n for (const parentCid of walked.cids) if (!cids.includes(parentCid)) cids.push(parentCid);\n nodes.push(...walked.nodes);\n }\n return { ok: true, dids: [...first!.dids, issuer], cids: [...cids, cid], nodes: [...nodes, node] };\n}\n\nfunction finiteSeconds(value: unknown): number | undefined {\n return typeof value === 'number' && Number.isFinite(value) ? value : undefined;\n}\n\nfunction earliestExpirationSeconds(nodes: SignedNode[]): number | undefined {\n let earliest: number | undefined;\n for (const node of nodes) {\n const exp = finiteSeconds(node.expiration);\n if (exp !== undefined && (earliest === undefined || exp < earliest)) earliest = exp;\n }\n return earliest;\n}\n\n// ---------------------------------------------------------------------------\n// Signatures and time, for the past path\n// ---------------------------------------------------------------------------\n\nasync function resolveKeys(did: string, env: UcanVerificationEnv): Promise<string[] | ChainFailure> {\n if (did.startsWith('did:key:')) return [did];\n if (!env.didResolver) return fail('INVALID_SIGNATURE', `Cannot look up the keys for ${did}: no DID resolver is configured.`);\n const resolved = await env.didResolver(did as `did:${string}:${string}`);\n if ('error' in resolved) return fail('INVALID_SIGNATURE', `Cannot look up the keys for ${did}: ${resolved.error.message}`);\n if (!resolved.ok?.length) return fail('INVALID_SIGNATURE', `${did} has no signing keys on record.`);\n return resolved.ok;\n}\n\nasync function verifyNodeSignature(node: SignedNode, env: UcanVerificationEnv): Promise<ChainFailure | null> {\n const issuerDid = node.issuer.did();\n const keys = await resolveKeys(issuerDid, env);\n if (!Array.isArray(keys)) return keys;\n for (const key of keys) {\n try {\n const verifier = ed25519.Verifier.parse(key as `did:key:${string}`);\n const wrapped = {\n did: () => issuerDid,\n verify: (payload: Uint8Array, signature: unknown) => verifier.verify(payload, signature as never),\n };\n if (await UCAN.verifySignature(node.data as never, wrapped as never)) return null;\n } catch {\n // try the next key\n }\n }\n return fail('INVALID_SIGNATURE', `The signature by ${issuerDid} does not check out.`);\n}\n\nfunction checkTimeAt(nodes: SignedNode[], atMs: number): ChainFailure | null {\n const atSeconds = Math.floor(atMs / 1000);\n for (const node of nodes) {\n const nbf = finiteSeconds(node.notBefore);\n if (nbf !== undefined && atSeconds < nbf) {\n return fail('NOT_YET_VALID', `A grant in the chain only starts at ${new Date(nbf * 1000).toISOString()}.`);\n }\n const exp = finiteSeconds(node.expiration);\n if (exp !== undefined && atSeconds >= exp) {\n return fail('EXPIRED', `A grant in the chain had already expired at ${new Date(exp * 1000).toISOString()}.`);\n }\n }\n return null;\n}\n\nasync function checkRevocation(cids: string[], env: UcanVerificationEnv): Promise<{ revoked?: string } | ChainFailure> {\n if (!env.revocationChecker) return fail('NO_REVOCATION_CHECKER', 'Could not confirm the grant was not cancelled: no revocation service is configured.');\n try {\n const revoked = await env.revocationChecker.check(cids);\n const hit = revoked.find((cid) => cids.includes(cid));\n return hit ? { revoked: hit } : {};\n } catch (error) {\n return fail('REVOCATION_CHECK_FAILED', `Could not confirm the grant was not cancelled: ${error instanceof Error ? error.message : String(error)}`);\n }\n}\n\nfunction mapValidatorError(error: { code?: string; message?: string } | undefined): ChainFailure {\n const message = error?.message ?? 'The signed chain did not verify.';\n switch (error?.code) {\n case 'EXPIRED':\n return fail('EXPIRED', 'This grant has expired.');\n case 'REVOKED':\n return fail('REVOKED', `This grant has been cancelled. ${message}`);\n case 'REVOCATION_CHECK_FAILED':\n return fail('REVOCATION_CHECK_FAILED', `Could not confirm the grant was not cancelled. ${message}`);\n case 'INVALID_SIGNATURE':\n return fail('INVALID_SIGNATURE', message);\n case 'INVALID_FORMAT':\n return fail('INVALID_FORMAT', message);\n default:\n if (/no expiration/i.test(message)) return fail('NO_EXPIRATION', 'This grant never expires. Grants must have an end date; ask the flow creator to sign it again.');\n if (/expired/i.test(message)) return fail('EXPIRED', 'This grant has expired.');\n return fail('UNAUTHORIZED', message);\n }\n}\n\n// ---------------------------------------------------------------------------\n// Grants\n// ---------------------------------------------------------------------------\n\n/**\n * Verify one grant CAR gives `actorDid` the `required` capability under the\n * flow owner's authority.\n */\nexport async function verifyGrant(car: string | undefined | null, options: VerifyGrantOptions): Promise<GrantVerdict> {\n const ownerDid = options.ownerDid ? normalizeDid(options.ownerDid) : '';\n if (!ownerDid.startsWith('did:')) return fail('NO_OWNER', 'This flow has no known creator, so no grant in it can be checked.');\n const decoded = await decodeSigned(car, options.cid);\n if (!decoded.ok) return decoded;\n const { node } = decoded;\n\n const audienceDid = normalizeDid(node.audience.did());\n if (audienceDid !== normalizeDid(options.actorDid)) {\n return fail('WRONG_AUDIENCE', `This grant was given to ${audienceDid}, not to ${normalizeDid(options.actorDid)}.`);\n }\n const walked = walkToOwner(node, ownerDid);\n if (!walked.ok) return walked;\n\n const capabilities = signedCapabilities(node);\n const covers = options.coverage === 'hierarchical' ? signedCapabilityCovers : grantCoversExercise;\n if (!capabilities.some((capability) => covers(capability, options.required))) {\n return fail('CAPABILITY_NOT_COVERED', `This grant does not allow ${options.required.can} on ${options.required.with}.`);\n }\n\n const expSeconds = earliestExpirationSeconds(walked.nodes);\n const grant: VerifiedGrant = {\n cid: options.cid,\n issuerDid: normalizeDid(node.issuer.did()),\n audienceDid,\n capabilities,\n ...(expSeconds !== undefined ? { expiresAt: expSeconds * 1000 } : {}),\n proofChain: walked.dids,\n proofChainCids: walked.cids,\n };\n\n if (options.at === undefined) {\n // Present: the services' own validator decides signatures, expiry and\n // revocation. It does not check nbf, so that is checked here.\n if (!options.env.revocationChecker) return fail('NO_REVOCATION_CHECKER', 'Could not confirm the grant was not cancelled: no revocation service is configured.');\n const notYet = checkTimeAt(walked.nodes, Date.now());\n if (notYet?.code === 'NOT_YET_VALID') return notYet;\n const validator = await createUCANValidator({\n serverDid: node.audience.did(),\n rootIssuers: [ownerDid],\n didResolver: options.env.didResolver,\n revocationChecker: options.env.revocationChecker,\n revocationFailure: 'closed',\n requireExpiration: true,\n });\n const result = await validator.validateDelegation(car!);\n if (!result.ok) return mapValidatorError(result.error);\n return { ok: true, grant };\n }\n\n for (const chainNode of walked.nodes) {\n const bad = await verifyNodeSignature(chainNode, options.env);\n if (bad) return bad;\n }\n const timeFailure = checkTimeAt(walked.nodes, options.at);\n if (timeFailure) return timeFailure;\n const revocation = await checkRevocation(walked.cids, options.env);\n if ('ok' in revocation) return revocation;\n return { ok: true, grant, ...(revocation.revoked ? { revokedNow: revocation.revoked } : {}) };\n}\n\n// ---------------------------------------------------------------------------\n// Invocations\n// ---------------------------------------------------------------------------\n\nconst capabilityParsers = new Map<string, ReturnType<typeof defineCapability>>();\nfunction capabilityParser(can: string): ReturnType<typeof defineCapability> {\n let parser = capabilityParsers.get(can);\n if (!parser) {\n parser = defineCapability({ can: can as `${string}/${string}`, protocol: 'ixo:' });\n capabilityParsers.set(can, parser);\n }\n return parser;\n}\n\n/** A replay store that remembers nothing: re-reading a stored receipt is not a replay. */\nconst NO_REPLAY_STORE = {\n has: async () => false,\n add: async () => undefined,\n};\n\nfunction factsMatch(facts: readonly unknown[] | undefined, expected: Record<string, unknown> | undefined): boolean {\n if (!expected || Object.keys(expected).length === 0) return true;\n return (facts ?? []).some((fact) => {\n if (!fact || typeof fact !== 'object') return false;\n const record = fact as Record<string, unknown>;\n return Object.entries(expected).every(([key, value]) => JSON.stringify(record[key]) === JSON.stringify(value));\n });\n}\n\nfunction plainFacts(facts: readonly unknown[] | undefined): Record<string, unknown>[] {\n return (facts ?? []).filter((fact): fact is Record<string, unknown> => Boolean(fact) && typeof fact === 'object' && !Array.isArray(fact));\n}\n\n/**\n * Verify a signed invocation (a step receipt or a request proof) exercises\n * exactly `required`, is addressed to `expectedAudience`, is signed by\n * `actorDid` when given, carries `expectedFacts`, and chains to the owner.\n */\nexport async function verifyInvocation(car: string | undefined | null, options: VerifyInvocationOptions): Promise<InvocationVerdict> {\n const ownerDid = options.ownerDid ? normalizeDid(options.ownerDid) : '';\n if (!ownerDid.startsWith('did:')) return fail('NO_OWNER', 'This flow has no known creator, so no receipt in it can be checked.');\n const decoded = await decodeSigned(car, options.cid);\n if (!decoded.ok) return decoded;\n const { node } = decoded;\n\n const audienceDid = normalizeDid(node.audience.did());\n if (audienceDid !== normalizeDid(options.expectedAudience)) {\n return fail('WRONG_AUDIENCE', `This receipt is addressed to ${audienceDid}, not ${normalizeDid(options.expectedAudience)}.`);\n }\n const invokerDid = normalizeDid(node.issuer.did());\n if (options.actorDid && invokerDid !== normalizeDid(options.actorDid)) {\n return fail('WRONG_INVOKER', `This receipt was signed by ${invokerDid}, not by ${normalizeDid(options.actorDid)} as recorded.`);\n }\n const capabilities = signedCapabilities(node);\n const capability = capabilities[0];\n if (capabilities.length !== 1 || capability.can !== options.required.can || capability.with !== options.required.with) {\n return fail('CAPABILITY_NOT_COVERED', `This receipt is not for ${options.required.can} on ${options.required.with}.`);\n }\n if (!factsMatch(node.facts, options.expectedFacts)) {\n return fail('FACTS_MISMATCH', 'The signed receipt does not match what the record says happened (action, inputs or run).');\n }\n const walked = walkToOwner(node, ownerDid, new Set(), options.allowBlockExecuteFallback === true);\n if (!walked.ok) return walked;\n\n const expSeconds = earliestExpirationSeconds(walked.nodes);\n const grantExpSeconds = earliestExpirationSeconds(walked.nodes.filter((chainNode) => chainNode !== node));\n const verified: VerifiedInvocation = {\n cid: options.cid,\n invokerDid,\n audienceDid,\n capability,\n facts: plainFacts(node.facts),\n ...(expSeconds !== undefined ? { expiresAt: expSeconds * 1000 } : {}),\n ...(grantExpSeconds !== undefined ? { grantsExpireAt: grantExpSeconds * 1000 } : {}),\n proofChain: walked.dids,\n proofChainCids: walked.cids,\n };\n\n if (options.at === undefined) {\n if (!options.env.revocationChecker) return fail('NO_REVOCATION_CHECKER', 'Could not confirm the grant was not cancelled: no revocation service is configured.');\n const validator = await createUCANValidator({\n serverDid: node.audience.did(),\n rootIssuers: [ownerDid],\n didResolver: options.env.didResolver,\n invocationStore: NO_REPLAY_STORE,\n revocationChecker: options.env.revocationChecker,\n revocationFailure: 'closed',\n requireExpiration: true,\n });\n const result = await validator.validate(car!, capabilityParser(options.required.can) as never, options.required.with);\n if (!result.ok) return mapValidatorError(result.error);\n // The library also accepts any issuer whose DID appears inside `with`;\n // only a chain that starts at the owner counts here.\n if (normalizeDid(result.proofChain?.[0] ?? '') !== ownerDid) {\n return fail('NOT_ROOTED_AT_OWNER', `The chain starts with ${result.proofChain?.[0] ?? 'nobody'}, who did not create this flow.`);\n }\n return { ok: true, invocation: verified };\n }\n\n // Past: the receipt's own signed expiry is the time anchor.\n const ownExp = finiteSeconds(node.expiration);\n let noTimeAnchor = false;\n if (ownExp === undefined) {\n noTimeAnchor = true;\n } else {\n const expMs = ownExp * 1000;\n if (options.at >= expMs || options.at < expMs - RECEIPT_ANCHOR_WINDOW_MS) {\n return fail('EXPIRED', `The recorded time ${new Date(options.at).toISOString()} is outside the time this receipt was signed for.`);\n }\n }\n for (const chainNode of walked.nodes) {\n const bad = await verifyNodeSignature(chainNode, options.env);\n if (bad) return bad;\n }\n const timeFailure = checkTimeAt(walked.nodes, options.at);\n if (timeFailure) return timeFailure;\n const revocation = await checkRevocation(walked.cids, options.env);\n if ('ok' in revocation) return revocation;\n return {\n ok: true,\n invocation: verified,\n ...(revocation.revoked ? { revokedNow: revocation.revoked } : {}),\n ...(noTimeAnchor ? { noTimeAnchor: true } : {}),\n };\n}\n","/**\n * UCAN Service using @ixo/ucan directly\n *\n * This service provides a high-level API for:\n * - Creating and managing delegations (CAR format)\n * - Creating and validating invocations\n * - Executing actions with invocation-based authorization\n *\n * The host app only needs to provide the signer (private key) after PIN decryption.\n * All UCAN operations are performed using @ixo/ucan directly.\n */\n\nimport {\n createDelegation as ucanCreateDelegation,\n createInvocation as ucanCreateInvocation,\n serializeDelegation,\n serializeInvocation,\n parseDelegation,\n parseSigner,\n signerFromMnemonic,\n type Signer,\n type Delegation,\n type Capability as UcantoCapability,\n type SupportedDID,\n} from '@ixo/ucan';\n\nimport { ucanCapabilityCovers, type UcanDelegationStore } from '../lib/ucanDelegationStore';\nimport { normalizeDid } from '../lib/ucan/normalizeDid';\nimport type { FlowAuthorityIndex } from '../lib/ucan/flowAuthorityIndex';\nimport type { ReceiptVerifier } from '../lib/ucan/receiptVerifier';\nimport { createFlowRequest, type CreateFlowRequestParams, type FlowRequestRecordV1 } from '../lib/ucan/requestProofs';\nimport { verifyInvocation, type UcanVerificationEnv } from '../lib/ucan/signedChain';\nimport type { InvocationStore } from '../lib/invocationStore';\nimport type {\n StoredDelegation,\n StoredInvocation,\n UcanCapability,\n InvocationResult,\n ExecutionWithInvocationResult,\n DelegationChainValidationResult,\n FindProofsResult,\n CreateRootDelegationParams,\n CreateDelegationParams,\n CreateInvocationParams,\n} from '../types/ucan';\n\n/**\n * Signer session scope type\n */\nexport type SignerSessionScope = 'session' | 'operation';\n\n/** Reusable decrypted signer lifetime. The host enforces the same one-hour maximum. */\nconst FLOW_INVOCATION_SIGNER_TTL_SECONDS = 60 * 60;\n\n/**\n * Signer session returned by createSignerSession\n */\nexport interface SignerSessionInfo {\n sessionId: string;\n did: string;\n publicKey: string;\n keyId: string;\n expiresAt: number;\n scope: SignerSessionScope;\n}\n\n/**\n * Handler functions for getting signers from the host application\n * The host app handles PIN decryption and key management\n */\nexport interface UcanServiceHandlers {\n /**\n * Get a signer for the given DID after PIN verification\n * The host app decrypts the private key using the PIN\n *\n * @returns The private key in multibase format (for parseSigner)\n * @deprecated Prefer createSignerSession for better security\n */\n getPrivateKey?: (params: { did: string; didType: 'entity' | 'user'; entityRoomId?: string; pin: string }) => Promise<string>;\n\n /**\n * Get a signer from mnemonic (alternative to getPrivateKey)\n * The host app retrieves and decrypts the mnemonic using the PIN\n *\n * @returns The mnemonic phrase\n * @deprecated Prefer createSignerSession for better security\n */\n getMnemonic?: (params: { did: string; didType: 'entity' | 'user'; entityRoomId?: string; pin: string }) => Promise<string>;\n\n // ============================================================================\n // Handle-based signer session handlers (preferred approach)\n // ============================================================================\n\n /** Return a reusable in-memory signer session for this DID, if one exists. */\n getActiveSignerSession?: (params: { did: string }) => Promise<SignerSessionInfo | null>;\n\n /**\n * Create a signer session that can be used for multiple sign operations.\n * The host app keeps the key material secure; the editor only receives an opaque handle.\n *\n * @param params.scope - 'session' for multiple operations, 'operation' for one-time use\n * @param params.ttlSeconds - Time-to-live for session scope (default: 300, max: 3600)\n */\n createSignerSession?: (params: {\n did: string;\n didType: 'entity' | 'user';\n entityRoomId?: string;\n pin: string;\n scope: SignerSessionScope;\n ttlSeconds?: number;\n }) => Promise<SignerSessionInfo>;\n\n /**\n * Sign data using an existing session.\n * For 'operation' scope, the session is automatically invalidated after this call.\n */\n signWithSession?: (params: { sessionId: string; data: string; algorithm?: 'Ed25519' }) => Promise<{\n signature: string;\n algorithm: 'Ed25519';\n keyId: string;\n }>;\n\n /**\n * Release a session before it expires.\n * Safe to call on already-released or expired sessions.\n */\n releaseSignerSession?: (params: { sessionId: string }) => Promise<{\n released: boolean;\n reason?: string;\n }>;\n\n // ============================================================================\n // Deprecated high-level session helpers.\n // Prefer BlocknoteHandlers.createDelegation/createInvocation plus the\n // createSignerSession/signWithSession/releaseSignerSession contract.\n // ============================================================================\n\n /**\n * Create a delegation directly in the host app.\n * The host handles all signing internally using session-based signing.\n * @deprecated Use createDelegation on BlocknoteHandlers instead.\n */\n createDelegationWithSession?: (params: {\n sessionId: string;\n audience: string;\n capabilities: Array<{\n can: string;\n with: string;\n nb?: Record<string, unknown>;\n }>;\n proofs?: string[];\n expiration?: number;\n }) => Promise<{\n cid: string;\n delegation: string;\n }>;\n\n /**\n * Create an invocation directly in the host app.\n * The host handles all signing internally using session-based signing.\n * @deprecated Use createInvocation on BlocknoteHandlers instead.\n */\n createInvocationWithSession?: (params: {\n sessionId: string;\n audience: string;\n capability: {\n can: string;\n with: string;\n nb?: Record<string, unknown>;\n };\n proofs: string[];\n facts?: Record<string, unknown>;\n /** Unix seconds. Omitted means the invocation never expires (legacy). */\n expiration?: number;\n }) => Promise<{\n cid: string;\n invocation: string;\n }>;\n\n /**\n * Revoke a signed delegation where verifiers look (the host's UCAN store).\n * Must reject when the revocation did not land; the delegation then stays.\n */\n revokeDelegation?: (params: { cid: string; token: string }) => Promise<void>;\n}\n\n/**\n * Configuration for UcanService\n */\nexport interface UcanServiceConfig {\n delegationStore: UcanDelegationStore;\n invocationStore: InvocationStore;\n handlers: UcanServiceHandlers;\n /** The room creator (see core/lib/flowOwner.ts). Never the doc's flowOwnerDid copy. */\n flowOwnerDid: string;\n flowUri: string;\n /**\n * Decides who may do what from the signed grants. Without it nothing is\n * authorized: the service never falls back to the JSON copies.\n */\n authority?: FlowAuthorityIndex;\n /** DID resolver and revocation checker used to verify every invocation this service mints. */\n verification?: UcanVerificationEnv;\n /** Re-verifies stored step receipts from their CARs (completion and trigger checks read it). */\n receipts?: ReceiptVerifier;\n}\n\n/** How long a Portal-signed invocation is valid (contract §1, §3): five minutes. */\nexport const FLOW_INVOCATION_TTL_SECONDS = 300;\n\n/** 128 random bits, base64url, for the `nonce` fact every flow invocation carries. */\nexport function createInvocationNonce(): string {\n const bytes = new Uint8Array(16);\n globalThis.crypto.getRandomValues(bytes);\n let binary = '';\n for (const byte of bytes) binary += String.fromCharCode(byte);\n return globalThis.btoa(binary).replace(/\\+/g, '-').replace(/\\//g, '_').replace(/=+$/, '');\n}\n\n/**\n * UCAN Service interface\n */\nexport interface UcanService {\n // Delegation operations\n createRootDelegation: (params: CreateRootDelegationParams) => Promise<StoredDelegation>;\n createDelegation: (params: CreateDelegationParams) => Promise<StoredDelegation>;\n /** Revokes through the host first, then removes locally. Rejects (and removes nothing) when the host cannot revoke. */\n revokeDelegation: (cid: string) => Promise<void>;\n getDelegation: (cid: string) => StoredDelegation | null;\n getAllDelegations: () => StoredDelegation[];\n getRootDelegation: () => StoredDelegation | null;\n\n // Invocation operations\n createAndValidateInvocation: (params: CreateInvocationParams, flowId: string, blockId?: string) => Promise<InvocationResult>;\n executeWithInvocation: <T>(\n params: CreateInvocationParams,\n action: () => Promise<T>,\n flowId: string,\n blockId?: string,\n sessionRunId?: string\n ) => Promise<ExecutionWithInvocationResult & { actionResult?: T }>;\n\n // Validation\n validateDelegationChain: (audienceDid: string, capability: UcanCapability) => Promise<DelegationChainValidationResult>;\n findValidProofs: (audienceDid: string, capability: UcanCapability) => Promise<FindProofsResult>;\n\n // Parsing\n parseDelegationFromStore: (cid: string) => Promise<Delegation | null>;\n\n // Utility\n isConfigured: () => boolean;\n /** The signed-grant authority behind findValidProofs, for synchronous reads with a loading state. */\n authority?: FlowAuthorityIndex;\n /** The verification environment every invocation this service mints is checked with. */\n verification?: UcanVerificationEnv;\n /** Receipt re-verification, shared by completion checks and trigger reconciliation. */\n receipts?: ReceiptVerifier;\n /**\n * Sign a requester proof addressed to the flow-manager (contract §1): run\n * start/close, step request, input answer or schedule arm. Refused unless\n * the requester holds the capability; verified before it is returned.\n */\n createRequestInvocation: (params: CreateFlowRequestParams) => Promise<FlowRequestRecordV1>;\n}\n\n/**\n * Convert a DID string to SupportedDID type (did:ixo:* or did:key:*)\n */\nfunction toSupportedDID(did: string): SupportedDID | undefined {\n if (did.startsWith('did:ixo:') || did.startsWith('did:key:')) {\n return did as SupportedDID;\n }\n return undefined;\n}\n\n/** How long a flow grant lasts when the caller names no expiry: 30 days. Every grant expires. */\nexport const DEFAULT_FLOW_GRANT_TTL_MS = 30 * 24 * 60 * 60 * 1000;\n\n/**\n * The expiry (unix ms) a new delegation is signed with. Defaults to 30 days;\n * refuses anything that is not a finite time in the future, so a caller can\n * never sign a grant that never ends.\n */\nexport function resolveGrantExpiration(expiration?: number, now: number = Date.now()): number {\n if (expiration === undefined) return now + DEFAULT_FLOW_GRANT_TTL_MS;\n if (!Number.isFinite(expiration) || expiration <= now) throw new Error('A grant needs an expiry date in the future.');\n return expiration;\n}\n\nfunction toInvocationAudienceDID(did: string): SupportedDID {\n const normalized = normalizeDid(did);\n const supported = toSupportedDID(normalized);\n if (!supported) {\n throw new Error(`Invalid DID \"${did}\", must start with 'did:'`);\n }\n return supported;\n}\n\n/**\n * Ability type for UCAN capabilities (format: \"namespace/action\" or \"*\")\n */\ntype Ability = `${string}/${string}` | '*';\n\n/**\n * Resource type for UCAN capabilities (format: \"scheme:path\")\n */\ntype Resource = `${string}:${string}`;\n\n/**\n * Convert UcanCapability to UcantoCapability with proper type format\n * Ucanto requires `can` to be Ability and `with` to be Resource\n */\nfunction toUcantoCapabilities(capabilities: UcanCapability[]): UcantoCapability[] {\n return capabilities.map((cap) => ({\n can: cap.can as Ability,\n with: cap.with as Resource,\n ...(cap.nb && { nb: cap.nb }),\n }));\n}\n\n/**\n * Get a signer from the handlers.\n */\nasync function getSigner(handlers: UcanServiceHandlers, did: string, didType: 'entity' | 'user', entityRoomId: string | undefined, pin: string): Promise<Signer> {\n const normalizedDid = normalizeDid(did);\n const supportedDid = toSupportedDID(normalizedDid);\n\n if (handlers.getPrivateKey) {\n const privateKey = await handlers.getPrivateKey({ did: normalizedDid, didType, entityRoomId, pin });\n return parseSigner(privateKey, supportedDid);\n }\n\n if (handlers.getMnemonic) {\n const mnemonic = await handlers.getMnemonic({ did: normalizedDid, didType, entityRoomId, pin });\n const result = await signerFromMnemonic(mnemonic, supportedDid);\n return result.signer;\n }\n\n throw new Error('No signer handler configured (need getPrivateKey or getMnemonic)');\n}\n\n/**\n * Generate a CID-like identifier from delegation\n */\nfunction getCidFromDelegation(delegation: Delegation): string {\n return delegation.cid.toString();\n}\n\n/**\n * Create a UCAN service instance\n */\n/**\n * Whether the flow's root capability covers a request. The root is minted as\n * `flow/*` on the bare flow URI; every flow resource is addressed beneath it\n * (`<flowUri>:<blockId>`, `<flowUri>:*`), so the root's resource covers itself\n * and anything under its `:` hierarchy. Non-flow abilities are never covered.\n */\nexport function rootCapabilityCovers(granted: UcanCapability, requested: UcanCapability): boolean {\n if (!requested.can.startsWith('flow/')) return false;\n if (!ucanCapabilityCovers({ ...granted, with: '*' }, { ...requested, with: '*' })) return false;\n return requested.with === granted.with || requested.with.startsWith(`${granted.with}:`);\n}\n\nexport const createUcanService = (config: UcanServiceConfig): UcanService => {\n const { delegationStore, invocationStore, handlers, flowOwnerDid } = config;\n\n // Cache for parsed delegations\n const delegationCache = new Map<string, Delegation>();\n\n const isConfigured = (): boolean => {\n const hasSessionHandlers = !!(handlers.createSignerSession && handlers.signWithSession);\n const hasLegacyHandlers = !!(handlers.getPrivateKey || handlers.getMnemonic);\n return hasSessionHandlers || hasLegacyHandlers;\n };\n\n const parseDelegationFromStore = async (cid: string): Promise<Delegation | null> => {\n if (delegationCache.has(cid)) {\n return delegationCache.get(cid)!;\n }\n\n const stored = delegationStore.get(cid);\n if (!stored || !stored.delegation) {\n return null;\n }\n\n try {\n const delegation = await parseDelegation(stored.delegation);\n delegationCache.set(cid, delegation);\n return delegation;\n } catch {\n return null;\n }\n };\n\n const getProofDelegations = async (proofCids: string[]): Promise<Delegation[]> => {\n const proofs: Delegation[] = [];\n for (const cid of proofCids) {\n const delegation = await parseDelegationFromStore(cid);\n if (delegation) {\n proofs.push(delegation);\n }\n }\n return proofs;\n };\n\n /**\n * Resolve proof CIDs to their serialized CAR strings (base64) by reading\n * the local delegation store. Used when the host's session-based UCAN\n * handlers want CARs (so they don't need access to the editor's store).\n */\n const getProofCars = async (proofCids: string[]): Promise<string[]> => {\n const cars: string[] = [];\n for (const cid of proofCids) {\n const stored = delegationStore.get(cid);\n if (stored && stored.delegation) {\n cars.push(stored.delegation);\n }\n }\n return cars;\n };\n\n const createRootDelegation = async (params: CreateRootDelegationParams): Promise<StoredDelegation> => {\n const { flowOwnerDid: ownerDid, issuerType, entityRoomId, flowUri: uri, pin } = params;\n const normalizedOwnerDid = normalizeDid(ownerDid);\n\n const capabilities: UcantoCapability[] = [{ can: 'flow/*', with: uri as `${string}:${string}` }];\n // The root expires like every other grant; the flow's Renew re-signs it.\n const rootExpiration = resolveGrantExpiration();\n\n // Prefer the host's session-based UCAN handler when available — same\n // fallback pattern as createDelegation / createAndValidateInvocation.\n if (handlers.createSignerSession && handlers.createDelegationWithSession) {\n const session = await handlers.createSignerSession({\n did: normalizedOwnerDid,\n didType: issuerType,\n entityRoomId,\n pin,\n scope: 'operation',\n });\n\n const result = await handlers.createDelegationWithSession({\n sessionId: session.sessionId,\n audience: normalizedOwnerDid,\n capabilities: capabilities as Array<{ can: string; with: string; nb?: Record<string, unknown> }>,\n proofs: [],\n expiration: Math.floor(rootExpiration / 1000),\n });\n\n const storedDelegation: StoredDelegation = {\n cid: result.cid,\n delegation: result.delegation,\n issuerDid: normalizedOwnerDid,\n audienceDid: normalizedOwnerDid,\n capabilities: capabilities as UcanCapability[],\n expiration: rootExpiration,\n createdAt: Date.now(),\n format: 'car',\n proofCids: [],\n };\n\n delegationStore.set(storedDelegation);\n delegationStore.setRootCid(result.cid);\n return storedDelegation;\n }\n\n // Legacy path — editor builds the signer locally from a mnemonic/key.\n const signer = await getSigner(handlers, ownerDid, issuerType, entityRoomId, pin);\n\n const delegation = await ucanCreateDelegation({\n issuer: signer,\n audience: toInvocationAudienceDID(normalizedOwnerDid),\n capabilities,\n proofs: [],\n expiration: Math.floor(rootExpiration / 1000),\n });\n\n const serialized = await serializeDelegation(delegation);\n const cid = getCidFromDelegation(delegation);\n\n const storedDelegation: StoredDelegation = {\n cid,\n delegation: serialized,\n issuerDid: normalizedOwnerDid,\n audienceDid: normalizedOwnerDid,\n capabilities: capabilities as UcanCapability[],\n expiration: rootExpiration,\n createdAt: Date.now(),\n format: 'car',\n proofCids: [],\n };\n\n delegationStore.set(storedDelegation);\n delegationStore.setRootCid(cid);\n\n delegationCache.set(cid, delegation);\n\n return storedDelegation;\n };\n\n const createDelegation = async (params: CreateDelegationParams): Promise<StoredDelegation> => {\n const { issuerDid, issuerType, entityRoomId, audience, capabilities, proofs = [], pin } = params;\n const expiration = resolveGrantExpiration(params.expiration);\n const normalizedIssuerDid = normalizeDid(issuerDid);\n const normalizedAudienceDid = normalizeDid(audience);\n\n // Use proofs exactly as the caller provided them. Empty array = the\n // delegation is self-issued (no parent in the chain) — this is correct\n // for capabilities targeting external services where the issuer's DID\n // is itself the trust root. Flow-rooted delegations must be assembled\n // by the caller (e.g. AuthorizationTab passes [rootCid, ...]).\n const proofCids = proofs;\n\n // Prefer the host's session-based UCAN handler when available — it\n // signs without ever exposing the mnemonic to the editor. Falls back\n // to the legacy mnemonic-based path for older host implementations.\n if (handlers.createSignerSession && handlers.createDelegationWithSession) {\n const session = await handlers.createSignerSession({\n did: normalizedIssuerDid,\n didType: issuerType,\n entityRoomId,\n pin,\n scope: 'operation',\n });\n\n const proofCars = await getProofCars(proofCids);\n\n const result = await handlers.createDelegationWithSession({\n sessionId: session.sessionId,\n audience: normalizedAudienceDid,\n capabilities: capabilities as Array<{ can: string; with: string; nb?: Record<string, unknown> }>,\n proofs: proofCars,\n expiration: Math.floor(expiration / 1000),\n });\n\n const storedDelegation: StoredDelegation = {\n cid: result.cid,\n delegation: result.delegation,\n issuerDid: normalizedIssuerDid,\n audienceDid: normalizedAudienceDid,\n capabilities,\n expiration,\n createdAt: Date.now(),\n format: 'car',\n proofCids,\n };\n\n delegationStore.set(storedDelegation);\n return storedDelegation;\n }\n\n // Legacy path: editor signs locally using getMnemonic/getPrivateKey.\n const signer = await getSigner(handlers, issuerDid, issuerType, entityRoomId, pin);\n\n const proofDelegations = await getProofDelegations(proofCids);\n\n const delegation = await ucanCreateDelegation({\n issuer: signer,\n audience: toInvocationAudienceDID(normalizedAudienceDid),\n capabilities: toUcantoCapabilities(capabilities),\n proofs: proofDelegations,\n expiration: Math.floor(expiration / 1000),\n });\n\n const serialized = await serializeDelegation(delegation);\n const cid = getCidFromDelegation(delegation);\n\n const storedDelegation: StoredDelegation = {\n cid,\n delegation: serialized,\n issuerDid: normalizedIssuerDid,\n audienceDid: normalizedAudienceDid,\n capabilities,\n expiration,\n createdAt: Date.now(),\n format: 'car',\n proofCids,\n };\n\n delegationStore.set(storedDelegation);\n\n delegationCache.set(cid, delegation);\n\n return storedDelegation;\n };\n\n const revokeDelegation = async (cid: string): Promise<void> => {\n // Deleting the entry only hides it here; the CAR stays valid wherever it\n // was copied. A signed entry is revoked by the host first, and stays put\n // if that fails. An entry with no CAR carries no signature to revoke.\n const token = delegationStore.get(cid)?.delegation;\n if (token) {\n if (!handlers.revokeDelegation) throw new Error('Revoking is not available here, so the grant was left in place.');\n await handlers.revokeDelegation({ cid, token });\n }\n delegationStore.remove(cid);\n delegationCache.delete(cid);\n // Drop every cached verdict now, not on the next delegations-map event:\n // a revoked grant must stop authorizing at once.\n config.authority?.invalidate();\n };\n\n const getDelegation = (cid: string): StoredDelegation | null => {\n return delegationStore.get(cid);\n };\n\n const getAllDelegations = (): StoredDelegation[] => {\n return delegationStore.getAll();\n };\n\n const getRootDelegation = (): StoredDelegation | null => {\n return delegationStore.getRoot();\n };\n\n const findValidProofs = async (audienceDid: string, capability: UcanCapability): Promise<FindProofsResult> => {\n // Authority comes from the signed grants only (FlowAuthorityIndex). The\n // JSON fields stored next to each CAR — issuerDid, audienceDid,\n // capabilities, expiration, proofCids — are never read here: anyone who\n // can write to the room can edit them.\n if (!config.authority) {\n return { found: false, error: 'Grants cannot be checked in this editor: no UCAN verifier is set up.' };\n }\n const decision = await config.authority.authorize(audienceDid, capability);\n return decision.allowed ? { found: true, proofCids: decision.proofCids } : { found: false, error: decision.reason };\n };\n\n const validateDelegationChain = async (audienceDid: string, capability: UcanCapability): Promise<DelegationChainValidationResult> => {\n const proofsResult = await findValidProofs(audienceDid, capability);\n if (!proofsResult.found || !proofsResult.proofCids) {\n return { valid: false, error: proofsResult.error };\n }\n // The records are returned for display and audit only; the decision was\n // made from their CARs. The room creator acting on their own authority\n // has an empty chain.\n const proofChain = proofsResult.proofCids.map((cid) => delegationStore.get(cid)).filter((delegation): delegation is StoredDelegation => delegation !== null);\n return { valid: true, proofChain };\n };\n\n const createAndValidateInvocation = async (params: CreateInvocationParams, _flowId: string, _blockId?: string): Promise<InvocationResult> => {\n const { invokerDid, invokerType, entityRoomId, capability, pin } = params;\n const normalizedInvokerDid = normalizeDid(invokerDid);\n const refuse = (error: string): InvocationResult => ({ cid: '', invocation: '', valid: false, error });\n\n const proofsResult = await findValidProofs(normalizedInvokerDid, capability);\n if (!proofsResult.found || !proofsResult.proofCids) return refuse(proofsResult.error ?? 'No valid grant for this action.');\n // The proofs stapled to the invocation are the ones the verifier chose,\n // not whatever the caller passed.\n const proofs = proofsResult.proofCids;\n\n // Audience defaults to the flow owner (in-flow invocations) but can be\n // overridden, e.g. to the flow-manager for a signed request (contract §1).\n const audience = normalizeDid(params.audience ?? flowOwnerDid);\n if (!audience.startsWith('did:')) return refuse(\"We can't tell who created this flow yet, so nothing can be signed for it.\");\n\n // Every flow invocation expires within five minutes and carries a fresh\n // nonce, so a receipt cannot be replayed later or minted twice alike. The\n // clock starts when the signer is ready, not before a PIN prompt.\n const ttlSeconds = Math.min(params.ttlSeconds ?? FLOW_INVOCATION_TTL_SECONDS, FLOW_INVOCATION_TTL_SECONDS);\n let expiration = 0;\n const facts: Record<string, unknown> = { ...(params.facts ?? {}), nonce: typeof params.facts?.nonce === 'string' ? params.facts.nonce : createInvocationNonce() };\n\n let minted: { cid: string; invocation: string };\n if (handlers.createSignerSession && handlers.createInvocationWithSession) {\n // Prefer the host's session-based UCAN handler when available. Reuse a\n // live signer so repeated browser actions do not need the PIN again.\n try {\n const cachedSession = await handlers.getActiveSignerSession?.({ did: normalizedInvokerDid });\n const session =\n cachedSession ??\n (await handlers.createSignerSession({\n did: normalizedInvokerDid,\n didType: invokerType,\n entityRoomId,\n pin,\n scope: 'session',\n ttlSeconds: FLOW_INVOCATION_SIGNER_TTL_SECONDS,\n }));\n\n const proofCars = await getProofCars(proofs);\n\n expiration = Math.floor(Date.now() / 1000) + ttlSeconds;\n minted = await handlers.createInvocationWithSession({\n sessionId: session.sessionId,\n audience,\n capability: {\n can: capability.can,\n with: capability.with,\n ...(capability.nb && { nb: capability.nb }),\n },\n proofs: proofCars,\n facts,\n expiration,\n });\n } catch (err) {\n return refuse(err instanceof Error ? err.message : 'Failed to create invocation via session');\n }\n } else {\n // Legacy path — editor builds the signer locally from a mnemonic/key.\n const signer = await getSigner(handlers, invokerDid, invokerType, entityRoomId, pin);\n const proofDelegations = await getProofDelegations(proofs);\n\n const ucantoCapability: UcantoCapability = {\n can: capability.can as Ability,\n with: capability.with as Resource,\n ...(capability.nb && { nb: capability.nb }),\n };\n\n expiration = Math.floor(Date.now() / 1000) + ttlSeconds;\n const invocation = await ucanCreateInvocation({\n issuer: signer,\n audience,\n capability: ucantoCapability,\n proofs: proofDelegations,\n facts: [facts],\n expiration,\n });\n\n const built = await invocation.buildIPLDView();\n minted = { cid: built.cid.toString(), invocation: await serializeInvocation(invocation) };\n }\n\n // Verify what was just signed, the same way anyone reading it later will:\n // from the CAR, against the room creator, as of the moment it was signed\n // (every signature, link, expiry and revocation). Checking \"as of now\"\n // rather than through the audience's validator means a request addressed\n // to the flow-manager does not depend on resolving the flow-manager's key.\n if (!config.verification) return refuse('This invocation cannot be checked in this editor: no UCAN verifier is set up.');\n const verdict = await verifyInvocation(minted.invocation, {\n cid: minted.cid,\n expectedAudience: audience,\n ownerDid: flowOwnerDid,\n actorDid: normalizedInvokerDid,\n required: { can: capability.can, with: capability.with },\n expectedFacts: facts,\n env: config.verification,\n at: (expiration - ttlSeconds) * 1000,\n });\n if (!verdict.ok) return { cid: minted.cid, invocation: minted.invocation, valid: false, error: verdict.reason };\n if (verdict.revokedNow) return { cid: minted.cid, invocation: minted.invocation, valid: false, error: 'The grant this relies on has been cancelled.' };\n\n return { cid: minted.cid, invocation: minted.invocation, valid: true, facts, proofCids: proofs, expiresAt: expiration * 1000, signedAt: (expiration - ttlSeconds) * 1000 };\n };\n\n const executeWithInvocation = async <T>(\n params: CreateInvocationParams,\n action: () => Promise<T>,\n flowId: string,\n blockId?: string,\n sessionRunId?: string\n ): Promise<ExecutionWithInvocationResult & { actionResult?: T }> => {\n const invocationResult = await createAndValidateInvocation(params, flowId, blockId);\n\n if (!invocationResult.valid) {\n return {\n success: false,\n invocationCid: invocationResult.cid,\n error: invocationResult.error,\n };\n }\n\n if (invocationStore.hasBeenInvoked(invocationResult.cid)) {\n return {\n success: false,\n invocationCid: invocationResult.cid,\n error: 'Invocation has already been used (replay attack prevented)',\n };\n }\n\n try {\n const actionResult = await action();\n\n const storedInvocation: StoredInvocation = {\n cid: invocationResult.cid,\n invocation: invocationResult.invocation,\n invokerDid: params.invokerDid,\n capability: params.capability,\n // The receipt's time anchor: when it was signed, so that\n // exp = executedAt + 300s holds (contract §3).\n executedAt: invocationResult.signedAt ?? Date.now(),\n flowId,\n sessionRunId,\n blockId,\n result: 'success',\n proofCids: invocationResult.proofCids ?? params.proofs,\n facts: invocationResult.facts ?? params.facts,\n };\n invocationStore.add(storedInvocation);\n\n return {\n success: true,\n invocationCid: invocationResult.cid,\n result: actionResult,\n actionResult,\n };\n } catch (error) {\n const storedInvocation: StoredInvocation = {\n cid: invocationResult.cid,\n invocation: invocationResult.invocation,\n invokerDid: params.invokerDid,\n capability: params.capability,\n // The receipt's time anchor: when it was signed, so that\n // exp = executedAt + 300s holds (contract §3).\n executedAt: invocationResult.signedAt ?? Date.now(),\n flowId,\n sessionRunId,\n blockId,\n result: 'failure',\n error: error instanceof Error ? error.message : 'Unknown error',\n proofCids: invocationResult.proofCids ?? params.proofs,\n facts: invocationResult.facts ?? params.facts,\n };\n invocationStore.add(storedInvocation);\n\n return {\n success: false,\n invocationCid: invocationResult.cid,\n error: error instanceof Error ? error.message : 'Unknown error',\n };\n }\n };\n\n const service: UcanService = {\n createRootDelegation,\n createDelegation,\n revokeDelegation,\n getDelegation,\n getAllDelegations,\n getRootDelegation,\n createAndValidateInvocation,\n executeWithInvocation,\n validateDelegationChain,\n findValidProofs,\n parseDelegationFromStore,\n isConfigured,\n authority: config.authority,\n verification: config.verification,\n receipts: config.receipts,\n createRequestInvocation: (params) => createFlowRequest(service, params),\n };\n return service;\n};\n","import { createUcanStoreRevocationChecker, type DIDKeyResolver, type RevocationChecker } from '@ixo/ucan';\n\nimport type { UcanVerificationEnv } from './signedChain';\n\n/** The host's side of verification: injected as `handlers.ucanVerification`. */\nexport interface UcanVerificationHandlers {\n /** DID → did:key verification keys. The Portal memoizes this for 5 minutes. */\n didResolver: DIDKeyResolver;\n /** Base URL of the UCAN store the editor asks about revocations. */\n revocationStoreUrl: string;\n}\n\n/**\n * One revocation checker per store URL for the life of the page.\n *\n * The checker caches \"not revoked\" for 30 seconds and \"revoked\" forever\n * (revocation cannot be undone), so it has to outlive any one editor to be\n * worth having: a new checker per render would ask the store every time.\n */\nconst checkers = new Map<string, RevocationChecker>();\n\nexport function revocationCheckerFor(url: string): RevocationChecker {\n let checker = checkers.get(url);\n if (!checker) {\n checker = createUcanStoreRevocationChecker({ url });\n checkers.set(url, checker);\n }\n return checker;\n}\n\n/**\n * Build the verification environment from what the host injected. A host\n * that injected nothing gets an environment with no revocation checker, and\n * every verification then refuses with \"could not confirm the grant was not\n * cancelled\" — never a silent allow.\n */\nexport function ucanVerificationEnvFrom(handlers: { ucanVerification?: UcanVerificationHandlers } | undefined | null): UcanVerificationEnv {\n const injected = handlers?.ucanVerification;\n if (!injected) return {};\n return {\n didResolver: injected.didResolver,\n ...(injected.revocationStoreUrl ? { revocationChecker: revocationCheckerFor(injected.revocationStoreUrl) } : {}),\n };\n}\n","/**\n * Who may do what in one flow, decided from the signed grants only.\n *\n * One index per editor. It answers \"may this actor exercise this capability\n * here, and with which proofs\" by verifying the grants' signed CARs against\n * the room creator — never by reading the JSON fields stored beside them.\n *\n * - The room creator needs no grant: their own signature is the root. Their\n * pinned self-issued `__root__` is still passed as a proof when it checks\n * out, because the deployed flow-manager expects to find it.\n * - Everyone else needs a grant whose CAR is addressed to them (the CAR's\n * audience, not the record's `audienceDid`), chains to the creator, carries\n * the capability, has not expired and has not been revoked.\n *\n * Verdicts are cached per grant and capability, for at most 30 seconds (so a\n * revocation is noticed within that time) and never past the grant's expiry.\n * The cache is dropped whenever the delegations map changes. A failure to\n * reach the revocation service is never cached: the next check asks again.\n */\nimport { Delegation as UcantoDelegation } from '@ucanto/core';\n\nimport type { UcanCapability } from '../../types/ucan';\nimport type { UcanDelegationStore } from '../ucanDelegationStore';\nimport { normalizeDid } from './normalizeDid';\nimport { decodeCarBase64, verifyGrant, type ChainFailureCode, type UcanVerificationEnv, type VerifiedGrant } from './signedChain';\n\nexport const AUTHORITY_RECHECK_MS = 30_000;\n\nexport type AuthorityDecision =\n | {\n allowed: true;\n /** Grant CID first, then its parents present in the store — the order invocations staple them. */\n proofCids: string[];\n /** Absent when the actor is the room creator acting on their own authority. */\n grant?: VerifiedGrant;\n viaOwner: boolean;\n }\n | {\n allowed: false;\n code: ChainFailureCode | 'NO_GRANT' | 'NOT_A_FLOW_CAPABILITY';\n /** Plain words, shown to people. */\n reason: string;\n };\n\nexport interface FlowAuthorityIndex {\n authorize(actorDid: string, capability: UcanCapability): Promise<AuthorityDecision>;\n /** The cached decision, or `undefined` while it has not been worked out (loading). */\n peek(actorDid: string, capability: UcanCapability): AuthorityDecision | undefined;\n invalidate(): void;\n /** Called after invalidate() and whenever a new decision is cached. */\n subscribe(listener: () => void): () => void;\n}\n\nexport interface FlowAuthorityIndexOptions {\n delegationStore: UcanDelegationStore;\n /** Read on every check: the room may finish loading after the index is made. */\n getOwnerDid: () => string;\n /** `ixo:flow:<doc_id>`. A function when the doc id can change (it loads late; a Design POD pins it to the room id). */\n flowUri: string | (() => string);\n env: UcanVerificationEnv;\n now?: () => number;\n}\n\ninterface CachedDecision {\n decision: AuthorityDecision;\n until: number;\n}\n\ninterface ParsedAudience {\n audience: string;\n /** For ordering: grants on the exact resource first. */\n resources: string[];\n}\n\nconst NO_CACHE_CODES = new Set<string>(['REVOCATION_CHECK_FAILED', 'NO_REVOCATION_CHECKER', 'NO_OWNER']);\n\n/** Most useful failure to show when every candidate grant failed. */\nconst FAILURE_PRIORITY: string[] = ['REVOKED', 'EXPIRED', 'NO_EXPIRATION', 'REVOCATION_CHECK_FAILED', 'NO_REVOCATION_CHECKER', 'NOT_ROOTED_AT_OWNER', 'EXCEEDS_PARENT', 'INVALID_SIGNATURE'];\n\nfunction keyOf(actorDid: string, capability: UcanCapability): string {\n return `${actorDid}\\u0000${capability.can}\\u0000${capability.with}`;\n}\n\nexport function createFlowAuthorityIndex(options: FlowAuthorityIndexOptions): FlowAuthorityIndex {\n const now = options.now ?? Date.now;\n const decisions = new Map<string, CachedDecision>();\n const parsed = new Map<string, ParsedAudience | null>();\n const listeners = new Set<() => void>();\n let generation = 0;\n\n const notify = () => {\n for (const listener of listeners) listener();\n };\n\n async function audienceOf(cid: string, car: string | undefined): Promise<ParsedAudience | null> {\n if (parsed.has(cid)) return parsed.get(cid)!;\n let value: ParsedAudience | null = null;\n if (car) {\n try {\n const extracted = await UcantoDelegation.extract(decodeCarBase64(car));\n const node = extracted.ok as unknown as { cid: { toString(): string }; audience: { did(): string }; capabilities: Array<{ with?: unknown }> } | undefined;\n if (node && node.cid.toString() === cid) {\n value = { audience: normalizeDid(node.audience.did()), resources: node.capabilities.map((capability) => String(capability.with ?? '')) };\n }\n } catch {\n value = null;\n }\n }\n parsed.set(cid, value);\n return value;\n }\n\n const flowUriNow = () => (typeof options.flowUri === 'function' ? options.flowUri() : options.flowUri);\n\n function isFlowCapability(capability: UcanCapability): boolean {\n const flowUri = flowUriNow();\n if (!flowUri || !capability.can.startsWith('flow/')) return false;\n return capability.with === flowUri || capability.with.startsWith(`${flowUri}:`);\n }\n\n async function ownerDecision(owner: string, capability: UcanCapability): Promise<AuthorityDecision> {\n // The owner's pinned self-issued root is stapled for the deployed\n // flow-manager when its signature and dates check out. Expiry is not\n // required of it (roots so far were minted without one); its absence\n // changes nothing about the owner's authority.\n const root = options.delegationStore.getRoot();\n const rootCid = options.delegationStore.getRootCid();\n if (root && rootCid) {\n const verdict = await verifyGrant(root.delegation, { cid: rootCid, actorDid: owner, ownerDid: owner, required: capability, env: options.env, at: now(), coverage: 'hierarchical' });\n if (verdict.ok && !verdict.revokedNow && verdict.grant.issuerDid === owner) {\n return { allowed: true, proofCids: [rootCid], viaOwner: true };\n }\n }\n return { allowed: true, proofCids: [], viaOwner: true };\n }\n\n async function decide(actorDid: string, capability: UcanCapability): Promise<{ decision: AuthorityDecision; until: number }> {\n const owner = options.getOwnerDid() ? normalizeDid(options.getOwnerDid()) : '';\n const recheck = now() + AUTHORITY_RECHECK_MS;\n if (!owner) {\n return { decision: { allowed: false, code: 'NO_OWNER', reason: \"We can't tell who created this flow yet, so nobody's grants can be checked.\" }, until: 0 };\n }\n if (!isFlowCapability(capability)) {\n return { decision: { allowed: false, code: 'NOT_A_FLOW_CAPABILITY', reason: `${capability.can} on ${capability.with} is not part of this flow.` }, until: recheck };\n }\n const actor = normalizeDid(actorDid);\n if (actor === owner) return { decision: await ownerDecision(owner, capability), until: recheck };\n\n const rootCid = options.delegationStore.getRootCid();\n const candidates: Array<{ cid: string; car: string; exact: boolean }> = [];\n for (const record of options.delegationStore.getAll()) {\n if (record.cid === rootCid) continue;\n const signed = await audienceOf(record.cid, record.delegation);\n if (!signed || signed.audience !== actor) continue;\n candidates.push({ cid: record.cid, car: record.delegation, exact: signed.resources.includes(capability.with) });\n }\n if (candidates.length === 0) {\n return { decision: { allowed: false, code: 'NO_GRANT', reason: 'You have not been given this step in this flow.' }, until: recheck };\n }\n candidates.sort((left, right) => Number(right.exact) - Number(left.exact) || (left.cid < right.cid ? -1 : left.cid > right.cid ? 1 : 0));\n\n const failures: Array<{ code: ChainFailureCode; reason: string }> = [];\n for (const candidate of candidates) {\n const verdict = await verifyGrant(candidate.car, { cid: candidate.cid, actorDid: actor, ownerDid: owner, required: capability, env: options.env });\n if (verdict.ok) {\n const inStore = verdict.grant.proofChainCids.filter((cid) => cid !== candidate.cid && options.delegationStore.has(cid)).reverse();\n const until = Math.min(recheck, verdict.grant.expiresAt ?? recheck);\n return { decision: { allowed: true, proofCids: [candidate.cid, ...inStore], grant: verdict.grant, viaOwner: false }, until };\n }\n failures.push({ code: verdict.code, reason: verdict.reason });\n }\n failures.sort((a, b) => {\n const rank = (code: string) => {\n const index = FAILURE_PRIORITY.indexOf(code);\n return index === -1 ? FAILURE_PRIORITY.length : index;\n };\n return rank(a.code) - rank(b.code);\n });\n const worst = failures[0];\n return { decision: { allowed: false, code: worst.code, reason: worst.reason }, until: NO_CACHE_CODES.has(worst.code) ? 0 : recheck };\n }\n\n return {\n async authorize(actorDid, capability) {\n const key = keyOf(normalizeDid(actorDid), capability);\n const cached = decisions.get(key);\n if (cached && cached.until > now()) return cached.decision;\n const started = generation;\n const { decision, until } = await decide(actorDid, capability);\n if (started === generation) {\n if (until > now()) decisions.set(key, { decision, until });\n else decisions.delete(key);\n notify();\n }\n return decision;\n },\n peek(actorDid, capability) {\n const cached = decisions.get(keyOf(normalizeDid(actorDid), capability));\n return cached && cached.until > now() ? cached.decision : undefined;\n },\n invalidate() {\n generation += 1;\n decisions.clear();\n parsed.clear();\n notify();\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n}\n","/**\n * Re-verify step receipts (the `invocations` map) from their signed CARs.\n *\n * A completed step used to count as done when the `invocations` map held a\n * record saying `{ result: 'success', blockId }` — a record any room member\n * could write. A receipt now counts only when its CAR verifies: signed by the\n * recorded actor, addressed to the room creator, for exactly this step,\n * chained to the creator, and valid at the time it was signed (receipts live\n * five minutes, so they are checked as of their signing time, contract §3).\n *\n * Verification is asynchronous and the completion checks that read it are\n * not, so this keeps a cache and answers `pending` until the answer is known,\n * then tells subscribers to re-read.\n */\nimport type { StoredInvocation } from '../../types/ucan';\nimport { normalizeDid } from './normalizeDid';\nimport { verifyInvocation, type UcanVerificationEnv } from './signedChain';\n\nexport type ReceiptStatus =\n | { status: 'verified'; noTimeAnchor?: boolean }\n | { status: 'unverified'; reason: string; revokedSince?: boolean }\n | { status: 'pending' };\n\nexport interface ReceiptExpectation {\n blockId: string;\n}\n\nexport interface ReceiptVerifier {\n /** Cached answer, starting a verification when there is none. */\n check(invocation: StoredInvocation, expected: ReceiptExpectation): ReceiptStatus;\n /** Full answer. */\n verify(invocation: StoredInvocation, expected: ReceiptExpectation): Promise<ReceiptStatus>;\n /**\n * Record a verdict reached elsewhere. The executor verifies every receipt it\n * mints (from the CAR, at signing time) before it runs the step; it hands\n * that verdict over so the reconcile that follows can fire triggers at once\n * instead of waiting for a second verification of the same bytes.\n */\n remember(invocation: StoredInvocation, expected: ReceiptExpectation, status: ReceiptStatus): void;\n subscribe(listener: () => void): () => void;\n}\n\nexport interface ReceiptVerifierOptions {\n getOwnerDid: () => string;\n /** `ixo:flow:<doc_id>`, or a function reading it live. */\n flowUri: string | (() => string);\n env: UcanVerificationEnv;\n now?: () => number;\n /** How long an answer is reused. Revocation can change it; nothing else can. */\n ttlMs?: number;\n}\n\nconst TRANSIENT = new Set(['REVOCATION_CHECK_FAILED', 'NO_REVOCATION_CHECKER', 'NO_OWNER']);\n/** A failure that may clear up (store unreachable, room still loading) is retried soon, not immediately: re-verifying on every render would loop. */\nconst TRANSIENT_TTL_MS = 5_000;\n\nexport function createReceiptVerifier(options: ReceiptVerifierOptions): ReceiptVerifier {\n const now = options.now ?? Date.now;\n const ttlMs = options.ttlMs ?? 30_000;\n const cache = new Map<string, { status: ReceiptStatus; until: number }>();\n const inFlight = new Map<string, Promise<ReceiptStatus>>();\n const listeners = new Set<() => void>();\n\n const keyOf = (invocation: StoredInvocation, expected: ReceiptExpectation) => `${invocation.cid}\\u0000${expected.blockId}\\u0000${invocation.invokerDid}\\u0000${invocation.sessionRunId ?? ''}`;\n\n async function run(invocation: StoredInvocation, expected: ReceiptExpectation): Promise<{ status: ReceiptStatus; transient: boolean }> {\n const owner = options.getOwnerDid() ? normalizeDid(options.getOwnerDid()) : '';\n if (!owner) return { status: { status: 'unverified', reason: \"We can't tell who created this flow yet, so its receipts can't be checked.\" }, transient: true };\n const verdict = await verifyInvocation(invocation.invocation, {\n cid: invocation.cid,\n expectedAudience: owner,\n ownerDid: owner,\n actorDid: invocation.invokerDid,\n required: { can: 'flow/block/execute', with: `${typeof options.flowUri === 'function' ? options.flowUri() : options.flowUri}:${expected.blockId}` },\n // The record's session run (what every surface groups it under) must be\n // the one the signer bound it to.\n ...(invocation.sessionRunId ? { expectedFacts: { sessionRunId: invocation.sessionRunId } } : {}),\n env: options.env,\n at: invocation.executedAt,\n });\n if (!verdict.ok) return { status: { status: 'unverified', reason: verdict.reason }, transient: TRANSIENT.has(verdict.code) };\n if (verdict.revokedNow) {\n // Decision 3: a revoked grant stops the flow. The receipt was valid when\n // signed, but it no longer lets anything happen downstream.\n return { status: { status: 'unverified', reason: 'This step was done under a grant that has since been cancelled.', revokedSince: true }, transient: false };\n }\n return { status: { status: 'verified', ...(verdict.noTimeAnchor ? { noTimeAnchor: true } : {}) }, transient: false };\n }\n\n const verifier: ReceiptVerifier = {\n check(invocation, expected) {\n const key = keyOf(invocation, expected);\n const hit = cache.get(key);\n if (hit && hit.until > now()) return hit.status;\n void verifier.verify(invocation, expected);\n return hit?.status ?? { status: 'pending' };\n },\n verify(invocation, expected) {\n const key = keyOf(invocation, expected);\n const pending = inFlight.get(key);\n if (pending) return pending;\n const request = run(invocation, expected)\n .then(({ status, transient }) => {\n cache.set(key, { status, until: now() + (transient ? TRANSIENT_TTL_MS : ttlMs) });\n for (const listener of listeners) listener();\n return status;\n })\n .finally(() => inFlight.delete(key));\n inFlight.set(key, request);\n return request;\n },\n remember(invocation, expected, status) {\n cache.set(keyOf(invocation, expected), { status, until: now() + ttlMs });\n },\n subscribe(listener) {\n listeners.add(listener);\n return () => listeners.delete(listener);\n },\n };\n return verifier;\n}\n"],"mappings":";;;;;;;;;;AAGA,IAAM,sBAAsB;AAC5B,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB;AAgCxB,SAAS,iBAAiB,OAAuB;AAC/C,QAAM,UAAU,MAAM,KAAK;AAC3B,QAAM,UAAU,QAAQ,YAAY,GAAG;AACvC,SAAO,CAAC,QAAQ,SAAS,GAAG,K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