@seams/wallet 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (281) hide show
  1. package/README.md +3 -3
  2. package/dist/.build-inputs.sha256 +1 -1
  3. package/dist/esm/SeamsWeb/SeamsWeb.js +1 -0
  4. package/dist/esm/SeamsWeb/walletIframe/client/router.js +9 -0
  5. package/dist/esm/SeamsWeb/walletIframe/coordinator.js +8 -0
  6. package/dist/esm/SeamsWeb/walletIframe/shared/messages.js +1 -1
  7. package/dist/esm/core/config/defaultConfigs.js +1 -1
  8. package/dist/esm/core/indexedDB/index.js +2 -1
  9. package/dist/esm/core/indexedDB/schemaNames.js +1 -2
  10. package/dist/esm/core/indexedDB/seamsWalletDB/schema.js +2 -1
  11. package/dist/esm/core/indexedDB/walletDbName.js +6 -0
  12. package/dist/esm/sdk/{ConfirmationDrawer-Frj3uEee.js → ConfirmationDrawer-BFzQjd1P.js} +1 -1
  13. package/dist/esm/sdk/{NonceCoordinator-S5ZbrkDp.js → NonceCoordinator-CDGnEgfI.js} +1 -1
  14. package/dist/{public/sdk/accountLifecycle-HEUmDLus.js → esm/sdk/accountLifecycle-CBOkr0vU.js} +1 -1
  15. package/dist/esm/sdk/{adapters-CGvNLOfZ.js → adapters-DsAaBNNY.js} +2 -2
  16. package/dist/esm/sdk/{challengeDelivery-5lIu9spR.js → challengeDelivery-CATQ4u6P.js} +1 -1
  17. package/dist/{public/sdk/clientSessionPersistenceState-DRdve9rC.js → esm/sdk/clientSessionPersistenceState-CBylL1Ul.js} +1 -1
  18. package/dist/esm/sdk/{commitQueue-qjvY_zWn.js → commitQueue-DYEgzoLA.js} +1 -1
  19. package/dist/esm/sdk/{display-DTbGoX4e.js → display-DsfJkAra.js} +1 -1
  20. package/dist/esm/sdk/{ecdsaCapabilityManifest-ChszYCC0.js → ecdsaCapabilityManifest-DX6TflEz.js} +1 -1
  21. package/dist/{public/sdk/ecdsaDerivationClientWasm-CpH-b3jx.js → esm/sdk/ecdsaDerivationClientWasm-CpjnN4aK.js} +1 -1
  22. package/dist/esm/sdk/ecdsaDerivationExport-CuNIssOt.js +1 -0
  23. package/dist/esm/sdk/{ecdsaWalletRecords-Di_NUxD_.js → ecdsaWalletRecords-CHfrYvKr.js} +1 -1
  24. package/dist/{public/sdk/emailOtpEcdsaDerivationIdentity-p0C1CQva.js → esm/sdk/emailOtpEcdsaDerivationIdentity-Bik0N8v9.js} +1 -1
  25. package/dist/esm/sdk/{enrichDisplayModelWithAbi-DZIhvE-x.js → enrichDisplayModelWithAbi-DSj4NAlY.js} +1 -1
  26. package/dist/esm/sdk/{export-viewer-host-DUMwD6zP.js → export-viewer-host-CV-lSsQF.js} +1 -1
  27. package/dist/esm/sdk/exportKeypairOperation-Bql0I-8U.js +1 -0
  28. package/dist/esm/sdk/host-D3Q_NsmE.js +1 -0
  29. package/dist/esm/sdk/{lanes-Ck81oEGv.js → lanes-5kcTFbPx.js} +1 -1
  30. package/dist/esm/sdk/{localOnly-CUVRoMy2.js → localOnly-C5mSXb_D.js} +1 -1
  31. package/dist/{public/sdk/mountExportPrivateKeySurface-B4gH1Sel.js → esm/sdk/mountExportPrivateKeySurface-CatAhYoG.js} +1 -1
  32. package/dist/{public/sdk/mountRecoveryCodeBackupSurface-D1G-iCPI.js → esm/sdk/mountRecoveryCodeBackupSurface-DlEb3uD7.js} +1 -1
  33. package/dist/esm/sdk/nearEd25519YaoMaterialActivation-Bo3IOTS-.js +1 -0
  34. package/dist/esm/sdk/{nearEd25519YaoSigningPreparation-Eiq_ikXk.js → nearEd25519YaoSigningPreparation-RIfkYN0d.js} +1 -1
  35. package/dist/esm/sdk/{nonceLaneKeys-Do5Vs-De.js → nonceLaneKeys-BCYfl1wv.js} +1 -1
  36. package/dist/esm/sdk/{normalization-DJPmcXTg.js → normalization-n503J-BI.js} +1 -1
  37. package/dist/{public/sdk/passkey-custody-Cd_yyoRa.js → esm/sdk/passkey-custody-DpTM-eNJ.js} +1 -1
  38. package/dist/esm/sdk/{pendingWalletRecoveryCodeBackup-DMg5U0Fk.js → pendingWalletRecoveryCodeBackup-C60sZMj5.js} +1 -1
  39. package/dist/{public/sdk/presignaturePool-CLHu7HaU.js → esm/sdk/presignaturePool-DX_hqZ6Z.js} +1 -1
  40. package/dist/esm/sdk/recovery-entrypoint-BULjaFBM.js +1 -0
  41. package/dist/esm/sdk/{registration-Drtkzrlc.js → registration-CyF7nOXs.js} +1 -1
  42. package/dist/esm/sdk/registration-DEGZR8kA.js +1 -0
  43. package/dist/esm/sdk/{registrationAccounts-DP-32yCK.js → registrationAccounts-BQMUusdD.js} +1 -1
  44. package/dist/{public/sdk/registrationIntent-BHU5k2Q-.js → esm/sdk/registrationIntent-090Zj7Iu.js} +1 -1
  45. package/dist/{public/sdk/registrationSignerPlan-dY9Rp0m_.js → esm/sdk/registrationSignerPlan-CPzHavPM.js} +1 -1
  46. package/dist/esm/sdk/{requireStepUpAuth-FqZSU021.js → requireStepUpAuth-BCY5ZStI.js} +1 -1
  47. package/dist/esm/sdk/routerAbNormalSigning-C4P2tDU-.js +1 -0
  48. package/dist/esm/sdk/runtime-auth-DDOPe7LO.js +1 -0
  49. package/dist/esm/sdk/runtime-device-link-Bkt5AJAI.js +1 -0
  50. package/dist/esm/sdk/runtime-ecdsa-tempo-DUOkCNFT.js +1 -0
  51. package/dist/esm/sdk/runtime-email-otp-Bsv55Gin.js +1 -0
  52. package/dist/esm/sdk/runtime-export-D7QKXvdg.js +1 -0
  53. package/dist/esm/sdk/runtime-near-Bl7bBU2g.js +1 -0
  54. package/dist/esm/sdk/runtime-preferences-C2Rqmp7q.js +1 -0
  55. package/dist/esm/sdk/runtime-recovery-BMY7AkJq.js +1 -0
  56. package/dist/esm/sdk/runtime-recovery-codes-GOytzExh.js +1 -0
  57. package/dist/esm/sdk/secp256k1-CL273JMp.js +1 -0
  58. package/dist/esm/sdk/sessionObservationRevision-CnEOLDbl.js +1 -0
  59. package/dist/esm/sdk/shared-CNT5EU_h.js +6 -0
  60. package/dist/{public/sdk/signEvmFamily-M0trbeZe.js → esm/sdk/signEvmFamily-BE0a14MT.js} +1 -1
  61. package/dist/esm/sdk/{signEvmFamilyWithUiConfirmForTempo-Bo25SwuV.js → signEvmFamilyWithUiConfirmForTempo-DGWmm9n7.js} +1 -1
  62. package/dist/esm/sdk/{signEvmWithUiConfirm-CFcqJRj3.js → signEvmWithUiConfirm-BRmdLgmm.js} +1 -1
  63. package/dist/esm/sdk/signNear-XGZBxc_g.js +1 -0
  64. package/dist/esm/sdk/signer-worker-DlK58rEA.js +1 -0
  65. package/dist/{public/sdk/signingFlow-DZvV4AgG.js → esm/sdk/signingFlow-VAnM8L5C.js} +1 -1
  66. package/dist/esm/sdk/{signingQueue-2pr7lAUS.js → signingQueue-D_Ebmzcn.js} +1 -1
  67. package/dist/esm/sdk/singletons-BXhnsqeY.js +1 -0
  68. package/dist/esm/sdk/{thresholdEcdsa-D-QMyevW.js → thresholdEcdsa-CneSKcRt.js} +1 -1
  69. package/dist/esm/sdk/{trace-QLsbYdld.js → trace-BBux0jtr.js} +1 -1
  70. package/dist/esm/sdk/{transaction-activity-xfeHKJoq.js → transaction-activity-Cccvec2J.js} +1 -1
  71. package/dist/esm/sdk/{transactionState-CGULLokO.js → transactionState-Day-1x7Y.js} +1 -1
  72. package/dist/esm/sdk/{types-WGrFMQSw.js → types-hKLqDUhR.js} +1 -1
  73. package/dist/esm/sdk/wallet-iframe-host-ecdsa.js +1 -1
  74. package/dist/esm/sdk/wallet-iframe-host-full.js +1 -1
  75. package/dist/esm/sdk/wallet-iframe-host-near.js +1 -1
  76. package/dist/esm/sdk/wallet-iframe-host-runtime.js +1 -1
  77. package/dist/esm/sdk/{wallet-recovery-LMtGiEL3.js → wallet-recovery-Bfhfk52N.js} +1 -1
  78. package/dist/esm/sdk/{walletAuthMethodRecord-CnBw27ED.js → walletAuthMethodRecord-LniOQQmj.js} +1 -1
  79. package/dist/{public/sdk/walletAuthority-BWvfaKIX.js → esm/sdk/walletAuthority-CAiGuWW2.js} +1 -1
  80. package/dist/esm/sdk/walletCustodyEcdsaContinuity-B4fTDL10.js +1 -0
  81. package/dist/esm/sdk/{sessionPolicy-CBTZQe1n.js → walletDbName-DtRewci9.js} +1 -1
  82. package/dist/{public/sdk/walletOwnershipGeneration-CAycHv-H.js → esm/sdk/walletOwnershipGeneration-B6HyR2rE.js} +1 -1
  83. package/dist/esm/sdk/walletRecoveryCommit-C6HF84_U.js +1 -0
  84. package/dist/{public/sdk/walletSessionAuthorizationStore-BiKGIBWQ.js → esm/sdk/walletSessionAuthorizationStore-DmYe-cDR.js} +1 -1
  85. package/dist/esm/sdk/warmSessionHydration-CsQpQVuy.js +1 -0
  86. package/dist/public/headers.manifest.json +1 -1
  87. package/dist/public/sdk/{ConfirmationDrawer-Frj3uEee.js → ConfirmationDrawer-BFzQjd1P.js} +1 -1
  88. package/dist/public/sdk/{NonceCoordinator-S5ZbrkDp.js → NonceCoordinator-CDGnEgfI.js} +1 -1
  89. package/dist/{esm/sdk/accountLifecycle-HEUmDLus.js → public/sdk/accountLifecycle-CBOkr0vU.js} +1 -1
  90. package/dist/public/sdk/{adapters-CGvNLOfZ.js → adapters-DsAaBNNY.js} +2 -2
  91. package/dist/public/sdk/{challengeDelivery-5lIu9spR.js → challengeDelivery-CATQ4u6P.js} +1 -1
  92. package/dist/{esm/sdk/clientSessionPersistenceState-DRdve9rC.js → public/sdk/clientSessionPersistenceState-CBylL1Ul.js} +1 -1
  93. package/dist/public/sdk/{commitQueue-qjvY_zWn.js → commitQueue-DYEgzoLA.js} +1 -1
  94. package/dist/public/sdk/{display-DTbGoX4e.js → display-DsfJkAra.js} +1 -1
  95. package/dist/public/sdk/{ecdsaCapabilityManifest-ChszYCC0.js → ecdsaCapabilityManifest-DX6TflEz.js} +1 -1
  96. package/dist/{esm/sdk/ecdsaDerivationClientWasm-CpH-b3jx.js → public/sdk/ecdsaDerivationClientWasm-CpjnN4aK.js} +1 -1
  97. package/dist/public/sdk/ecdsaDerivationExport-CuNIssOt.js +1 -0
  98. package/dist/public/sdk/{ecdsaWalletRecords-Di_NUxD_.js → ecdsaWalletRecords-CHfrYvKr.js} +1 -1
  99. package/dist/{esm/sdk/emailOtpEcdsaDerivationIdentity-p0C1CQva.js → public/sdk/emailOtpEcdsaDerivationIdentity-Bik0N8v9.js} +1 -1
  100. package/dist/public/sdk/{enrichDisplayModelWithAbi-DZIhvE-x.js → enrichDisplayModelWithAbi-DSj4NAlY.js} +1 -1
  101. package/dist/public/sdk/{export-viewer-host-DUMwD6zP.js → export-viewer-host-CV-lSsQF.js} +1 -1
  102. package/dist/public/sdk/exportKeypairOperation-Bql0I-8U.js +1 -0
  103. package/dist/public/sdk/host-D3Q_NsmE.js +1 -0
  104. package/dist/public/sdk/{lanes-Ck81oEGv.js → lanes-5kcTFbPx.js} +1 -1
  105. package/dist/public/sdk/{localOnly-CUVRoMy2.js → localOnly-C5mSXb_D.js} +1 -1
  106. package/dist/{esm/sdk/mountExportPrivateKeySurface-B4gH1Sel.js → public/sdk/mountExportPrivateKeySurface-CatAhYoG.js} +1 -1
  107. package/dist/{esm/sdk/mountRecoveryCodeBackupSurface-D1G-iCPI.js → public/sdk/mountRecoveryCodeBackupSurface-DlEb3uD7.js} +1 -1
  108. package/dist/public/sdk/nearEd25519YaoMaterialActivation-Bo3IOTS-.js +1 -0
  109. package/dist/public/sdk/{nearEd25519YaoSigningPreparation-Eiq_ikXk.js → nearEd25519YaoSigningPreparation-RIfkYN0d.js} +1 -1
  110. package/dist/public/sdk/{nonceLaneKeys-Do5Vs-De.js → nonceLaneKeys-BCYfl1wv.js} +1 -1
  111. package/dist/public/sdk/{normalization-DJPmcXTg.js → normalization-n503J-BI.js} +1 -1
  112. package/dist/{esm/sdk/passkey-custody-Cd_yyoRa.js → public/sdk/passkey-custody-DpTM-eNJ.js} +1 -1
  113. package/dist/public/sdk/{pendingWalletRecoveryCodeBackup-DMg5U0Fk.js → pendingWalletRecoveryCodeBackup-C60sZMj5.js} +1 -1
  114. package/dist/{esm/sdk/presignaturePool-CLHu7HaU.js → public/sdk/presignaturePool-DX_hqZ6Z.js} +1 -1
  115. package/dist/public/sdk/recovery-entrypoint-BULjaFBM.js +1 -0
  116. package/dist/public/sdk/{registration-Drtkzrlc.js → registration-CyF7nOXs.js} +1 -1
  117. package/dist/public/sdk/registration-DEGZR8kA.js +1 -0
  118. package/dist/public/sdk/{registrationAccounts-DP-32yCK.js → registrationAccounts-BQMUusdD.js} +1 -1
  119. package/dist/{esm/sdk/registrationIntent-BHU5k2Q-.js → public/sdk/registrationIntent-090Zj7Iu.js} +1 -1
  120. package/dist/{esm/sdk/registrationSignerPlan-dY9Rp0m_.js → public/sdk/registrationSignerPlan-CPzHavPM.js} +1 -1
  121. package/dist/public/sdk/{requireStepUpAuth-FqZSU021.js → requireStepUpAuth-BCY5ZStI.js} +1 -1
  122. package/dist/public/sdk/routerAbNormalSigning-C4P2tDU-.js +1 -0
  123. package/dist/public/sdk/runtime-auth-DDOPe7LO.js +1 -0
  124. package/dist/public/sdk/runtime-device-link-Bkt5AJAI.js +1 -0
  125. package/dist/public/sdk/runtime-ecdsa-tempo-DUOkCNFT.js +1 -0
  126. package/dist/public/sdk/runtime-email-otp-Bsv55Gin.js +1 -0
  127. package/dist/public/sdk/runtime-export-D7QKXvdg.js +1 -0
  128. package/dist/public/sdk/runtime-near-Bl7bBU2g.js +1 -0
  129. package/dist/public/sdk/runtime-preferences-C2Rqmp7q.js +1 -0
  130. package/dist/public/sdk/runtime-recovery-BMY7AkJq.js +1 -0
  131. package/dist/public/sdk/runtime-recovery-codes-GOytzExh.js +1 -0
  132. package/dist/public/sdk/secp256k1-CL273JMp.js +1 -0
  133. package/dist/public/sdk/sessionObservationRevision-CnEOLDbl.js +1 -0
  134. package/dist/public/sdk/shared-CNT5EU_h.js +6 -0
  135. package/dist/{esm/sdk/signEvmFamily-M0trbeZe.js → public/sdk/signEvmFamily-BE0a14MT.js} +1 -1
  136. package/dist/public/sdk/{signEvmFamilyWithUiConfirmForTempo-Bo25SwuV.js → signEvmFamilyWithUiConfirmForTempo-DGWmm9n7.js} +1 -1
  137. package/dist/public/sdk/{signEvmWithUiConfirm-CFcqJRj3.js → signEvmWithUiConfirm-BRmdLgmm.js} +1 -1
  138. package/dist/public/sdk/signNear-XGZBxc_g.js +1 -0
  139. package/dist/public/sdk/signer-worker-DlK58rEA.js +1 -0
  140. package/dist/{esm/sdk/signingFlow-DZvV4AgG.js → public/sdk/signingFlow-VAnM8L5C.js} +1 -1
  141. package/dist/public/sdk/{signingQueue-2pr7lAUS.js → signingQueue-D_Ebmzcn.js} +1 -1
  142. package/dist/public/sdk/singletons-BXhnsqeY.js +1 -0
  143. package/dist/public/sdk/{thresholdEcdsa-D-QMyevW.js → thresholdEcdsa-CneSKcRt.js} +1 -1
  144. package/dist/public/sdk/{trace-QLsbYdld.js → trace-BBux0jtr.js} +1 -1
  145. package/dist/public/sdk/{transaction-activity-xfeHKJoq.js → transaction-activity-Cccvec2J.js} +1 -1
  146. package/dist/public/sdk/{transactionState-CGULLokO.js → transactionState-Day-1x7Y.js} +1 -1
  147. package/dist/public/sdk/{types-WGrFMQSw.js → types-hKLqDUhR.js} +1 -1
  148. package/dist/public/sdk/wallet-iframe-host-ecdsa.js +1 -1
  149. package/dist/public/sdk/wallet-iframe-host-full.js +1 -1
  150. package/dist/public/sdk/wallet-iframe-host-near.js +1 -1
  151. package/dist/public/sdk/wallet-iframe-host-runtime.js +1 -1
  152. package/dist/public/sdk/{wallet-recovery-LMtGiEL3.js → wallet-recovery-Bfhfk52N.js} +1 -1
  153. package/dist/public/sdk/{walletAuthMethodRecord-CnBw27ED.js → walletAuthMethodRecord-LniOQQmj.js} +1 -1
  154. package/dist/{esm/sdk/walletAuthority-BWvfaKIX.js → public/sdk/walletAuthority-CAiGuWW2.js} +1 -1
  155. package/dist/public/sdk/walletCustodyEcdsaContinuity-B4fTDL10.js +1 -0
  156. package/dist/public/sdk/{sessionPolicy-CBTZQe1n.js → walletDbName-DtRewci9.js} +1 -1
  157. package/dist/{esm/sdk/walletOwnershipGeneration-CAycHv-H.js → public/sdk/walletOwnershipGeneration-B6HyR2rE.js} +1 -1
  158. package/dist/public/sdk/walletRecoveryCommit-C6HF84_U.js +1 -0
  159. package/dist/{esm/sdk/walletSessionAuthorizationStore-BiKGIBWQ.js → public/sdk/walletSessionAuthorizationStore-DmYe-cDR.js} +1 -1
  160. package/dist/public/sdk/warmSessionHydration-CsQpQVuy.js +1 -0
  161. package/dist/public/sdk/workers/ecdsa-derivation-client.worker.js +3 -1
  162. package/dist/public/wallet-assets.manifest.json +233 -209
  163. package/dist/public/wallet-service/index.html +4 -4
  164. package/dist/types/wallet/src/SeamsWeb/publicApi/types.d.ts +7 -0
  165. package/dist/types/wallet/src/SeamsWeb/walletIframe/client/router.d.ts +3 -0
  166. package/dist/types/wallet/src/SeamsWeb/walletIframe/coordinator.d.ts +1 -0
  167. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/emptyWalletStoreReads.d.ts +19 -0
  168. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/requestRouter.d.ts +1 -1
  169. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/runtimeLoader.d.ts +5 -0
  170. package/dist/types/wallet/src/SeamsWeb/walletIframe/host/sessionObservationRevision.d.ts +7 -0
  171. package/dist/types/wallet/src/SeamsWeb/walletIframe/shared/messages.d.ts +3 -3
  172. package/dist/types/wallet/src/core/indexedDB/index.d.ts +2 -1
  173. package/dist/types/wallet/src/core/indexedDB/schemaNames.d.ts +0 -1
  174. package/dist/types/wallet/src/core/indexedDB/seamsWalletDB/manager.d.ts +2 -1
  175. package/dist/types/wallet/src/core/indexedDB/walletDbName.d.ts +2 -0
  176. package/dist/workers/ecdsa-derivation-client.worker.js +3 -1
  177. package/package.json +1 -1
  178. package/dist/esm/sdk/ecdsaDerivationExport-C1cE5m0t.js +0 -1
  179. package/dist/esm/sdk/exportKeypairOperation-BHXMSA3v.js +0 -1
  180. package/dist/esm/sdk/host-GawN20iA.js +0 -1
  181. package/dist/esm/sdk/messages-DgJlG9NU.js +0 -1
  182. package/dist/esm/sdk/nearEd25519YaoMaterialActivation-DMGPKrn8.js +0 -1
  183. package/dist/esm/sdk/recovery-entrypoint-EHY_b7Z-.js +0 -1
  184. package/dist/esm/sdk/registration-CQxxUt5s.js +0 -1
  185. package/dist/esm/sdk/routerAbNormalSigning-DVKFBYgV.js +0 -1
  186. package/dist/esm/sdk/runtime-auth-TZw6JD8N.js +0 -1
  187. package/dist/esm/sdk/runtime-device-link-DXjabXJb.js +0 -1
  188. package/dist/esm/sdk/runtime-ecdsa-tempo-DlKMIbyP.js +0 -1
  189. package/dist/esm/sdk/runtime-email-otp-BBPghU2G.js +0 -1
  190. package/dist/esm/sdk/runtime-export-pw-xJL8o.js +0 -1
  191. package/dist/esm/sdk/runtime-near-B-vYxGjl.js +0 -1
  192. package/dist/esm/sdk/runtime-preferences-D-hY0RfC.js +0 -1
  193. package/dist/esm/sdk/runtime-recovery-Vg1ND2nl.js +0 -1
  194. package/dist/esm/sdk/runtime-recovery-codes-rLR4Guy4.js +0 -1
  195. package/dist/esm/sdk/secp256k1-C-AETUpI.js +0 -1
  196. package/dist/esm/sdk/shared-6bpRPbcM.js +0 -6
  197. package/dist/esm/sdk/signNear-DGUQZ44s.js +0 -1
  198. package/dist/esm/sdk/singletons-8UH3gOnZ.js +0 -1
  199. package/dist/esm/sdk/walletCustodyEcdsaContinuity-D-gYxv6e.js +0 -1
  200. package/dist/esm/sdk/walletRecoveryCommit-BYRC_2li.js +0 -1
  201. package/dist/esm/sdk/warmSessionHydration-B7-kCnJh.js +0 -1
  202. package/dist/public/sdk/ecdsaDerivationExport-C1cE5m0t.js +0 -1
  203. package/dist/public/sdk/exportKeypairOperation-BHXMSA3v.js +0 -1
  204. package/dist/public/sdk/host-GawN20iA.js +0 -1
  205. package/dist/public/sdk/messages-DgJlG9NU.js +0 -1
  206. package/dist/public/sdk/nearEd25519YaoMaterialActivation-DMGPKrn8.js +0 -1
  207. package/dist/public/sdk/recovery-entrypoint-EHY_b7Z-.js +0 -1
  208. package/dist/public/sdk/registration-CQxxUt5s.js +0 -1
  209. package/dist/public/sdk/routerAbNormalSigning-DVKFBYgV.js +0 -1
  210. package/dist/public/sdk/runtime-auth-TZw6JD8N.js +0 -1
  211. package/dist/public/sdk/runtime-device-link-DXjabXJb.js +0 -1
  212. package/dist/public/sdk/runtime-ecdsa-tempo-DlKMIbyP.js +0 -1
  213. package/dist/public/sdk/runtime-email-otp-BBPghU2G.js +0 -1
  214. package/dist/public/sdk/runtime-export-pw-xJL8o.js +0 -1
  215. package/dist/public/sdk/runtime-near-B-vYxGjl.js +0 -1
  216. package/dist/public/sdk/runtime-preferences-D-hY0RfC.js +0 -1
  217. package/dist/public/sdk/runtime-recovery-Vg1ND2nl.js +0 -1
  218. package/dist/public/sdk/runtime-recovery-codes-rLR4Guy4.js +0 -1
  219. package/dist/public/sdk/secp256k1-C-AETUpI.js +0 -1
  220. package/dist/public/sdk/shared-6bpRPbcM.js +0 -6
  221. package/dist/public/sdk/signNear-DGUQZ44s.js +0 -1
  222. package/dist/public/sdk/singletons-8UH3gOnZ.js +0 -1
  223. package/dist/public/sdk/walletCustodyEcdsaContinuity-D-gYxv6e.js +0 -1
  224. package/dist/public/sdk/walletRecoveryCommit-BYRC_2li.js +0 -1
  225. package/dist/public/sdk/warmSessionHydration-B7-kCnJh.js +0 -1
  226. /package/dist/esm/sdk/{accountIds-BzZs7YoX.js → accountIds-Cpvlkvbe.js} +0 -0
  227. /package/dist/esm/sdk/{appearance-DITtYj-z.js → appearance-4DmzKUWf.js} +0 -0
  228. /package/dist/esm/sdk/{authenticatorOptions-C9aCKgeF.js → authenticatorOptions-2_XK8aXv.js} +0 -0
  229. /package/dist/esm/sdk/{browser-DkCRXFkk.js → browser-n3IVr7qu.js} +0 -0
  230. /package/dist/esm/sdk/{digestEncoding-CkUc5vtR.js → digestEncoding-BX3VW9eF.js} +0 -0
  231. /package/dist/esm/sdk/{ecdsaChainTarget-DJBXHzbH.js → ecdsaChainTarget-Bfatk3oP.js} +0 -0
  232. /package/dist/esm/sdk/{helpers-BnkILY2_.js → helpers-B9fpZNAP.js} +0 -0
  233. /package/dist/esm/sdk/{intentDigest-DJBrMyLJ.js → intentDigest-P_-CM7lS.js} +0 -0
  234. /package/dist/esm/sdk/{jsonRpc-YKL5n8VL.js → jsonRpc-BVDv1wfm.js} +0 -0
  235. /package/dist/esm/sdk/{jsxRuntime.module-C8JOKu_4.js → jsxRuntime.module-DKsgiFjd.js} +0 -0
  236. /package/dist/esm/sdk/{keccak-BArcwgbj.js → keccak-mS0Mejjx.js} +0 -0
  237. /package/dist/esm/sdk/{normalization-CeZT7ob0.js → normalization-C6fQN6mW.js} +0 -0
  238. /package/dist/esm/sdk/{operationFingerprint-CUrnoh-M.js → operationFingerprint-BHNYryLY.js} +0 -0
  239. /package/dist/esm/sdk/{presignatures-DZm0d6Wy.js → presignatures-K-yuzOE0.js} +0 -0
  240. /package/dist/esm/sdk/{prfCache-DCkuB8Lu.js → prfCache-DJ93rtDv.js} +0 -0
  241. /package/dist/esm/sdk/{profileAccountProjection-B3LXAUmo.js → profileAccountProjection-BNVJLOt2.js} +0 -0
  242. /package/dist/esm/sdk/{promptText-B8RprJhO.js → promptText-CnyrLxgj.js} +0 -0
  243. /package/dist/esm/sdk/{registrationAuthMethodInput-BBCeWDmw.js → registrationAuthMethodInput-RbSR7R1G.js} +0 -0
  244. /package/dist/esm/sdk/{registrationIds-ByuReLUc.js → registrationIds-BaK3jUS6.js} +0 -0
  245. /package/dist/esm/sdk/{sdkSentEvents-Dl8fOL50.js → sdkSentEvents-D4KtK7_I.js} +0 -0
  246. /package/dist/esm/sdk/{signatureUses-8c8Ku_Fw.js → signatureUses-BKAoDbQd.js} +0 -0
  247. /package/dist/esm/sdk/{signerDomain-DqLCvI-D.js → signerDomain-Dp7BhfmZ.js} +0 -0
  248. /package/dist/esm/sdk/{signerSlot-B4Eq8Oe2.js → signerSlot-FJAGOhmg.js} +0 -0
  249. /package/dist/esm/sdk/{types-DhtByIcQ.js → types-Buoe6179.js} +0 -0
  250. /package/dist/esm/sdk/{walletRecoveryRotate-D_1a8Agl.js → walletRecoveryRotate-BN3H8byw.js} +0 -0
  251. /package/dist/esm/sdk/{walletSessionAuthorizationStatus-BLyzJbU8.js → walletSessionAuthorizationStatus-BL7j2TeM.js} +0 -0
  252. /package/dist/esm/sdk/{webauthnP256-DZCusNY9.js → webauthnP256-BwgxtG5N.js} +0 -0
  253. /package/dist/esm/sdk/{webauthnPromptCoordinator-CS4Xc_jZ.js → webauthnPromptCoordinator-CwJeKiYq.js} +0 -0
  254. /package/dist/public/sdk/{accountIds-BzZs7YoX.js → accountIds-Cpvlkvbe.js} +0 -0
  255. /package/dist/public/sdk/{appearance-DITtYj-z.js → appearance-4DmzKUWf.js} +0 -0
  256. /package/dist/public/sdk/{authenticatorOptions-C9aCKgeF.js → authenticatorOptions-2_XK8aXv.js} +0 -0
  257. /package/dist/public/sdk/{browser-DkCRXFkk.js → browser-n3IVr7qu.js} +0 -0
  258. /package/dist/public/sdk/{digestEncoding-CkUc5vtR.js → digestEncoding-BX3VW9eF.js} +0 -0
  259. /package/dist/public/sdk/{ecdsaChainTarget-DJBXHzbH.js → ecdsaChainTarget-Bfatk3oP.js} +0 -0
  260. /package/dist/public/sdk/{helpers-BnkILY2_.js → helpers-B9fpZNAP.js} +0 -0
  261. /package/dist/public/sdk/{intentDigest-DJBrMyLJ.js → intentDigest-P_-CM7lS.js} +0 -0
  262. /package/dist/public/sdk/{jsonRpc-YKL5n8VL.js → jsonRpc-BVDv1wfm.js} +0 -0
  263. /package/dist/public/sdk/{jsxRuntime.module-C8JOKu_4.js → jsxRuntime.module-DKsgiFjd.js} +0 -0
  264. /package/dist/public/sdk/{keccak-BArcwgbj.js → keccak-mS0Mejjx.js} +0 -0
  265. /package/dist/public/sdk/{normalization-CeZT7ob0.js → normalization-C6fQN6mW.js} +0 -0
  266. /package/dist/public/sdk/{operationFingerprint-CUrnoh-M.js → operationFingerprint-BHNYryLY.js} +0 -0
  267. /package/dist/public/sdk/{presignatures-DZm0d6Wy.js → presignatures-K-yuzOE0.js} +0 -0
  268. /package/dist/public/sdk/{prfCache-DCkuB8Lu.js → prfCache-DJ93rtDv.js} +0 -0
  269. /package/dist/public/sdk/{profileAccountProjection-B3LXAUmo.js → profileAccountProjection-BNVJLOt2.js} +0 -0
  270. /package/dist/public/sdk/{promptText-B8RprJhO.js → promptText-CnyrLxgj.js} +0 -0
  271. /package/dist/public/sdk/{registrationAuthMethodInput-BBCeWDmw.js → registrationAuthMethodInput-RbSR7R1G.js} +0 -0
  272. /package/dist/public/sdk/{registrationIds-ByuReLUc.js → registrationIds-BaK3jUS6.js} +0 -0
  273. /package/dist/public/sdk/{sdkSentEvents-Dl8fOL50.js → sdkSentEvents-D4KtK7_I.js} +0 -0
  274. /package/dist/public/sdk/{signatureUses-8c8Ku_Fw.js → signatureUses-BKAoDbQd.js} +0 -0
  275. /package/dist/public/sdk/{signerDomain-DqLCvI-D.js → signerDomain-Dp7BhfmZ.js} +0 -0
  276. /package/dist/public/sdk/{signerSlot-B4Eq8Oe2.js → signerSlot-FJAGOhmg.js} +0 -0
  277. /package/dist/public/sdk/{types-DhtByIcQ.js → types-Buoe6179.js} +0 -0
  278. /package/dist/public/sdk/{walletRecoveryRotate-D_1a8Agl.js → walletRecoveryRotate-BN3H8byw.js} +0 -0
  279. /package/dist/public/sdk/{walletSessionAuthorizationStatus-BLyzJbU8.js → walletSessionAuthorizationStatus-BL7j2TeM.js} +0 -0
  280. /package/dist/public/sdk/{webauthnP256-DZCusNY9.js → webauthnP256-BwgxtG5N.js} +0 -0
  281. /package/dist/public/sdk/{webauthnPromptCoordinator-CS4Xc_jZ.js → webauthnPromptCoordinator-CwJeKiYq.js} +0 -0
@@ -5,14 +5,14 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1" />
6
6
  <title>Web3Authn Wallet Service</title>
7
7
  <!-- Surface styles are external so strict CSP can keep style-src 'self' -->
8
- <link rel="stylesheet" href="/sdk/wallet-ui.css?v=0.13.0" />
8
+ <link rel="stylesheet" href="/sdk/wallet-ui.css?v=0.14.0" />
9
9
  <!-- Minimal shims some ESM bundles expect (externalized to enable strict CSP) -->
10
- <script src="/sdk/wallet-shims.js?v=0.13.0"></script>
10
+ <script src="/sdk/wallet-shims.js?v=0.14.0"></script>
11
11
  <!-- Hint the browser to fetch the host script earlier -->
12
- <link rel="modulepreload" href="/sdk/wallet-iframe-host-runtime.js?v=0.13.0" crossorigin>
12
+ <link rel="modulepreload" href="/sdk/wallet-iframe-host-runtime.js?v=0.14.0" crossorigin>
13
13
  </head>
14
14
  <body>
15
15
  <!-- sdkBasePath points to the SDK root (e.g. '/sdk'). Load the host directly. -->
16
- <script type="module" src="/sdk/wallet-iframe-host-runtime.js?v=0.13.0"></script>
16
+ <script type="module" src="/sdk/wallet-iframe-host-runtime.js?v=0.14.0"></script>
17
17
  </body>
18
18
  </html>
@@ -62,6 +62,13 @@ export interface EventsCapability {
62
62
  subscribe(listener: SdkLifecycleEventListener): () => void;
63
63
  }
64
64
  export interface AuthMenuCapability {
65
+ /**
66
+ * Downloads the wallet's sign-in code in the background. A signed-out page does
67
+ * not load it until a sign-in starts. Call this on sign-in intent, such as
68
+ * pointer, focus or touch on your sign-in control, so that `open` starts sooner.
69
+ * It never throws; `open` reports any failure.
70
+ */
71
+ prepare(): void;
65
72
  open(request: HostedAuthMenuOpenRequest, anchorElement?: HTMLElement): Promise<HostedAuthMenuOutcome>;
66
73
  cancel(args: {
67
74
  authMenuSessionId: HostedAuthMenuSessionId;
@@ -73,6 +73,7 @@ export declare class WalletIframeRouter {
73
73
  private exactSessionState;
74
74
  private sessionSelectionGeneration;
75
75
  private sessionObservationRevision;
76
+ private walletRuntimePreparedConnectionId;
76
77
  private lastPreferencesChangedPayload;
77
78
  private mirroredConfirmationUiMode;
78
79
  private progressBus;
@@ -392,6 +393,8 @@ export declare class WalletIframeRouter {
392
393
  }): Promise<ActionResult>;
393
394
  resolveExactKeyExportLane(input: ResolveExactKeyExportLaneInput): Promise<ResolveExactKeyExportLaneResult>;
394
395
  exportKeypairWithUI(input: ExportKeypairWithUIInput): Promise<void>;
396
+ /** Asks the wallet host to download its runtime once per connection, ahead of sign-in. */
397
+ prepareWalletHostRuntime(): Promise<void>;
395
398
  openHostedAuthMenu(request: HostedAuthMenuOpenRequest, anchorElement?: HTMLElement): Promise<HostedAuthMenuOutcome>;
396
399
  cancelHostedAuthMenu(args: {
397
400
  authMenuSessionId: HostedAuthMenuSessionId;
@@ -54,6 +54,7 @@ export declare class WalletIframeCoordinator {
54
54
  private initializeConnection;
55
55
  private assertConnecting;
56
56
  getExactSessionState(): Promise<WalletIframeExactSessionState>;
57
+ prepareHostedAuthMenu(): void;
57
58
  openHostedAuthMenu(request: HostedAuthMenuOpenRequest, anchorElement?: HTMLElement): Promise<HostedAuthMenuOutcome>;
58
59
  cancelHostedAuthMenu(args: {
59
60
  authMenuSessionId: HostedAuthMenuSessionId;
@@ -0,0 +1,19 @@
1
+ import type { RuntimeWalletHostRoute } from './requestRouter';
2
+ /**
3
+ * The reads a parent sends when it connects. While this origin stores no wallet,
4
+ * the boot answers them with the values the wallet runtime would return, so a
5
+ * signed-out visitor does not download the runtime.
6
+ */
7
+ export type EmptyWalletStoreRead = RuntimeWalletHostRoute & {
8
+ readonly type: 'PM_GET_EXACT_WALLET_SESSION_STATE' | 'PM_GET_RECENT_UNLOCKS' | 'PM_GET_CONFIRMATION_CONFIG';
9
+ };
10
+ export declare function isEmptyWalletStoreRead(route: RuntimeWalletHostRoute): route is EmptyWalletStoreRead;
11
+ export declare function answerEmptyWalletStoreRead(read: EmptyWalletStoreRead): unknown;
12
+ /**
13
+ * Resolves true only when this origin provably stores no wallet: the wallet
14
+ * database is absent, or every store in it is empty. Any doubt resolves false,
15
+ * and the request goes to the wallet runtime. The probe never creates the
16
+ * database.
17
+ */
18
+ export declare function walletStoreIsEmpty(): Promise<boolean>;
19
+ //# sourceMappingURL=emptyWalletStoreReads.d.ts.map
@@ -2,7 +2,7 @@ import type { ParentToChildEnvelope, ParentToChildType } from '../shared/message
2
2
  type WalletHostRequest<T extends ParentToChildType> = ParentToChildEnvelope & {
3
3
  type: T;
4
4
  };
5
- type BootWalletRequestType = 'PM_ACTIVATE_TRANSACTION_REVIEW' | 'PING' | 'PM_SET_CONFIG' | 'PM_CANCEL' | 'PM_SET_TRANSACTION_VIEW' | 'PM_TRANSACTION_BROADCAST_STARTED';
5
+ type BootWalletRequestType = 'PM_ACTIVATE_TRANSACTION_REVIEW' | 'PING' | 'PM_PREPARE_WALLET_RUNTIME' | 'PM_SET_CONFIG' | 'PM_CANCEL' | 'PM_SET_TRANSACTION_VIEW' | 'PM_TRANSACTION_BROADCAST_STARTED';
6
6
  type NearWalletRequestType = 'PM_REGISTER_WALLET' | 'PM_ADD_WALLET_SIGNER' | 'PM_ADD_PASSKEY' | 'PM_ADD_EMAIL_OTP' | 'PM_REVOKE_AUTH_METHOD' | 'PM_GET_NEAR_PROVISIONING_STATE' | 'PM_SIGN_TX_WITH_ACTIONS' | 'PM_SIGN_AND_SEND_TX' | 'PM_SEND_TRANSACTION' | 'PM_SIGN_DELEGATE_ACTION' | 'PM_SIGN_NEP413';
7
7
  type AuthWalletRequestType = 'PM_OPEN_AUTH_MENU' | 'PM_CANCEL_AUTH_MENU' | 'PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH' | 'PM_UNLOCK' | 'PM_LOCK' | 'PM_LOCK_EXACT_WALLET_SESSION' | 'PM_GET_LAST_WALLET_MOVE_REQUEST' | 'PM_MOVE_WALLET' | 'PM_GET_WALLET_MOVE' | 'PM_GET_WALLET_PLACEMENT' | 'PM_GET_WALLET_SESSION' | 'PM_GET_EXACT_WALLET_SESSION_STATE' | 'PM_GET_RECENT_UNLOCKS';
8
8
  type EcdsaWalletRequestType = 'PM_SIGN_TEMPO' | 'PM_REPORT_TEMPO_BROADCAST_ACCEPTED' | 'PM_REPORT_TEMPO_BROADCAST_REJECTED' | 'PM_REPORT_TEMPO_FINALIZED' | 'PM_REPORT_TEMPO_DROPPED_OR_REPLACED' | 'PM_RECONCILE_TEMPO_NONCE_LANE';
@@ -1,6 +1,11 @@
1
1
  import type { RuntimeWalletHostRoute } from './requestRouter';
2
2
  type WalletHostRuntimeModule = typeof import('./runtime');
3
3
  export declare function loadWalletHostRuntime(route: RuntimeWalletHostRoute): Promise<WalletHostRuntimeModule>;
4
+ /**
5
+ * Downloads the auth runtime ahead of its first request, on sign-in intent. Every
6
+ * runtime kind shares most of its code, so this covers the other kinds too.
7
+ */
8
+ export declare function preloadWalletHostRuntime(): void;
4
9
  export declare function preloadWalletHostRecoveryCodeSurface(): Promise<void>;
5
10
  export {};
6
11
  //# sourceMappingURL=runtimeLoader.d.ts.map
@@ -0,0 +1,7 @@
1
+ /**
2
+ * The parent accepts a session snapshot or lifecycle event only when its revision
3
+ * is newer than the last one it saw. The boot reads and the wallet runtime share
4
+ * this one counter, so a runtime that loads after a boot answer stays in order.
5
+ */
6
+ export declare function nextSessionObservationRevision(): number;
7
+ //# sourceMappingURL=sessionObservationRevision.d.ts.map
@@ -189,10 +189,10 @@ export declare function buildHostedAuthMenuCancelPayload(args: {
189
189
  reason: HostedAuthMenuCancelReason;
190
190
  }): HostedAuthMenuCancelPayload;
191
191
  export declare function parseHostedAuthMenuOutcome(value: unknown): HostedAuthMenuOutcome | null;
192
- export declare const WALLET_PROTOCOL_VERSION: "15.0.0";
192
+ export declare const WALLET_PROTOCOL_VERSION: "16.0.0";
193
193
  export declare const WALLET_IFRAME_PROTOCOL_VERSION_MISMATCH: "WALLET_IFRAME_PROTOCOL_VERSION_MISMATCH";
194
194
  export type WalletProtocolVersion = typeof WALLET_PROTOCOL_VERSION;
195
- export type ParentToChildType = 'PM_SET_TRANSACTION_VIEW' | 'PM_TRANSACTION_BROADCAST_STARTED' | 'PING' | 'PM_SET_CONFIG' | 'PM_ACTIVATE_TRANSACTION_REVIEW' | 'PM_CANCEL' | 'PM_OPEN_AUTH_MENU' | 'PM_CANCEL_AUTH_MENU' | 'PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH' | 'PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION' | 'PM_REGISTER_WALLET' | 'PM_ADD_WALLET_SIGNER' | 'PM_ADD_PASSKEY' | 'PM_ADD_EMAIL_OTP' | 'PM_REVOKE_AUTH_METHOD' | 'PM_UNLOCK' | 'PM_LOCK' | 'PM_LOCK_EXACT_WALLET_SESSION' | 'PM_GET_LAST_WALLET_MOVE_REQUEST' | 'PM_MOVE_WALLET' | 'PM_GET_WALLET_MOVE' | 'PM_GET_WALLET_PLACEMENT' | 'PM_GET_WALLET_SESSION' | 'PM_GET_EXACT_WALLET_SESSION_STATE' | 'PM_GET_NEAR_PROVISIONING_STATE' | 'PM_REQUEST_EMAIL_OTP_CHALLENGE' | 'PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH' | 'PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND' | 'PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID' | 'PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT' | 'PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION' | 'PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL' | 'PM_GET_WALLET_RECOVERY_CODE_STATUS' | 'PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP' | 'PM_ROTATE_WALLET_RECOVERY_CODES' | 'PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE' | 'PM_SIGN_TX_WITH_ACTIONS' | 'PM_SIGN_AND_SEND_TX' | 'PM_SEND_TRANSACTION' | 'PM_SIGN_DELEGATE_ACTION' | 'PM_SIGN_NEP413' | 'PM_SIGN_TEMPO' | 'PM_REPORT_TEMPO_BROADCAST_ACCEPTED' | 'PM_REPORT_TEMPO_BROADCAST_REJECTED' | 'PM_REPORT_TEMPO_FINALIZED' | 'PM_REPORT_TEMPO_DROPPED_OR_REPLACED' | 'PM_RECONCILE_TEMPO_NONCE_LANE' | 'PM_RESOLVE_EXACT_KEY_EXPORT_LANE' | 'PM_EXPORT_KEYPAIR_UI' | 'PM_GET_RECENT_UNLOCKS' | 'PM_SET_CONFIRM_BEHAVIOR' | 'PM_SET_CONFIRMATION_CONFIG' | 'PM_GET_CONFIRMATION_CONFIG' | 'PM_HAS_PASSKEY' | 'PM_LIST_LINKED_DEVICES' | 'PM_REVOKE_LINKED_DEVICE' | 'PM_SCAN_AND_LINK_DEVICE' | 'PM_START_DEVICE2_LINKING_FLOW' | 'PM_DEVICE_LINK_TARGET_FACTOR_ACTION' | 'PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION' | 'PM_CANCEL_DEVICE_LINKING' | 'PM_SYNC_ACCOUNT_FLOW';
195
+ export type ParentToChildType = 'PM_SET_TRANSACTION_VIEW' | 'PM_TRANSACTION_BROADCAST_STARTED' | 'PING' | 'PM_PREPARE_WALLET_RUNTIME' | 'PM_SET_CONFIG' | 'PM_ACTIVATE_TRANSACTION_REVIEW' | 'PM_CANCEL' | 'PM_OPEN_AUTH_MENU' | 'PM_CANCEL_AUTH_MENU' | 'PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH' | 'PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION' | 'PM_REGISTER_WALLET' | 'PM_ADD_WALLET_SIGNER' | 'PM_ADD_PASSKEY' | 'PM_ADD_EMAIL_OTP' | 'PM_REVOKE_AUTH_METHOD' | 'PM_UNLOCK' | 'PM_LOCK' | 'PM_LOCK_EXACT_WALLET_SESSION' | 'PM_GET_LAST_WALLET_MOVE_REQUEST' | 'PM_MOVE_WALLET' | 'PM_GET_WALLET_MOVE' | 'PM_GET_WALLET_PLACEMENT' | 'PM_GET_WALLET_SESSION' | 'PM_GET_EXACT_WALLET_SESSION_STATE' | 'PM_GET_NEAR_PROVISIONING_STATE' | 'PM_REQUEST_EMAIL_OTP_CHALLENGE' | 'PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH' | 'PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND' | 'PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID' | 'PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT' | 'PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION' | 'PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL' | 'PM_GET_WALLET_RECOVERY_CODE_STATUS' | 'PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP' | 'PM_ROTATE_WALLET_RECOVERY_CODES' | 'PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE' | 'PM_SIGN_TX_WITH_ACTIONS' | 'PM_SIGN_AND_SEND_TX' | 'PM_SEND_TRANSACTION' | 'PM_SIGN_DELEGATE_ACTION' | 'PM_SIGN_NEP413' | 'PM_SIGN_TEMPO' | 'PM_REPORT_TEMPO_BROADCAST_ACCEPTED' | 'PM_REPORT_TEMPO_BROADCAST_REJECTED' | 'PM_REPORT_TEMPO_FINALIZED' | 'PM_REPORT_TEMPO_DROPPED_OR_REPLACED' | 'PM_RECONCILE_TEMPO_NONCE_LANE' | 'PM_RESOLVE_EXACT_KEY_EXPORT_LANE' | 'PM_EXPORT_KEYPAIR_UI' | 'PM_GET_RECENT_UNLOCKS' | 'PM_SET_CONFIRM_BEHAVIOR' | 'PM_SET_CONFIRMATION_CONFIG' | 'PM_GET_CONFIRMATION_CONFIG' | 'PM_HAS_PASSKEY' | 'PM_LIST_LINKED_DEVICES' | 'PM_REVOKE_LINKED_DEVICE' | 'PM_SCAN_AND_LINK_DEVICE' | 'PM_START_DEVICE2_LINKING_FLOW' | 'PM_DEVICE_LINK_TARGET_FACTOR_ACTION' | 'PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION' | 'PM_CANCEL_DEVICE_LINKING' | 'PM_SYNC_ACCOUNT_FLOW';
196
196
  interface RpcEnvelope<T extends string = string, P = unknown> {
197
197
  type: T;
198
198
  requestId?: string;
@@ -608,7 +608,7 @@ export type ParentToChildEnvelope = RpcEnvelope<'PM_ACTIVATE_TRANSACTION_REVIEW'
608
608
  view: 'toast' | 'closed';
609
609
  }> | RpcEnvelope<'PM_TRANSACTION_BROADCAST_STARTED', {
610
610
  signedTransaction: string;
611
- }> | RpcEnvelope<'PING'> | RpcEnvelope<'PM_SET_CONFIG', PMSetConfigPayload> | RpcEnvelope<'PM_CANCEL', PMCancelPayload> | RpcEnvelope<'PM_OPEN_AUTH_MENU', PMOpenAuthMenuPayload> | RpcEnvelope<'PM_CANCEL_AUTH_MENU', PMCancelAuthMenuPayload> | RpcEnvelope<'PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH', PMResolveAuthMenuExternalAuthPayload> | RpcEnvelope<'PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION', PMRedeemHostedWalletSeamsSessionPayload> | RpcEnvelope<'PM_REGISTER_WALLET', PMRegisterWalletPayload> | RpcEnvelope<'PM_ADD_WALLET_SIGNER', PMAddWalletSignerPayload> | RpcEnvelope<'PM_ADD_PASSKEY', PMAddPasskeyPayload> | RpcEnvelope<'PM_ADD_EMAIL_OTP', PMAddEmailOtpPayload> | RpcEnvelope<'PM_REVOKE_AUTH_METHOD', PMRevokeAuthMethodPayload> | RpcEnvelope<'PM_UNLOCK', PMUnlockPayload> | RpcEnvelope<'PM_LOCK'> | RpcEnvelope<'PM_LOCK_EXACT_WALLET_SESSION', WalletIframeExactSessionIdentity> | RpcEnvelope<'PM_MOVE_WALLET', {
611
+ }> | RpcEnvelope<'PING'> | RpcEnvelope<'PM_PREPARE_WALLET_RUNTIME'> | RpcEnvelope<'PM_SET_CONFIG', PMSetConfigPayload> | RpcEnvelope<'PM_CANCEL', PMCancelPayload> | RpcEnvelope<'PM_OPEN_AUTH_MENU', PMOpenAuthMenuPayload> | RpcEnvelope<'PM_CANCEL_AUTH_MENU', PMCancelAuthMenuPayload> | RpcEnvelope<'PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH', PMResolveAuthMenuExternalAuthPayload> | RpcEnvelope<'PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION', PMRedeemHostedWalletSeamsSessionPayload> | RpcEnvelope<'PM_REGISTER_WALLET', PMRegisterWalletPayload> | RpcEnvelope<'PM_ADD_WALLET_SIGNER', PMAddWalletSignerPayload> | RpcEnvelope<'PM_ADD_PASSKEY', PMAddPasskeyPayload> | RpcEnvelope<'PM_ADD_EMAIL_OTP', PMAddEmailOtpPayload> | RpcEnvelope<'PM_REVOKE_AUTH_METHOD', PMRevokeAuthMethodPayload> | RpcEnvelope<'PM_UNLOCK', PMUnlockPayload> | RpcEnvelope<'PM_LOCK'> | RpcEnvelope<'PM_LOCK_EXACT_WALLET_SESSION', WalletIframeExactSessionIdentity> | RpcEnvelope<'PM_MOVE_WALLET', {
612
612
  readonly walletId: string;
613
613
  readonly moveId: string;
614
614
  readonly destinationRegion: string;
@@ -1,7 +1,8 @@
1
1
  export { UnifiedIndexedDBManager } from './unifiedIndexedDBManager';
2
2
  export { createIndexedDBNonceLaneCoordinationStore } from './nonceLaneCoordinationStore';
3
3
  export { seamsWalletDB } from './singletons';
4
- export { SEAMS_WALLET_DB_NAME, SEAMS_WALLET_DB_VERSION, SEAMS_WALLET_INDEXES, SEAMS_WALLET_SCHEMA_MANIFEST, SEAMS_WALLET_STORES, assertCanonicalIndexedDBName, createSeamsTestWalletDbName, } from './schemaNames';
4
+ export { SEAMS_WALLET_DB_NAME } from './walletDbName';
5
+ export { SEAMS_WALLET_DB_VERSION, SEAMS_WALLET_INDEXES, SEAMS_WALLET_SCHEMA_MANIFEST, SEAMS_WALLET_STORES, assertCanonicalIndexedDBName, createSeamsTestWalletDbName, } from './schemaNames';
5
6
  export { upgradeSeamsWalletDBSchema } from './seamsWalletDB/schema';
6
7
  export type { SeamsWalletDBConfig } from './seamsWalletDB/schema';
7
8
  export { SeamsWalletDBManager } from './seamsWalletDB/manager';
@@ -1,4 +1,3 @@
1
- export declare const SEAMS_WALLET_DB_NAME: "seams_wallet";
2
1
  export declare const SEAMS_WALLET_DB_VERSION: 24;
3
2
  export declare const SEAMS_WALLET_STORES: {
4
3
  readonly appState: "app_state";
@@ -1,6 +1,7 @@
1
1
  import { type IDBPDatabase } from 'idb';
2
2
  import { type SeamsWalletDBConfig } from './schema';
3
- import { SEAMS_WALLET_DB_NAME, type SeamsWalletStoreName } from '../schemaNames';
3
+ import { type SeamsWalletStoreName } from '../schemaNames';
4
+ import { SEAMS_WALLET_DB_NAME } from '../walletDbName';
4
5
  type SeamsWalletTransactionMode = 'readonly' | 'readwrite';
5
6
  export type SeamsWalletTransactionContext = {
6
7
  db: IDBPDatabase;
@@ -0,0 +1,2 @@
1
+ export declare const SEAMS_WALLET_DB_NAME: "seams_wallet";
2
+ //# sourceMappingURL=walletDbName.d.ts.map
@@ -4310,8 +4310,10 @@ replaceTraps((oldTraps) => ({
4310
4310
  }
4311
4311
  }));
4312
4312
 
4313
- // src/core/indexedDB/schemaNames.ts
4313
+ // src/core/indexedDB/walletDbName.ts
4314
4314
  var SEAMS_WALLET_DB_NAME = "seams_wallet";
4315
+
4316
+ // src/core/indexedDB/schemaNames.ts
4315
4317
  var SEAMS_WALLET_DB_VERSION = 24;
4316
4318
  var SEAMS_WALLET_STORES = {
4317
4319
  appState: "app_state",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@seams/wallet",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "type": "module",
5
5
  "description": "Seams web and runtime TypeScript SDK for NEAR and EVM-family wallets",
6
6
  "main": "./dist/esm/index.js",
@@ -1 +0,0 @@
1
- import{r as e}from"./domainIds-BzkGsRqO.js";import{c as t,u as n}from"./chains-C_X_fNuS.js";import{i as r,r as i}from"./base64-DW79QA0h.js";import{r as a}from"./secureRandomId-LwBFx84B.js";import{o}from"./sessionPolicy-CBTZQe1n.js";import{g as s}from"./capabilityKinds-N8xo_IEh.js";import{r as c}from"./canonicalPrimitives-Dsbsxgxc.js";import{c as l,o as u}from"./ecdsaChainTarget-DJBXHzbH.js";import{i as d,n as f}from"./signerDomain-DqLCvI-D.js";import{$ as p,C as m,J as h,Kt as g,N as _,Nt as v,Ot as y,T as b,Z as ee,en as x,h as te,tn as S,v as C}from"./emailOtpEcdsaDerivationIdentity-p0C1CQva.js";import{B as ne,C as re,E as w,I as ie,R as ae,S as oe,x as se,y as ce,z as le}from"./ecdsaCapabilityManifest-ChszYCC0.js";import{t as ue}from"./signerSlot-B4Eq8Oe2.js";import{r as T}from"./types-WGrFMQSw.js";import{o as de}from"./walletSessionAuthorizationStore-BiKGIBWQ.js";import{t as fe}from"./thresholdEcdsa-D-QMyevW.js";import{p as pe}from"./nearEd25519YaoSigningPreparation-Eiq_ikXk.js";import{a as me,i as he,r as ge}from"./walletSessionAuthorizationProjection-DuU6w0FP.js";import{a as _e,d as ve,i as ye,n as be,u as xe}from"./ecdsaDerivationClientWasm-CpH-b3jx.js";import{a as Se,r as Ce,t as we}from"./walletSessionFailure-YuhraC3P.js";import{a as E,o as D}from"./signingQueue-2pr7lAUS.js";import{t as O}from"./bytes-DZRW2UDg.js";const Te=`router-ab-ed25519-yao-seed-export-v1`;function Ee(e){if(typeof e!=`object`||!e||Array.isArray(e))return null;let t=e,n=typeof t.id==`string`&&t.id.trim()?t.id.trim():void 0;return t.success===!0&&`data`in t&&t.error===void 0?{id:n,success:!0,data:t.data}:t.success===!1&&typeof t.error==`string`&&t.data===void 0?{id:n,success:!1,error:t.error}:null}var k=class extends Error{constructor(e){super(`[OwnerLaneScope] ${e}`),this.name=`OwnerLaneScopeIntegrityError`}},De=class extends Error{constructor(e){super(`[OwnerLaneScope] relink_required: no active canonical wallet auth method (${e})`),this.code=`relink_required`,this.reason=`missing_canonical_owner_binding`,this.name=`OwnerRelinkRequiredError`}};function Oe(e){return e instanceof De&&e.name===`OwnerRelinkRequiredError`&&e.code===`relink_required`}function ke(e){return{walletId:e.walletId,factor:{kind:`passkey`,credentialIdB64u:e.credentialIdB64u},verifier:{kind:`webauthn`,rpId:e.rpId},bindingId:e.walletAuthMethodId}}function Ae(e){let t=String(e.providerSubjectId||``).trim();if(!t)throw new k(`active Email OTP method has no exact local factor`);let n=y({walletId:e.authMethod.walletId,factor:{kind:`email_otp`,provider:t.startsWith(`google:`)?`google`:`email`,providerUserId:t},verifier:{kind:`email_otp_wallet_auth_method`,emailHashHex:e.authMethod.emailHashHex},bindingId:e.authMethod.walletAuthMethodId});if(!n)throw new k(`active Email OTP method has no exact local factor`);return n}function je(e){let t=e.localMethods.filter(t=>t.kind===`email_otp`&&t.status===`active`&&t.walletId===e.authMethod.walletId&&t.emailHashHex===e.authMethod.emailHashHex),n=t[0],r=n?y(n.authority):null;if(t.length!==1||!r||r.walletId!==e.authMethod.walletId||r.bindingId!==e.authMethod.walletAuthMethodId||r.verifier.emailHashHex!==e.authMethod.emailHashHex)throw new k(`active Email OTP method has no exact local factor`);return r}async function A(e){let t=String(e.authMethod.walletId);try{return je({authMethod:e.authMethod,localMethods:await e.stores.listWalletAuthMethodsForWallet(t)})}catch(n){if(!e.stores.readEmailOtpProviderSubjectForWallet)throw n;let r=await e.stores.readEmailOtpProviderSubjectForWallet(t);if(!r)throw n;return Ae({authMethod:e.authMethod,providerSubjectId:r})}}function Me(e){if(e.authority.walletId!==e.authMethod.walletId||e.authority.bindingId!==e.authMethod.walletAuthMethodId)throw new k(`active wallet auth method does not have an exact factor authority binding`);return e.authority}async function Ne(e){return e.authMethod.kind===`passkey`?Me({authMethod:e.authMethod,authority:ke(e.authMethod)}):Me({authMethod:e.authMethod,authority:await A({authMethod:e.authMethod,stores:e.stores})})}function Pe(e){return{auth:{kind:`passkey`,rpId:b(e.authMethod.rpId),credentialIdB64u:e.authMethod.credentialIdB64u},signerSlot:e.signerSlot}}function Fe(e){return{auth:{kind:`passkey`,rpId:b(e.authMethod.rpId),credentialIdB64u:e.authMethod.credentialIdB64u},keyFamily:`ecdsa`}}function Ie(e){if(e.factorAuthority.walletId!==e.authMethod.walletId||e.factorAuthority.bindingId!==e.authMethod.walletAuthMethodId||e.factorAuthority.verifier.emailHashHex!==e.authMethod.emailHashHex||e.authorityRef.walletId!==e.authMethod.walletId||e.authorityRef.walletAuthMethodId!==e.authMethod.walletAuthMethodId)throw new k(`linked Email OTP authority does not match the selected V2 method`);return{auth:{kind:`email_otp`,providerSubjectId:String(e.factorAuthority.factor.providerUserId)},ownerAuthority:{walletAuthMethodId:e.authorityRef.walletAuthMethodId,authorityDigest:e.authorityRef.authorityDigest}}}async function Le(e){let t=await e.stores.getWalletPasskeyAuthenticator({walletId:String(e.authMethod.walletId),credentialId:e.authMethod.credentialIdB64u});if(!t||t.credentialId!==e.authMethod.credentialIdB64u)throw new k(`active Passkey auth method has no exact local authenticator`);let n=ue(t.signerSlot,{min:1});if(n===null)throw new k(`local authenticator signer slot is invalid`);return Pe({authMethod:e.authMethod,signerSlot:n})}async function Re(e){if(e.authMethod.kind===`passkey`)return await Le({authMethod:e.authMethod,stores:e.stores});let t=await A({authMethod:e.authMethod,stores:e.stores}),n=await v({authority:t});return{auth:{kind:`email_otp`,providerSubjectId:String(t.factor.providerUserId)},ownerAuthority:{walletAuthMethodId:n.walletAuthMethodId,authorityDigest:n.authorityDigest}}}function j(e){return e.kind===`credential_free_ecdsa_session_activation_authorization_v1`}function ze(e,t){return e.error||e.message||e.code||t}function M(e){return p({kind:`router_ab_ecdsa_post_registration_session_activation_v1`,public_capability:e.publicCapability,session_policy:{threshold_session_id:e.thresholdSessionId,wallet_session_mint_id:e.walletSessionMintId,ttl_ms:e.ttlMs,remaining_uses:e.remainingUses,runtime_policy_scope:e.runtimePolicyScope}})}function Be(e,t){let n=t.public_identity;return e.applicationBindingDigestB64u===t.context.application_binding_digest_b64u&&e.contextBinding32B64u===n.context_binding_b64u&&e.derivationClientSharePublicKey33B64u===n.derivation_client_share_public_key33_b64u&&e.relayerPublicKey33B64u===n.server_public_key33_b64u&&e.groupPublicKey33B64u===n.threshold_public_key33_b64u&&e.ethereumAddress.toLowerCase()===O(i(n.ethereum_address20_b64u))&&ce(e.publicCapability,t)}function Ve(e,t){let n=e.normal_signing.scope;return n.wallet_id===String(t.walletId)&&n.ecdsa_threshold_key_id===String(t.ecdsaThresholdKeyId)&&n.signing_root_id===String(t.signingRootId)&&n.signing_root_version===String(t.signingRootVersion)}function N(e){let t=e.persistedRoleLocalMaterial.publicFacts;if(!ce(e.sessionActivation.public_capability,e.publicCapability)||e.sessionActivation.session.threshold_session_id!==e.thresholdSessionId||!Ve(e.sessionActivation,t))throw Error(`Strict ECDSA session activation returned a different registered key identity`)}function He(t){let n=t.sessionActivation.activation,r=t.sessionActivation.authorization,i=r.record,a=x(n.public_capability.material_activation),o=0;for(let t of i.capabilitySubjects)t.kind===`sign`&&t.keyFamily===`ecdsa_secp256k1`&&e(t.materialActivation,a)&&(o+=1);if(N({publicCapability:t.publicCapability,persistedRoleLocalMaterial:t.persistedRoleLocalMaterial,thresholdSessionId:t.thresholdSessionId,sessionActivation:n}),String(i.walletId)!==t.walletId||String(i.walletId)!==String(n.public_capability.client_id)||i.authMethodId!==t.persistedRoleLocalMaterial.authority.walletAuthMethodId||i.authorizationId!==n.session.authorization_id||i.quotaId!==n.session.quota_id||i.expiresAtMs!==n.session.expires_at_ms||n.session.remaining_uses!==t.remainingUses||r.operationCredential.walletSessionId!==n.session.wallet_session_id||!e(a,t.persistedRoleLocalMaterial.materialActivation)||o!==1)throw Error(`Strict ECDSA credential-free activation authority does not match its session`)}function P(e){let t=e.persistedRoleLocalMaterial.publicFacts;if(!e.walletId||!e.thresholdSessionId)throw Error(`Strict ECDSA session activation requires exact wallet and session identity`);if(!Number.isSafeInteger(e.ttlMs)||e.ttlMs<1)throw Error(`Strict ECDSA session activation requires a positive ttlMs`);if(!Number.isSafeInteger(e.remainingUses)||e.remainingUses<1)throw Error(`Strict ECDSA session activation requires positive remainingUses`);if(String(t.walletId)!==e.walletId||!Be(t,e.publicCapability))throw Error(`Strict ECDSA session activation requires exact registered role-local material`)}function Ue(e){switch(e.kind){case`rehydrated`:return e;case`device_link_required`:throw Error(`device_link_required: registered ECDSA role-local material is unavailable on this device`);case`corrupt`:throw Error(`Registered ECDSA role-local material is corrupt (${e.reason}): ${e.message}`);default:{let t=e;throw Error(`Unsupported ECDSA role-local material resolution: ${String(t)}`)}}}async function F(e){let t=Ue(await D({purpose:`registration_activation`,source:E(e.persistedRoleLocalMaterial),workerCtx:e.workerCtx}));return{kind:`existing_ecdsa_role_local_material_activated_v1`,roleLocalMaterial:t.liveHandle,roleLocalMaterialRef:t.materialRef,publicFacts:e.persistedRoleLocalMaterial.publicFacts,publicCapability:e.publicCapability}}async function We(e){P(e);let t=await fe(e.relayerUrl,{auth:e.routeAuth,request:M(e)});if(!t.ok)throw Error(ze(t,`Strict ECDSA session activation failed`));return await I({workerCtx:e.workerCtx,publicCapability:e.publicCapability,persistedRoleLocalMaterial:e.persistedRoleLocalMaterial,walletId:e.walletId,thresholdSessionId:e.thresholdSessionId,ttlMs:e.ttlMs,remainingUses:e.remainingUses,runtimePolicyScope:e.runtimePolicyScope,sessionActivation:t.value})}async function I(e){return P(e),N({publicCapability:e.publicCapability,persistedRoleLocalMaterial:e.persistedRoleLocalMaterial,thresholdSessionId:e.thresholdSessionId,sessionActivation:e.sessionActivation}),{sessionActivation:e.sessionActivation,roleLocalActivation:await F(e)}}async function Ge(e){return P(e),He(e),{sessionActivation:e.sessionActivation.activation,authorization:e.sessionActivation.authorization,roleLocalActivation:await F(e)}}async function Ke(e,t){let n=o(e.lanePolicy.runtimePolicyScope);if(!n)throw Error(`Strict ECDSA session activation requires runtimePolicyScope`);let r={workerCtx:e.workerCtx,publicCapability:e.publicCapability,persistedRoleLocalMaterial:e.existingRoleLocalMaterial,walletId:String(e.key.walletId),thresholdSessionId:e.lanePolicy.thresholdSessionId,ttlMs:e.lanePolicy.ttlMs,remainingUses:e.lanePolicy.remainingUses,runtimePolicyScope:n},s=e.sessionActivation?j(e.sessionActivation)?await Ge({...r,sessionActivation:e.sessionActivation}):await I({...r,sessionActivation:e.sessionActivation}):await We({...r,walletSessionMintId:qe(),relayerUrl:e.relayerUrl,routeAuth:e.bootstrapAuth}),c=s.sessionActivation.public_capability.public_identity,l=`authorization`in s?{thresholdSessionId:s.sessionActivation.session.threshold_session_id,authorizationSessionId:s.sessionActivation.session.authorization_session_id,authorizationId:s.sessionActivation.session.authorization_id,walletSessionId:s.sessionActivation.session.wallet_session_id,quotaId:s.sessionActivation.session.quota_id,expiresAtMs:s.sessionActivation.session.expires_at_ms,remainingUses:s.sessionActivation.session.remaining_uses,walletSession:s.authorization.record,operationCredential:s.authorization.operationCredential}:{thresholdSessionId:s.sessionActivation.session.threshold_session_id,authorizationSessionId:s.sessionActivation.session.authorization_session_id,authorizationId:s.sessionActivation.session.authorization_id,walletSessionId:s.sessionActivation.session.wallet_session_id,quotaId:s.sessionActivation.session.quota_id,expiresAtMs:s.sessionActivation.session.expires_at_ms,remainingUses:s.sessionActivation.session.remaining_uses,walletSession:s.sessionActivation.session.wallet_session,operationCredential:s.sessionActivation.session.operation_credential},u=await g({walletId:String(e.key.walletId),signingRootId:e.key.signingRootId,signingRootVersion:e.key.signingRootVersion});return{ok:!0,bootstrapKind:`strict_post_registration`,keygenSessionId:String(e.requestId||``).trim()||a(`tecdsa-keygen`,32,`threshold ECDSA session IDs`),rpId:t,keyHandle:String(e.keyHandle),clientVerifyingShareB64u:c.derivation_client_share_public_key33_b64u,thresholdEcdsaPublicKeyB64u:c.threshold_public_key33_b64u,ethereumAddress:O(i(c.ethereum_address20_b64u)),relayerKeyId:u,relayerVerifyingShareB64u:c.server_public_key33_b64u,participantIds:e.key.participantIds.map(Number),thresholdSessionId:l.thresholdSessionId,authorizationSessionId:l.authorizationSessionId,authorizationId:l.authorizationId,walletSessionId:l.walletSessionId,quotaId:l.quotaId,expiresAtMs:l.expiresAtMs,remainingUses:l.remainingUses,runtimePolicyScope:n,signingRootId:String(e.key.signingRootId),signingRootVersion:String(e.key.signingRootVersion),walletSession:l.walletSession,operationCredential:l.operationCredential,roleLocalActivation:s.roleLocalActivation,routerAbEcdsaDerivationNormalSigning:s.sessionActivation.normal_signing,secretSourceKind:`persisted_role_local`}}function qe(){let e=s(a(`wallet-session-mint`,32,`Wallet Session mint IDs`));if(!e.ok)throw Error(`Failed to create Wallet Session mint identity`);return e.value}async function Je(e){let t=e.touchIdPrompt.getRpId();if(!t)return{ok:!1,code:`invalid_args`,message:`Missing rpId for WebAuthn`};try{return await Ke(e,t)}catch(e){return{ok:!1,code:`strict_post_registration_failed`,message:e instanceof Error?e.message:String(e)}}}const L=`stale_ecdsa_key_identity`;function Ye(e){if(!e)throw Error(`Strict ECDSA session bootstrap requires Wallet Session authority`);switch(e.kind){case`opaque_wallet_session_operation_credential_v1`:return e;case`publishable_key`:throw Error(`Strict ECDSA session bootstrap requires Wallet Session authority`)}throw Error(`Strict ECDSA session bootstrap authority is invalid`)}function Xe(e){let t=String(e.code||``).trim(),n=String(e.message||``).trim().toLowerCase();return t===`stale_session_state`&&n.includes(`threshold-ecdsa bootstrap`)&&n.includes(`client verifying share`)&&n.includes(`integrated key record`)}function Ze(e){let t=String(e.message||e.code||`threshold-ecdsa bootstrap failed`).trim(),n=Xe(e)?L:String(e.code||`threshold_ecdsa_bootstrap_failed`).trim()||`threshold_ecdsa_bootstrap_failed`,r=Error(t||`threshold-ecdsa bootstrap failed`);return r.code=n,r}function Qe(e){let t=Error(e);return t.code=L,t}function $e(e){switch(e.authKind){case`email_otp`:return`email_otp`;case`passkey`:return`passkey`}return`unknown`}function et(e){switch(e.bootstrap.secretSourceKind){case`persisted_role_local`:return e.request.authKind===`email_otp`?se({authSubjectId:e.request.emailOtpWorkerSessionHandle.authSubjectId}):oe({credentialIdB64u:e.request.passkeyCredentialIdB64u,rpId:e.bootstrap.rpId})}}function R(e,t){let n=String(e||``).trim().toLowerCase();if(!/^0x[0-9a-f]{40}$/.test(n))throw Error(`threshold-ecdsa exact activation returned invalid ${t}`);return n}function tt(e){let t=R(e.bootstrapOwnerAddress,`server owner address`);if(t!==R(e.key.thresholdOwnerAddress,`key owner address`))throw Qe(`threshold-ecdsa exact activation owner address mismatches server bootstrap result`);return t}async function nt(e,t){let n=l(String(t.key.walletId)),r=t.lanePolicy.chainTarget,i=String(t.lanePolicy.thresholdSessionId).trim();if(e.routerAbNormalSigning.mode!==`enabled`)throw Error(`Router A/B ECDSA derivation normal signing must be enabled for activation`);let a={walletId:n,chainTarget:r,targetKey:u(r),operationId:i||null,authMethod:$e(t),evmFamilyKeyFingerprint:te(t.key),keyHandle:t.keyHandle,chainTargetKey:u(r),ecdsaThresholdKeyId:String(t.key.ecdsaThresholdKeyId),thresholdSessionId:i||null,freshAuthRetrySideEffectState:`not_applicable`,hasRequestedEcdsaThresholdKeyId:!0,requestedSessionId:i||null,authKind:t.walletSessionRouteAuth?.kind||`none`,passkeyCredentialBound:t.authKind===`passkey`},o;try{o=await Je({touchIdPrompt:e.touchIdPrompt,relayerUrl:t.relayerUrl,requestId:t.requestId,workerCtx:e.workerCtx,...`preauthorizedSessionActivation`in t&&t.preauthorizedSessionActivation?{sessionActivation:t.preauthorizedSessionActivation}:{bootstrapAuth:Ye(t.walletSessionRouteAuth)},keyHandle:t.keyHandle,key:t.key,lanePolicy:t.lanePolicy,publicCapability:t.publicCapability,existingRoleLocalMaterial:t.existingRoleLocalMaterial})}catch(e){try{console.warn(`[threshold-ecdsa][bootstrap][exception]`,{...a,message:e instanceof Error?e.message:String(e)})}catch{}throw e}if(!o.ok){try{console.warn(`[threshold-ecdsa][bootstrap][failure]`,{...a,code:o.code||``,message:o.message||``})}catch{}throw Ze({code:o.code,message:o.message})}let s=String(t.key.ecdsaThresholdKeyId).trim();if(!s)throw Error(`threshold-ecdsa bootstrap returned empty ecdsaThresholdKeyId`);let c=ie(s),d=le(String(o.keyHandle||``).trim()),f=String(o.relayerKeyId||``).trim();if(!f)throw Error(`threshold-ecdsa bootstrap returned empty relayerKeyId`);let p=ne(f),m=String(o.clientVerifyingShareB64u||``).trim();if(!m)throw Error(`threshold-ecdsa bootstrap returned empty clientVerifyingShareB64u`);let h=ae(m),g=String(o.thresholdSessionId||``).trim();if(!g)throw Error(`threshold-ecdsa bootstrap returned empty thresholdSessionId`);let _=Number(o.expiresAtMs);if(!Number.isFinite(_))throw Error(`threshold-ecdsa bootstrap returned invalid expiresAtMs`);let v=Number(o.remainingUses);if(!Number.isFinite(v))throw Error(`threshold-ecdsa bootstrap returned invalid remainingUses`);let y=t.key.participantIds.map(e=>Number(e));if(!y)throw Error(`threshold-ecdsa bootstrap returned empty participantIds`);let b=tt({key:t.key,bootstrapOwnerAddress:o.ethereumAddress}),ee=re({walletId:n,chainTarget:r,keyHandle:d,ecdsaThresholdKeyId:c,signingRootId:o.signingRootId,signingRootVersion:o.signingRootVersion,applicationBindingDigestB64u:o.roleLocalActivation.publicCapability.context.application_binding_digest_b64u,clientParticipantId:1,relayerParticipantId:2,participantIds:y,contextBinding32B64u:o.roleLocalActivation.publicFacts.contextBinding32B64u,derivationClientSharePublicKey33B64u:o.roleLocalActivation.publicFacts.derivationClientSharePublicKey33B64u,relayerPublicKey33B64u:o.roleLocalActivation.publicFacts.relayerPublicKey33B64u,groupPublicKey33B64u:o.roleLocalActivation.publicFacts.groupPublicKey33B64u,ethereumAddress:o.roleLocalActivation.publicFacts.ethereumAddress,publicCapability:o.roleLocalActivation.publicCapability}),x=o.routerAbEcdsaDerivationNormalSigning,S=o.roleLocalActivation.roleLocalMaterial,C=et({request:t,bootstrap:o}),w={ok:!0,thresholdSessionId:g,authorizationSessionId:o.authorizationSessionId,authorizationId:o.authorizationId,walletSessionId:o.walletSessionId,quotaId:o.quotaId,expiresAtMs:_,remainingUses:v,runtimePolicyScope:o.runtimePolicyScope,walletSession:o.walletSession,operationCredential:o.operationCredential,clientVerifyingShareB64u:h};return{thresholdEcdsaKeyRef:{type:`threshold-ecdsa-secp256k1`,userId:n,chainTarget:r,relayerUrl:t.relayerUrl,keyHandle:d,ecdsaThresholdKeyId:c,backendBinding:{materialKind:`role_local_worker_handle`,relayerKeyId:p,clientVerifyingShareB64u:h,roleLocalMaterialHandle:S,roleLocalMaterialRef:o.roleLocalActivation.roleLocalMaterialRef,publicFacts:ee,authMethod:C},participantIds:y,thresholdEcdsaPublicKeyB64u:o.thresholdEcdsaPublicKeyB64u,ethereumAddress:b,relayerVerifyingShareB64u:o.relayerVerifyingShareB64u,routerAbEcdsaDerivationNormalSigning:x},session:w}}async function rt(e,t){return await nt(e,t)}function it(e){let t;try{t=c(e.evidenceSetDigest)}catch(e){throw Error(e instanceof Error?e.message:`ECDSA explicit export evidence digest is invalid`)}let n=Math.floor(Number(e.expiresAtMs)),r=ee(e.operation);if(r.operation_kind!==`evm.export_key`)throw Error(`ECDSA explicit export operation kind is invalid`);if(!Number.isSafeInteger(n)||n<=Date.now())throw Error(`ECDSA explicit export operation authorization expiry is invalid`);let i=at(e.unseal);return{kind:`verified_step_up`,evidenceSetDigest:t,operation:r,expiresAtMs:n,quotaUse:`none`,unseal:i}}function at(e){switch(e.kind){case`not_requested`:return{kind:`not_requested`};case`email_otp_grant`:{let t=String(e.grant||``).trim(),n=String(e.challenge_id||``).trim();if(!t||!n)throw Error(`ECDSA explicit export Email OTP unseal grant is invalid`);return{kind:`email_otp_grant`,grant:t,challenge_id:n}}default:{let t=e;throw Error(`Unsupported ECDSA explicit export unseal state: ${String(t)}`)}}}async function z(e){let t=String(e.relayerUrl||``).trim();if(!t)throw Error(`ECDSA explicit export relayer URL is required`);return{kind:`explicit_key_export_ecdsa_activation_result`,purpose:`explicit_key_export`,material:{kind:`auth_neutral_ecdsa_export_material_v1`,relayerUrl:t,persistedMaterial:e.existingRoleLocalMaterial},authorization:it(e.authorization)}}function B(e,t){let n=String(e||t||``).trim();if(!n)throw Error(`Missing relayer url (configs.network.relayer.url)`);return n}function V(e){return`key`in e&&!!e.key&&`keyHandle`in e&&!!String(e.keyHandle||``).trim()}function H(e){return V(e)?e.key.walletId:e.walletId}function U(e){return V(e)?e.lanePolicy.chainTarget:e.chainTarget}function ot(e){return e.kind===`email_otp_ecdsa_bootstrap`?{authMethod:f.emailOtp,signerSource:d.emailOtpRegistration}:{authMethod:f.passkey,signerSource:d.passkeyRegistration}}function st(e){switch(e.kind){case`passkey_preauthorized_ecdsa_bootstrap`:case`wallet_session_reconnect_ecdsa_bootstrap`:return e.authorizationAuthority;case`passkey_fresh_ecdsa_bootstrap`:case`email_otp_ecdsa_bootstrap`:return e.existingRoleLocalMaterial.authority}}function ct(e){if(!(`sessionActivation`in e.request)||!e.request.sessionActivation)return;let t=e.request.sessionActivation,n=j(t)?t.activation:t,r=j(t)?t.authorization:{record:t.session.wallet_session,operationCredential:t.session.operation_credential};me({walletId:e.walletId,authority:e.authority,walletSession:r.record,operationCredential:r.operationCredential,expectedAuthorizationId:n.session.authorization_id,expectedWalletSessionId:n.session.wallet_session_id,expectedQuotaId:n.session.quota_id,expectedExpiresAtMs:n.session.expires_at_ms}),e.request.kind===`passkey_preauthorized_ecdsa_bootstrap`&&he({expected:e.request.authorizationIdentity,walletSession:r.record})}function lt(e,t){let n=(e,n,r)=>({kind:`session_bootstrap`,purpose:`transaction_signing`,relayerUrl:t,keyHandle:m(e.keyHandle),key:e.key,lanePolicy:e.lanePolicy,publicCapability:e.publicCapability,existingRoleLocalMaterial:e.existingRoleLocalMaterial,...e.requestId?{requestId:e.requestId}:{},...r,...n?{walletSessionRouteAuth:n}:{}}),r=e=>({kind:`session_bootstrap`,purpose:`transaction_signing`,relayerUrl:t,keyHandle:m(e.keyHandle),key:e.key,lanePolicy:e.lanePolicy,publicCapability:e.publicCapability,existingRoleLocalMaterial:e.existingRoleLocalMaterial,...e.requestId?{requestId:e.requestId}:{},authKind:`passkey`,passkeyCredentialIdB64u:e.passkeyCredentialIdB64u,preauthorizedSessionActivation:e.sessionActivation});switch(e.kind){case`passkey_fresh_ecdsa_bootstrap`:return n(e,e.routeAuth,{authKind:`passkey`,passkeyCredentialIdB64u:e.passkeyCredentialIdB64u});case`passkey_preauthorized_ecdsa_bootstrap`:return r(e);case`wallet_session_reconnect_ecdsa_bootstrap`:return n(e,e.routeAuth,{authKind:`passkey`,passkeyCredentialIdB64u:e.passkeyCredentialIdB64u});case`email_otp_ecdsa_bootstrap`:{let r={authKind:`email_otp`,emailOtpWorkerSessionHandle:e.emailOtpWorkerSessionHandle};return e.sessionActivation?{kind:`session_bootstrap`,purpose:`transaction_signing`,relayerUrl:t,keyHandle:m(e.keyHandle),key:e.key,lanePolicy:e.lanePolicy,publicCapability:e.publicCapability,existingRoleLocalMaterial:e.existingRoleLocalMaterial,...e.requestId?{requestId:e.requestId}:{},...r,preauthorizedSessionActivation:e.sessionActivation}:n(e,e.routeAuth,r)}}throw Error(`[SigningEngine][ecdsa] unsupported ECDSA bootstrap request`)}function ut(e,t){return{purpose:`explicit_key_export`,relayerUrl:t,existingRoleLocalMaterial:e.existingRoleLocalMaterial,authorization:e.authorization}}function dt(e,t){return{purpose:`explicit_key_export`,relayerUrl:t,existingRoleLocalMaterial:e.existingRoleLocalMaterial,authorization:e.authorization}}async function ft(e,t){if(t.kind===`reuse_warm_ecdsa_bootstrap`)throw Error(`[SigningEngine][ecdsa] reuse_warm bootstrap must resolve an existing exact material request before activation`);let n=st(t),r=l(H(t)),i=U(t),a=B(t.relayerUrl,e.defaultRelayerUrl),o=e.getSignerWorkerContext(),s={touchIdPrompt:e.touchIdPrompt,workerCtx:o,routerAbNormalSigning:e.routerAbNormalSigning};ct({request:t,walletId:r,authority:n});let c=await rt(s,lt(t,a)),u=ot(t);return await e.persistThresholdEcdsaBootstrapForWalletTarget({walletId:r,chainTarget:i,bootstrap:c,signerAuth:u}),await t.beforeAuthorizationPersistence?.(),await ge(de,{walletId:r,authority:n,bootstrap:c}),c}async function pt(e,t){return await z(ut(t,B(t.relayerUrl,e.defaultRelayerUrl)))}async function mt(e,t){return await z(dt(t,B(t.relayerUrl,e.defaultRelayerUrl)))}async function W(e,t,n){let r=String(t),i=(e.get(r)||Promise.resolve()).catch(()=>void 0),a,o=new Promise(e=>{a=e}),s=i.then(()=>o);e.set(r,s),await i;try{return await n()}finally{a(),e.get(r)===s&&e.delete(r)}}function ht(e,t){return t.runtimeScopeBootstrap&&(e.runtimeScopeBootstrap=t.runtimeScopeBootstrap),t.operationIntent&&(e.operationIntent=t.operationIntent),typeof t.ttlMs==`number`&&(e.ttlMs=t.ttlMs),e}function G(e){return ht({kind:`email_otp_ecdsa_activation`,purpose:`transaction_signing`,walletKey:e.walletKey,lanePolicy:e.lanePolicy,publicCapability:e.publicCapability,existingRoleLocalMaterial:e.existingRoleLocalMaterial,source:e.source,relayerUrl:e.relayerUrl,sessionIdentity:e.sessionIdentity,sessionKind:e.sessionKind,sessionBudgetUses:e.sessionBudgetUses,runtimePolicy:e.runtimePolicy,emailOtpWorkerSessionHandle:e.emailOtpWorkerSessionHandle,emailOtpAuthContext:e.emailOtpAuthContext,...`preauthorizedSessionActivation`in e?{preauthorizedSessionActivation:e.preauthorizedSessionActivation}:{walletSessionRouteAuth:e.walletSessionRouteAuth}},e)}function K(e){if(pe(e.context)!==e.expected)throw Error(`Email OTP ${e.label} activation requires ${e.expected} retention`)}function gt(e){return K({context:e.emailOtpAuthContext,expected:`session`,label:`session bootstrap`}),G(e)}function _t(e){return K({context:e.emailOtpAuthContext,expected:`session`,label:`recovered session`}),G(e)}function vt(e){return K({context:e.emailOtpAuthContext,expected:`session`,label:`preauthorized session bootstrap`}),G(e)}function yt(e){return K({context:e.emailOtpAuthContext,expected:`single_use`,label:`per-operation reauth`}),G(e)}function bt(e){return{kind:`email_otp_ecdsa_export_activation`,purpose:`explicit_key_export`,existingRoleLocalMaterial:e.existingRoleLocalMaterial,relayerUrl:e.relayerUrl,authorization:e.authorization}}function xt(e){return{kind:`passkey_ecdsa_export_activation`,purpose:`explicit_key_export`,existingRoleLocalMaterial:e.existingRoleLocalMaterial,relayerUrl:e.relayerUrl,authorization:e.authorization}}function St(e){switch(e.kind){case`default_policy`:return;case`scoped_policy`:return e.scope}throw Error(`[SigningEngine][ecdsa] unsupported ECDSA activation policy`)}function q(e,t){t.runtimeScopeBootstrap&&(e.runtimeScopeBootstrap=t.runtimeScopeBootstrap),t.operationIntent&&(e.operationIntent=t.operationIntent);let n=St(t.runtimePolicy);return`walletId`in e&&(typeof t.ttlMs==`number`&&(e.ttlMs=t.ttlMs),n&&(e.runtimePolicyScope=n)),e}function Ct(e){switch(e.kind){case`passkey_ecdsa_activation`:return{kind:`passkey_existing_session_activation`,request:e};case`email_otp_ecdsa_activation`:return{kind:`email_otp_existing_session_activation`,request:e}}throw Error(`[SigningEngine][ecdsa] unsupported activation request`)}function wt(e){let t=String(e.webauthnAuthentication.rawId||e.webauthnAuthentication.id||``).trim();if(!t)throw Error(`[SigningEngine][ecdsa] passkey activation requires credential identity`);return t}function Tt(e){let t=Ct(e);switch(t.kind){case`passkey_existing_session_activation`:return q({kind:`passkey_fresh_ecdsa_bootstrap`,keyHandle:t.request.walletKey.keyHandle,key:C(t.request.walletKey),lanePolicy:t.request.lanePolicy,publicCapability:t.request.publicCapability,existingRoleLocalMaterial:t.request.existingRoleLocalMaterial,source:t.request.source,relayerUrl:t.request.relayerUrl,requestId:t.request.requestId,passkeyCredentialIdB64u:wt(t.request),routeAuth:t.request.walletSessionRouteAuth},t.request);case`email_otp_existing_session_activation`:{let e={kind:`email_otp_ecdsa_bootstrap`,keyHandle:t.request.walletKey.keyHandle,key:C(t.request.walletKey),lanePolicy:t.request.lanePolicy,publicCapability:t.request.publicCapability,existingRoleLocalMaterial:t.request.existingRoleLocalMaterial,source:`email_otp`,relayerUrl:t.request.relayerUrl,emailOtpWorkerSessionHandle:t.request.emailOtpWorkerSessionHandle,emailOtpAuthContext:t.request.emailOtpAuthContext};return t.request.preauthorizedSessionActivation?q({...e,sessionActivation:t.request.preauthorizedSessionActivation},t.request):q({...e,routeAuth:t.request.walletSessionRouteAuth},t.request)}}throw Error(`[SigningEngine][ecdsa] unsupported activation request`)}function Et(e){return{kind:`passkey_ecdsa_export_bootstrap`,purpose:`explicit_key_export`,existingRoleLocalMaterial:e.existingRoleLocalMaterial,relayerUrl:e.relayerUrl,authorization:e.authorization}}async function Dt(e){let t=e.bootstrap.thresholdEcdsaKeyRef.backendBinding;if(!t)throw Error(`[WarmSessionStore] threshold ECDSA bootstrap is missing its backend binding`);let n=Ot(t);if(!n)return;let r=await e.deps.persistEcdsaRoleLocalReadyRecord({record:n,storageKeyFacts:w(n)});if(!r.ok)throw Error(`[WarmSessionStore] threshold ECDSA role-local ready record persistence failed (${r.code}): ${r.message}`)}function Ot(e){switch(e.materialKind){case`role_local_ready_state_blob`:return e.ecdsaRoleLocalReadyRecord;case`role_local_worker_handle`:case`role_local_durable_public_anchor`:case`role_local_durable_sealed_ref`:case`metadata_only`:return null;default:{let t=e;throw Error(`[WarmSessionStore] unsupported threshold ECDSA backend binding: ${JSON.stringify(t)}`)}}}async function J(e,t){let n=l(H(t));return await W(e.queueByWallet,n,async()=>{let n=await ft(e.activationDeps,t);return await Dt({deps:e,bootstrap:n}),n})}async function kt(e,t){return await J(e,Tt(t))}async function At(e,t){return await pt(e.activationDeps,Et(t))}async function jt(e,t){let n={kind:`email_otp_ecdsa_export_bootstrap`,purpose:`explicit_key_export`,existingRoleLocalMaterial:t.existingRoleLocalMaterial,relayerUrl:t.relayerUrl,authorization:t.authorization};return await mt(e.activationDeps,n)}const Y=`ecdsa-derivation:role-local:product-export-confirmation:v5`,X=`ecdsa-derivation:role-local:product-export-authorization:v5`;function Mt(e){return{kind:`operation_step_up`}}function Z(e){return{authorizationKind:e.kind,authorizationId:e.evidenceSetDigest}}function Q(){let e=globalThis.crypto;if(!e||typeof e.getRandomValues!=`function`)throw Error(`crypto.getRandomValues is required for threshold ECDSA export`);return r(e.getRandomValues(new Uint8Array(32)))}async function Nt(e){let t=String(e.relayerUrl||``).trim().replace(/\/+$/g,``);if(!t)throw Error(`[SigningEngine][ecdsa-export] relayer URL is required`);if(e.authorization.kind===`wallet_session_bearer`&&!e.authorization.token.trim())throw Error(`[SigningEngine][ecdsa-export] Wallet Session operation credential is required`);let n={"Content-Type":`application/json`};e.authorization.kind===`wallet_session_bearer`&&(n.Authorization=`Bearer ${e.authorization.token}`);try{let r=await fetch(`${t}${_}`,{method:`POST`,credentials:e.authorization.kind===`legacy_cookie`?`include`:`omit`,headers:n,body:JSON.stringify({request:e.request,requestDigestB64u:e.requestDigestB64u})}),i=await r.json().catch(()=>null);if(!r.ok){let e=i&&typeof i==`object`&&!Array.isArray(i)?i:null;return{ok:!1,code:String(e?.code||`http_error`),message:String(e?.message||`HTTP ${r.status}`)}}return{ok:!0,value:h(i)}}catch(e){return{ok:!1,error:e instanceof Error?e.message:String(e)}}}async function Pt(e){return await Nt({...e,authorization:{kind:`legacy_cookie`}})}async function Ft(e){return await Nt({relayerUrl:e.relayerUrl,request:e.request,requestDigestB64u:e.requestDigestB64u,authorization:{kind:`wallet_session_bearer`,token:e.operationCredential.token}})}function It(e){let t=Math.min(e.issuedAtUnixMs+6e4,e.authorizationExpiresAtMsCeiling??1/0);if(Number.isFinite(t)&&t>e.issuedAtUnixMs)return t;throw new we({failure:Ce(Se.expired),message:`Wallet Session expired before ECDSA export authorization`})}function Lt(e){if(String(e.material.persistedMaterial.publicFacts.walletId)!==String(e.walletSessionUserId))throw Error(`[SigningEngine][ecdsa-export] explicit export wallet mismatch`)}async function $(e){return r(await n(t(e)))}function Rt(e){switch(e.kind){case`rehydrated`:return e;case`device_link_required`:throw Error(`[SigningEngine][ecdsa-export] device_link_required: local threshold ECDSA material is unavailable`);case`corrupt`:throw Error(`[SigningEngine][ecdsa-export] local threshold ECDSA material is corrupt (${e.reason}): ${e.message}`);default:{let t=e;throw Error(`Unsupported ECDSA export material resolution: ${String(t)}`)}}}async function zt(e){return Rt(await D({purpose:`explicit_key_export`,source:E(e.persistedMaterial),workerCtx:e.workerCtx}))}function Bt(e){let t=Z(e.material.operationAuthorization),n=e.material.persistedMaterial.publicFacts;return{version:X,operation:`explicit_key_export`,keyHandle:n.keyHandle,walletId:String(n.walletId),ecdsaThresholdKeyId:e.ecdsaThresholdKeyId,relayerKeyId:n.publicCapability.signer_set.selected_server.server_id,signingRootId:e.signingRootId,signingRootVersion:e.signingRootVersion,contextBinding32B64u:e.contextBinding32B64u,publicIdentity:e.publicIdentity,exportRequestNonce32B64u:e.exportRequestNonce32B64u,confirmationDigest32B64u:e.confirmationDigest32B64u,issuedAtUnixMs:e.issuedAtUnixMs,expiresAtUnixMs:e.expiresAtUnixMs,authorizationKind:t.authorizationKind,authorizationId:t.authorizationId,materialActivation:S(e.material.persistedMaterial.materialActivation),participantIds:n.participantIds}}async function Vt(e,t){let n=t.persistedMaterial.publicFacts,r=S(t.persistedMaterial.materialActivation);switch(t.factorAuthorization.kind){case`passkey`:{let e=String(t.factorAuthorization.credential.rawId||t.factorAuthorization.credential.id||``).trim();if(!e)throw Error(`[SigningEngine][ecdsa-export] passkey authorization credential is missing`);if(e!==t.factorAuthorization.passkeyCredentialIdB64u)throw Error(`[SigningEngine][ecdsa-export] passkey export authorization credential mismatch`);break}case`email_otp_verified`:break;default:{let e=t.factorAuthorization;throw Error(`Unsupported ECDSA export authorization: ${String(e)}`)}}let i=Date.now(),a=It({issuedAtUnixMs:i,authorizationExpiresAtMsCeiling:t.operationAuthorization.expiresAtMs}),o={derivationClientSharePublicKey33B64u:n.derivationClientSharePublicKey33B64u,relayerPublicKey33B64u:n.relayerPublicKey33B64u,groupPublicKey33B64u:n.groupPublicKey33B64u,ethereumAddress:n.ethereumAddress},s=Q(),c=Z(t.operationAuthorization),l=await $({version:Y,walletId:String(n.walletId),ecdsaThresholdKeyId:n.ecdsaThresholdKeyId,relayerKeyId:n.publicCapability.signer_set.selected_server.server_id,contextBinding32B64u:n.contextBinding32B64u,publicIdentity:o,authorizationKind:c.authorizationKind,authorizationId:c.authorizationId,materialActivation:r,exportRequestNonce32B64u:s,issuedAtUnixMs:i,expiresAtUnixMs:a}),u=await $(Bt({ecdsaThresholdKeyId:n.ecdsaThresholdKeyId,signingRootId:n.signingRootId,signingRootVersion:n.signingRootVersion,contextBinding32B64u:n.contextBinding32B64u,publicIdentity:o,exportRequestNonce32B64u:s,confirmationDigest32B64u:l,issuedAtUnixMs:i,expiresAtUnixMs:a,material:t})),d=n.publicCapability,f=`ecdsa-export:${s}`,p=await _e({workerCtx:e.getSignerWorkerContext(),command:{kind:`create_router_ab_ecdsa_explicit_export_ceremony_v1`,ceremonyId:f,request:{context:d.context,lifecycle:{lifecycle_id:f,work_kind:`key_export`,primitive_request_kind:`export`,root_share_epoch:d.activation_epoch,account_id:String(n.walletId),session_id:T.thresholdEcdsaSession(f),signer_set_id:d.signer_set.signer_set_id,selected_server_id:d.signer_set.selected_server.server_id},public_identity:d.public_identity,signer_set:d.signer_set,router_id:d.router_id,client_id:d.client_id,authorization:Mt(t.operationAuthorization),authorization_id:t.operationAuthorization.evidenceSetDigest,operation:t.operationAuthorization.operation,material_activation:r,export_authorization_digest_b64u:u,export_nonce:s,expires_at_ms:a,deriver_recipient_keys:d.deriver_recipient_keys}}});if(p.kind!==`router_ab_ecdsa_explicit_export_ceremony_created_v1`)throw Error(`[SigningEngine][ecdsa-export] strict export ceremony kind mismatch`);try{let i=await Pt({relayerUrl:t.relayerUrl,request:p.request,requestDigestB64u:p.requestDigestB64u});if(!i.ok)throw Error(i.error||i.message||i.code||`Strict ECDSA explicit export request failed`);let a=await ve({workerCtx:e.getSignerWorkerContext(),command:{kind:`finalize_router_ab_ecdsa_explicit_export_v1`,ceremonyId:f,clientProofFinalization:{kind:`finalize_encrypted_client_proof_bundles_v2`,bundles:i.value.response.bundles},signingWorkerExport:i.value.signing_worker_export,authorizationKind:c.authorizationKind,authorizationId:c.authorizationId,materialActivation:r,roleLocalMaterial:t.liveMaterial.liveHandle,roleLocalMaterialRef:t.liveMaterial.materialRef,publicFacts:n}});return{publicKeyHex:a.publicKeyHex,privateKeyHex:a.privateKeyHex,ethereumAddress:a.ethereumAddress}}catch(t){throw await be({workerCtx:e.getSignerWorkerContext(),command:{kind:`close_router_ab_ecdsa_post_registration_ceremony_v1`,ceremonyId:f}}).catch(()=>void 0),t}}async function Ht(e,t){let n=t.exportProvision.material;Lt({material:n,walletSessionUserId:t.walletSessionUserId});let r=String(n.relayerUrl||``).trim();if(!r)throw Error(`[SigningEngine][ecdsa-export] relayer URL is required`);let i=n.persistedMaterial;return await Vt(e,{persistedMaterial:i,liveMaterial:await zt({persistedMaterial:i,workerCtx:e.getSignerWorkerContext()}),relayerUrl:r,operationAuthorization:t.exportProvision.authorization,factorAuthorization:t.factorAuthorization})}function Ut(t){let n=t.runtime.normalSigning.scope,r=t.operationAuthorization.operation,i=x(r.material_activation);if(r.operation_kind!==`evm.export_key`||r.wallet_id!==String(t.runtime.walletId)||r.key_handle!==t.runtime.publicFacts.keyHandle||r.relayer_key_id!==t.runtime.relayerKeyId||r.participant_ids[0]!==t.runtime.publicFacts.participantIds[0]||r.participant_ids[1]!==t.runtime.publicFacts.participantIds[1]||r.signing_worker_id!==n.signing_worker.server_id||r.normal_signing_scope.wallet_id!==n.wallet_id||r.normal_signing_scope.context.application_binding_digest_b64u!==n.context.application_binding_digest_b64u||r.normal_signing_scope.public_identity.context_binding_b64u!==n.public_identity.context_binding_b64u||r.normal_signing_scope.public_identity.threshold_public_key33_b64u!==n.public_identity.threshold_public_key33_b64u||r.normal_signing_scope.signing_worker.server_id!==n.signing_worker.server_id||!e(i,t.runtime.materialActivation)||!e(x(r.normal_signing_scope.material_activation),t.runtime.materialActivation))throw Error(`[SigningEngine][ecdsa-export] active Wallet Authority operation identity changed`)}async function Wt(e,t){Ut(t);let n=t.runtime,r=n.normalSigning.scope;if(t.operationAuthorization.exportTopology.signer_set.selected_server.server_id!==r.signing_worker.server_id)throw Error(`[SigningEngine][ecdsa-export] active export topology changed`);let i=r.material_activation,a=Date.now(),o=It({issuedAtUnixMs:a,authorizationExpiresAtMsCeiling:t.operationAuthorization.expiresAtMs}),s={derivationClientSharePublicKey33B64u:r.public_identity.derivation_client_share_public_key33_b64u,relayerPublicKey33B64u:r.public_identity.server_public_key33_b64u,groupPublicKey33B64u:r.public_identity.threshold_public_key33_b64u,ethereumAddress:n.publicFacts.thresholdOwnerAddress},l=Q(),u=Z(t.operationAuthorization),d=await $({version:Y,walletId:String(n.walletId),ecdsaThresholdKeyId:r.ecdsa_threshold_key_id,relayerKeyId:n.relayerKeyId,contextBinding32B64u:r.public_identity.context_binding_b64u,publicIdentity:s,authorizationKind:u.authorizationKind,authorizationId:u.authorizationId,materialActivation:i,exportRequestNonce32B64u:l,issuedAtUnixMs:a,expiresAtUnixMs:o}),f=await $({version:X,operation:`explicit_key_export`,keyHandle:n.publicFacts.keyHandle,walletId:String(n.walletId),ecdsaThresholdKeyId:r.ecdsa_threshold_key_id,relayerKeyId:n.relayerKeyId,signingRootId:r.signing_root_id,signingRootVersion:r.signing_root_version,contextBinding32B64u:r.public_identity.context_binding_b64u,publicIdentity:s,exportRequestNonce32B64u:l,confirmationDigest32B64u:d,issuedAtUnixMs:a,expiresAtUnixMs:o,authorizationKind:u.authorizationKind,authorizationId:u.authorizationId,materialActivation:i,participantIds:n.publicFacts.participantIds}),p=`ecdsa-export:${l}`,m={context:r.context,lifecycle:{lifecycle_id:p,work_kind:`key_export`,primitive_request_kind:`export`,root_share_epoch:r.activation_epoch,account_id:r.wallet_id,session_id:T.thresholdEcdsaSession(p),signer_set_id:t.operationAuthorization.exportTopology.signer_set.signer_set_id,selected_server_id:t.operationAuthorization.exportTopology.signer_set.selected_server.server_id},public_identity:r.public_identity,signer_set:t.operationAuthorization.exportTopology.signer_set,router_id:t.operationAuthorization.exportTopology.router_id,client_id:String(n.walletId),authorization:Mt(t.operationAuthorization),operation:t.operationAuthorization.operation,authorization_id:c(t.operationAuthorization.evidenceSetDigest),material_activation:i,export_authorization_digest_b64u:f,export_nonce:l,expires_at_ms:o,deriver_recipient_keys:t.operationAuthorization.exportTopology.deriver_recipient_keys},h=await ye({holderHandleId:n.holderRuntime.holderHandleId,request:m,workerCtx:e.getSignerWorkerContext()});if(h.kind!==`ecdsa_holder_ordinary_export_request_created_v1`)throw Error(`[SigningEngine][ecdsa-export] active holder export request kind mismatch`);let g=await Ft({relayerUrl:t.relayerUrl,request:h.request,requestDigestB64u:h.requestDigestB64u,operationCredential:n.operationCredential});if(!g.ok)throw Error(g.error||g.message||g.code||`Active Wallet Authority ECDSA export request failed`);let _={wallet_id:r.wallet_id,key_handle:n.publicFacts.keyHandle,ecdsa_threshold_key_id:r.ecdsa_threshold_key_id,signing_root_id:r.signing_root_id,signing_root_version:r.signing_root_version,activation_epoch:r.activation_epoch,signing_worker_id:r.signing_worker.server_id,context_binding_b64u:r.public_identity.context_binding_b64u,threshold_public_key33_b64u:r.public_identity.threshold_public_key33_b64u,export_request_digest_b64u:h.requestDigestB64u,export_authorization_digest_b64u:f,export_nonce:l,authorization_kind:`verified_step_up`,authorization_id:t.operationAuthorization.evidenceSetDigest,material_activation:i,lifecycle_id:p,recipient_identity:h.request.client_id,recipient_public_key:h.request.client_ephemeral_public_key,expires_at_ms:h.request.expires_at_ms},v=await xe({holderHandleId:n.holderRuntime.holderHandleId,requestDigestB64u:h.requestDigestB64u,expectedBinding:_,forwardedResponse:g.value,workerCtx:e.getSignerWorkerContext()});return{publicKeyHex:v.publicKeyHex,privateKeyHex:v.privateKeyHex,ethereumAddress:v.ethereumAddress}}export{Ne as C,Re as S,Ee as T,j as _,yt as a,Pe as b,gt as c,kt as d,J as f,M as g,H as h,bt as i,jt as l,U as m,Ht as n,vt as o,W as p,xt as r,_t as s,Wt as t,At as u,Fe as v,Te as w,Oe as x,Ie as y};
@@ -1 +0,0 @@
1
- import{r as e}from"./domainIds-BzkGsRqO.js";import{c as t}from"./chains-C_X_fNuS.js";import"./primitives-CqrjmIAH.js";import{r as n}from"./secureRandomId-LwBFx84B.js";import"./sessionPolicy-CBTZQe1n.js";import"./signingSessionSeal-DX41aXUL.js";import{t as r}from"./activeWalletSession-WdZkhtBB.js";import"./capabilityKinds-N8xo_IEh.js";import{o as i}from"./canonicalPrimitives-Dsbsxgxc.js";import{i as a,t as o}from"./errors-DIWY1KR9.js";import{d as s,t as c}from"./accountIds-BzZs7YoX.js";import{c as l,o as u,s as ee,u as d}from"./ecdsaChainTarget-DJBXHzbH.js";import"./signerDomain-DqLCvI-D.js";import"./singletons-8UH3gOnZ.js";import"./walletAuthority-BWvfaKIX.js";import{Dt as f,Et as p,Mt as m,a as h,en as te,g,ht as ne,tn as re}from"./emailOtpEcdsaDerivationIdentity-p0C1CQva.js";import{t as ie}from"./challengeDelivery-5lIu9spR.js";import"./digestEncoding-CkUc5vtR.js";import{i as ae}from"./walletAuthMethodRecord-CnBw27ED.js";import"./registrationIds-ByuReLUc.js";import{a as oe,n as _,u as se}from"./sdkSentEvents-Dl8fOL50.js";import{s as ce}from"./types-WGrFMQSw.js";import{i as le}from"./helpers-BnkILY2_.js";import{C as ue,D as v,b as de,j as fe,x as pe}from"./nearEd25519YaoSigningPreparation-Eiq_ikXk.js";import{l as y,u as me}from"./trace-QLsbYdld.js";import{n as he,r as ge,t as _e,w as ve,x as ye}from"./ecdsaDerivationExport-C1cE5m0t.js";import{i as be}from"./walletSessionFailure-YuhraC3P.js";import{i as xe,n as Se,r as Ce,s as we}from"./signingQueue-2pr7lAUS.js";import{h as b,i as x,l as Te,n as Ee,s as S}from"./clientSessionPersistenceState-DRdve9rC.js";import{t as C}from"./types-DhtByIcQ.js";import{i as w}from"./appearance-DITtYj-z.js";import{n as T,t as E}from"./export-viewer-host-DUMwD6zP.js";function D(e){return e.chainTarget.kind}function De(e){return e}function Oe(e){return!e||e.curve!==`ecdsa`||!e.chainTarget||!b(e)||!String(e.publicFacts.keyHandle||``).trim()?!1:e.source===`active_wallet_authority`?e.runtime.requiredCapability===`export_keys`&&e.state===`deferred`&&e.authorizationState===`authorization_required`:e.authorization?!0:e.state===`deferred`}function O(e){if(e.length!==2)throw Error(`[SigningEngine][ecdsa-export] ECDSA participant set must contain two parties`);let t=e[0],n=e[1];if(!Number.isSafeInteger(t)||!Number.isSafeInteger(n)||t<=0||n<=0||t===n)throw Error(`[SigningEngine][ecdsa-export] ECDSA participant set is invalid`);return[t,n]}function k(t){let{exportLane:n,label:r}=t,i=n.capability,a=i.manifest.signer;if(a.walletId!==n.key.walletId||!a.scope.targetMemberships.some(e=>ee(e,n.chainTarget)))throw Error(`[SigningEngine][ecdsa-export] ${r} capability target mismatch`);if(!t.authMatches())throw Error(`[SigningEngine][ecdsa-export] ${r} capability auth mismatch`);if(!e(i.manifest.activation.materialActivation,n.laneIdentity.signer.materialActivation))throw Error(`[SigningEngine][ecdsa-export] ${r} material activation mismatch`);h({expected:n.publicFacts,actual:a.registeredPublicFacts,context:`canonical ${r} export lane`});let o=i.material.publicFacts;if(o.walletId!==a.walletId||String(o.keyHandle)!==String(n.publicFacts.keyHandle)||String(o.groupPublicKey33B64u)!==String(n.publicFacts.publicKeyB64u)||String(o.ethereumAddress)!==String(n.publicFacts.thresholdOwnerAddress)||o.participantIds.length!==n.publicFacts.participantIds.length||o.participantIds.some((e,t)=>e!==n.publicFacts.participantIds[t]))throw Error(`[SigningEngine][ecdsa-export] canonical ${r} export material mismatch`);let s=i.manifest.durableMaterial,c=s.runtimePolicyScope,l=String(t.deps.relayerUrl).trim().replace(/\/+$/g,``);if(!c)throw Error(`[SigningEngine][ecdsa-export] ${r} runtime policy scope is missing`);if(!l)throw Error(`[SigningEngine][ecdsa-export] ${r} export relayer URL is missing`);return{durable:s,runtimePolicyScope:c,relayerUrl:l}}function ke(e){let{exportLane:t}=e,n=t.capability,r=n.authority;if(!p(r))throw Error(`[SigningEngine][ecdsa-export] Email OTP capability authority mismatch`);let{durable:i,runtimePolicyScope:a,relayerUrl:o}=k({deps:e.deps,exportLane:t,label:`Email OTP`,authMatches:()=>t.laneIdentity.auth.kind===`email_otp`&&t.laneIdentity.auth.providerSubjectId===r.factor.providerUserId});return{source:`canonical_capability`,kind:`fresh_email_otp_route_auth_ready`,chainTarget:t.chainTarget,publicFacts:t.publicFacts,runtimePolicyScope:a,persistedMaterial:n.material,normalSigning:i.routerAbEcdsaDerivationNormalSigning,relayerKeyId:String(i.roleLocalBinding.relayerKeyId),participantIds:O(i.roleLocalBinding.participantIds),relayerUrl:o,authorization:{kind:`fresh_operation_authorization_required`,authority:r}}}function Ae(e){let{exportLane:t}=e,n=t.capability,r=n.authority;if(!f(r))throw Error(`[SigningEngine][ecdsa-export] passkey capability authority mismatch`);let{durable:i,runtimePolicyScope:a,relayerUrl:o}=k({deps:e.deps,exportLane:t,label:`passkey`,authMatches:()=>t.laneIdentity.auth.kind===`passkey`&&t.laneIdentity.auth.credentialIdB64u===r.factor.credentialIdB64u});return{source:`canonical_capability`,kind:`fresh_passkey_needs_authorization`,chainTarget:t.chainTarget,publicFacts:t.publicFacts,runtimePolicyScope:a,publicCapability:i.roleLocalPublicFacts.publicCapability,existingRoleLocalMaterial:n.material,normalSigning:i.routerAbEcdsaDerivationNormalSigning,relayerKeyId:String(i.roleLocalBinding.relayerKeyId),participantIds:O(i.roleLocalBinding.participantIds),relayerUrl:o}}function je(t){let{exportLane:n,resolution:r}=t;if(n.laneIdentity.auth.kind!==`email_otp`)throw Error(`[SigningEngine][ecdsa-export] Email OTP runtime auth mismatch`);if(r.runtime.authBinding.kind!==`email_otp`)throw Error(`[SigningEngine][ecdsa-export] Email OTP runtime authority mismatch`);if(n.laneIdentity.auth.providerSubjectId!==r.runtime.authBinding.providerSubjectId)throw Error(`[SigningEngine][ecdsa-export] Email OTP runtime auth mismatch`);if(!e(r.runtime.materialActivation,n.laneIdentity.signer.materialActivation))throw Error(`[SigningEngine][ecdsa-export] Email OTP material activation mismatch`);let i=r.runtime.runtimePolicyScope;if(!i)throw Error(`[SigningEngine][ecdsa-export] Email OTP runtime policy scope is missing`);let a=xe({authority:r.manifest.signer.authority,materialActivation:r.manifest.activation.materialActivation,publicFacts:r.manifest.durableMaterial.roleLocalPublicFacts});return{source:`canonical_capability`,kind:`fresh_email_otp_route_auth_ready`,chainTarget:n.chainTarget,publicFacts:n.publicFacts,runtimePolicyScope:i,persistedMaterial:a,normalSigning:r.runtime.normalSigning,relayerKeyId:r.runtime.relayerKeyId,participantIds:r.runtime.participantIds,relayerUrl:r.runtime.relayerUrl,authorization:{kind:`fresh_operation_authorization_required`,authority:r.runtime.authBinding.emailOtpAuthority}}}function Me(t){let{exportLane:n}=t,r=n.runtime;if(r.requiredCapability!==`export_keys`)throw Error(`[SigningEngine][ecdsa-export] active Wallet Authority lane lacks export_keys capability`);if(r.walletId!==n.key.walletId)throw Error(`[SigningEngine][ecdsa-export] active Wallet Authority wallet mismatch`);if(!e(r.materialActivation,n.laneIdentity.signer.materialActivation))throw Error(`[SigningEngine][ecdsa-export] active Wallet Authority material activation mismatch`);h({expected:n.publicFacts,actual:r.publicFacts,context:`active Wallet Authority ECDSA export lane`});let i=r.normalSigning,a=i.scope;if(a.wallet_id!==String(r.walletId)||a.ecdsa_threshold_key_id!==r.ecdsaThresholdKeyId||a.public_identity.threshold_public_key33_b64u!==r.publicFacts.publicKeyB64u||!e(te(a.material_activation),r.materialActivation))throw Error(`[SigningEngine][ecdsa-export] active Wallet Authority normal-signing identity mismatch`);let o=String(t.deps.relayerUrl).trim().replace(/\/+$/g,``);if(!o)throw Error(`[SigningEngine][ecdsa-export] active Wallet Authority export relayer URL is missing`);let s=O(r.publicFacts.participantIds);if(r.auth.kind===`passkey`){if(!f(r.factorAuthority))throw Error(`[SigningEngine][ecdsa-export] active passkey factor authority mismatch`);if(r.factorAuthority.factor.credentialIdB64u!==r.auth.credentialIdB64u||r.factorAuthority.bindingId!==r.walletAuthMethodId)throw Error(`[SigningEngine][ecdsa-export] active passkey factor identity mismatch`);return{source:`active_wallet_authority`,kind:`active_wallet_authority_passkey_needs_authorization`,chainTarget:n.chainTarget,publicFacts:r.publicFacts,normalSigning:i,relayerKeyId:r.relayerKeyId,participantIds:s,relayerUrl:o,runtime:r,factorAuthority:r.factorAuthority,authMethod:`passkey`}}if(!p(r.factorAuthority))throw Error(`[SigningEngine][ecdsa-export] active Email OTP factor authority mismatch`);if(r.factorAuthority.factor.providerUserId!==r.auth.providerSubjectId||r.factorAuthority.bindingId!==r.walletAuthMethodId)throw Error(`[SigningEngine][ecdsa-export] active Email OTP factor identity mismatch`);return{source:`active_wallet_authority`,kind:`active_wallet_authority_email_otp_needs_authorization`,chainTarget:n.chainTarget,publicFacts:r.publicFacts,normalSigning:i,relayerKeyId:r.relayerKeyId,participantIds:s,relayerUrl:o,runtime:r,factorAuthority:r.factorAuthority,authMethod:`email_otp`}}async function A(e,t){if(t.source!==`canonical_capability`)throw Error(`[SigningEngine][ecdsa-export] active Wallet Authority Email OTP material uses its holder runtime`);if(t.authMethod!==`email_otp`)throw Error(`[SigningEngine][ecdsa-export] fresh Email OTP export requires Email OTP lane`);let n=await e.resolveActiveEcdsaCapabilityRuntime({walletId:t.key.walletId,chainTarget:t.chainTarget});if(n.kind===`blocked`&&n.reason===`missing_material`)return ke({deps:e,exportLane:t});if(n.kind!==`resolved`)throw Error(`[SigningEngine][ecdsa-export] Email OTP capability runtime unavailable: ${n.reason}`);return je({exportLane:t,resolution:n})}async function j(t,n){if(n.source===`active_wallet_authority`)return Me({deps:t,exportLane:n});if(n.authMethod===`email_otp`)return await A(t,n);let r=await t.resolveActiveEcdsaCapabilityRuntime({walletId:n.key.walletId,chainTarget:n.chainTarget});if(r.kind===`blocked`&&r.reason===`missing_material`)return Ae({deps:t,exportLane:n});if(r.kind!==`resolved`)throw Error(`[SigningEngine][ecdsa-export] passkey capability runtime unavailable: ${r.reason}`);if(!e(r.runtime.materialActivation,n.laneIdentity.signer.materialActivation))throw Error(`[SigningEngine][ecdsa-export] passkey material activation mismatch`);if(r.runtime.authBinding.kind!==`passkey`)throw Error(`[SigningEngine][ecdsa-export] passkey authority binding mismatch`);let i=r.manifest.signer.registeredPublicFacts;h({expected:n.publicFacts,actual:i,context:`canonical passkey export lane`});let a=r.runtime.runtimePolicyScope;if(!a)throw Error(`[SigningEngine][ecdsa-export] durable passkey export requires runtimePolicyScope`);return{source:`canonical_capability`,kind:`fresh_passkey_needs_authorization`,chainTarget:n.chainTarget,publicFacts:i,runtimePolicyScope:a,publicCapability:r.manifest.durableMaterial.roleLocalPublicFacts.publicCapability,existingRoleLocalMaterial:xe({authority:r.manifest.signer.authority,materialActivation:r.manifest.durableMaterial.materialActivation,publicFacts:r.manifest.durableMaterial.roleLocalPublicFacts}),normalSigning:r.runtime.normalSigning,relayerKeyId:r.runtime.relayerKeyId,participantIds:r.runtime.participantIds,relayerUrl:r.runtime.relayerUrl}}function Ne(e){return n(e,32,`Email OTP export UI request IDs`)}function Pe(e){switch(e.kind){case`near_account`:return String(c(e.nearAccountId));case`wallet_session`:{let t=String(e.walletId||``).trim();if(!t)throw Error(`Email OTP export requires wallet identity`);return t}default:return e}}function Fe(e){switch(e.kind){case`near_account`:if(!String(e.walletId||``).trim())throw Error(`Email OTP NEAR export requires wallet identity`);return{kind:`near_wallet`,walletId:String(e.walletId).trim(),nearAccountId:String(c(e.nearAccountId))};case`wallet_session`:{let t=String(e.walletId||``).trim();if(!t)throw Error(`Email OTP export requires wallet identity`);return{kind:`evm_wallet`,walletId:t}}default:return e}}function Ie(e){return{challengeId:e.challenge.challengeId,...e.challenge.emailHint?{emailHint:e.challenge.emailHint}:{},title:`Enter email code to export`,body:`This one-time code authorizes private key export only.`,helperText:`Enter the 6-digit code sent to your email`,onResend:e.onResend}}async function M(e){let t=Pe(e.identity),n=async()=>{let t=await e.challengeSource.requestChallenge(),n=String(t.challengeId||``).trim();if(!n)throw Error(`Email OTP export challenge response did not include challengeId`);let r=String(t.emailHint||``).trim();if(!r)throw Error(`Email OTP export challenge response did not include emailHint`);let i={challengeId:n,emailHint:r,delivery:t.delivery};return e.onChallenge?.(i),i},r=await n(),i=Ie({challenge:r,onResend:async()=>(r=await n(),r)}),a=Fe(e.identity),o=await e.confirmer.requestUserConfirmation({requestId:Ne(`export-${e.curve}-email-otp-auth`),type:w.SIGN_INTENT_DIGEST,summary:{operation:`Export Private Key`,accountId:t,publicKey:e.publicKey,warning:`Enter the email code to export this key. Anyone with the private key can fully control the account.`},payload:{signingSubject:a,challengeB64u:r.challengeId,signingAuthPlan:{kind:C.EmailOtpReauth,method:`email_otp`,emailOtpPrompt:i},emailOtpPrompt:i},intentDigest:`export-keys:${t}:${e.chain}:${e.curve}:email-otp`});if(!o.confirmed)throw Error(o.error||`User cancelled Email OTP export request`);let s=String(o.otpCode||``).replace(/\D/g,``).slice(0,6);if(s.length!==6)throw Error(`Email OTP export requires a 6-digit code`);return{challengeId:String(o.emailOtpChallengeId||r.challengeId).trim(),otpCode:s}}function N(e){throw Error(`[SigningEngine][export] unsupported authorization identity: ${String(e)}`)}function Le(e){throw Error(`[SigningEngine][export] unsupported step-up method: ${String(e)}`)}function Re(e){let t=String(e.walletSessionUserId||``).trim();if(!t)throw Error(`[SigningEngine][export] missing export step-up authorization identity`);let n=String(e.publicKey||``).trim();if(!n)throw Error(`[SigningEngine][export] missing export step-up authorization public key`);switch(e.curve){case`ecdsa`:return{walletSessionUserId:t,publicKey:n,curve:`ecdsa`,intent:`ecdsa_export`,chain:e.chain};case`ed25519`:{let r={walletSessionUserId:t,publicKey:n,curve:`ed25519`,intent:`ed25519_export`,chain:`near`,nearAccountId:String(e.nearAccountId||``).trim(),nearEd25519SigningKeyId:String(e.nearEd25519SigningKeyId||``).trim(),signerSlot:Number(e.signerSlot)};if(!r.nearAccountId||!r.nearEd25519SigningKeyId||!Number.isSafeInteger(r.signerSlot)||r.signerSlot<1)throw Error(`[SigningEngine][export] Ed25519 export authorization identity is invalid`);return r}default:return N(e)}}function ze(e){let t={kind:C.EmailOtpReauth,method:`email_otp`,emailOtpPrompt:e.emailOtpPrompt},n=e.emailOtpPrompt.emailHint;switch(e.identity.curve){case`ecdsa`:return{kind:`email_otp`,signingAuthPlan:t,challengeId:e.challengeId,otpCode:e.otpCode,walletSessionUserId:e.identity.walletSessionUserId,publicKey:e.identity.publicKey,curve:`ecdsa`,intent:`ecdsa_export`,chain:e.identity.chain,...n?{emailHint:n}:{}};case`ed25519`:return{kind:`email_otp`,signingAuthPlan:t,challengeId:e.challengeId,otpCode:e.otpCode,walletSessionUserId:e.identity.walletSessionUserId,publicKey:e.identity.publicKey,curve:`ed25519`,intent:`ed25519_export`,chain:`near`,nearAccountId:e.identity.nearAccountId,nearEd25519SigningKeyId:e.identity.nearEd25519SigningKeyId,signerSlot:e.identity.signerSlot,...n?{emailHint:n}:{}};default:return N(e.identity)}}function Be(e){let t={kind:C.PasskeyReauth,method:`passkey`};switch(e.identity.curve){case`ecdsa`:return{kind:`passkey`,signingAuthPlan:t,credential:e.credential,walletSessionUserId:e.identity.walletSessionUserId,publicKey:e.identity.publicKey,curve:`ecdsa`,intent:`ecdsa_export`,chain:e.identity.chain};case`ed25519`:return{kind:`passkey`,signingAuthPlan:t,credential:e.credential,walletSessionUserId:e.identity.walletSessionUserId,publicKey:e.identity.publicKey,curve:`ed25519`,intent:`ed25519_export`,chain:`near`,nearAccountId:e.identity.nearAccountId,nearEd25519SigningKeyId:e.identity.nearEd25519SigningKeyId,signerSlot:e.identity.signerSlot};default:return N(e.identity)}}function P(e){let t=Re(e);switch(e.method){case`email_otp`:{if(!e.decision.confirmed)throw Error(e.decision.error||`User cancelled Email OTP export request`);let n=String(e.decision.otpCode||``).replace(/\D/g,``).slice(0,6);if(n.length!==6)throw Error(`Email OTP export requires a 6-digit code`);let r=String(e.decision.emailOtpChallengeId||e.emailOtpPrompt.challengeId||``).trim();if(!r)throw Error(`Email OTP export challenge response did not include challengeId`);return ze({identity:t,emailOtpPrompt:e.emailOtpPrompt,challengeId:r,otpCode:n})}case`passkey`:if(!e.decision.confirmed)throw Error(e.decision.error||`User cancelled export request`);if(!e.decision.credential)throw Error(`[SigningEngine][export] missing WebAuthn credential for export authorization`);return Be({identity:t,credential:le(e.decision.credential)});default:return Le(e)}}function Ve(e){switch(e.kind){case`ecdsa`:return{subject:`${String(e.walletSession.walletId)}:${u(e.chainTarget)}`,chain:e.chainTarget.kind,data:{curve:`ecdsa`,chain:e.chainTarget.kind,chainTarget:e.chainTarget}};case`ed25519`:return{subject:`${String(e.walletSession.walletId)}:near:${String(e.nearAccount.accountId)}`,chain:`near`,data:{curve:`ed25519`,chain:`near`,nearAccount:e.nearAccount}}}}function F(e,t){if(e)try{e(se(t))}catch{}}function I(e){return n(e,32,`key export UI request IDs`)}function He(e,t){return`key-export:${e}:${t}:${I(`flow`)}`}async function Ue(e,t){let n=Ve(e),r=He(n.subject,n.chain),i=e.walletSession.walletId,s=n.data;F(e.options.onEvent,{phase:_.STEP_01_STARTED,status:`running`,flowId:r,accountId:String(i),interaction:{kind:`none`,overlay:`none`},data:s});try{return await t({...e,flowId:r})}catch(t){let n=a(t);throw F(e.options.onEvent,{phase:n?_.CANCELLED:_.FAILED,status:n?`cancelled`:`failed`,flowId:r,accountId:String(i),interaction:{kind:`none`,overlay:`hide`},error:{message:o(t)||(n?`Key export cancelled`:`Key export failed`)},data:s}),t}}async function We(e,t){return await e.requestExportChallenge({kind:`wallet_login_challenge`,walletSession:t.walletSession,chain:t.chain})}function L(e,t){let n=e.kind===`email_otp_ed25519_export_auth`?e.walletId:e.walletSession.walletSessionUserId;F(e.onEvent,{phase:_.STEP_02_AUTH_EMAIL_OTP_INPUT_REQUIRED,status:`waiting_for_user`,flowId:e.flowId,accountId:String(n),authMethod:`email_otp`,interaction:{kind:`otp_input`,overlay:`show`},data:{emailHint:t.emailHint,demoOtpCode:ie(t.delivery)}})}async function R(e,t){let n=t.walletSession.walletSessionUserId,r=await M({identity:{kind:`wallet_session`,walletId:n},chain:t.chain,publicKey:t.publicKey,curve:t.curve,challengeSource:{requestChallenge:async()=>await We(e,t)},confirmer:{requestUserConfirmation:async t=>await e.touchConfirm.requestUserConfirmation(t)},onChallenge:L.bind(void 0,t)}),i={challengeId:r.challengeId},a={confirmed:!0,otpCode:r.otpCode,emailOtpChallengeId:r.challengeId},o=P({method:`email_otp`,walletSessionUserId:n,chain:t.chain,publicKey:t.publicKey,curve:`ecdsa`,intent:`ecdsa_export`,emailOtpPrompt:i,decision:a});if(o.kind!==`email_otp`)throw Error(`[SigningEngine][export] Email OTP export returned the wrong step-up method`);return o}async function Ge(e,t){let n=await M({identity:{kind:`near_account`,walletId:t.walletId,nearAccountId:t.nearAccountId},chain:`near`,publicKey:t.publicKey,curve:`ed25519`,challengeSource:{requestChallenge:async()=>await e.requestExportChallenge({kind:`wallet_export_challenge`,walletId:t.walletId,chain:`near`})},confirmer:{requestUserConfirmation:async t=>await e.touchConfirm.requestUserConfirmation(t)},onChallenge:L.bind(void 0,t)}),r=P({method:`email_otp`,walletSessionUserId:t.walletId,publicKey:t.publicKey,curve:`ed25519`,intent:`ed25519_export`,chain:`near`,nearAccountId:t.nearAccountId,nearEd25519SigningKeyId:t.nearEd25519SigningKeyId,signerSlot:t.signerSlot,emailOtpPrompt:{challengeId:n.challengeId},decision:{confirmed:!0,otpCode:n.otpCode,emailOtpChallengeId:n.challengeId}});if(r.kind!==`email_otp`||r.curve!==`ed25519`)throw Error(`[SigningEngine][export] Ed25519 Email OTP export authorization changed kind`);return r}async function z(e,t){let n=t.state===`loading`,r=[{scheme:`ed25519`,label:`NEAR Ed25519 private key`,publicKey:t.publicKey,privateKey:n?``:t.privateKey}];await e.touchConfirm.requestUserConfirmation({requestId:I(`export-ed25519-yao-view`),type:w.SHOW_SECURE_PRIVATE_KEY_UI,summary:{operation:`Export Private Key`,accountId:t.nearAccountId,publicKey:t.publicKey,warning:`Anyone with your private key can fully control your account. Never share it.`},payload:{subject:{kind:`near_wallet`,nearAccountId:t.nearAccountId},viewerSessionId:t.viewerSessionId,publicKey:t.publicKey,keys:r,variant:t.variant,theme:t.theme??e.theme??`dark`,loading:n,onLifecycle:e=>{F(t.onEvent,{phase:e===`opened`?_.STEP_04_VIEWER_OPENED:_.STEP_05_VIEWER_CLOSED,status:e===`opened`?`waiting_for_user`:`succeeded`,flowId:t.flowId,accountId:t.nearAccountId,interaction:{kind:`key_export_viewer`,overlay:e===`opened`?`show`:`hide`},data:{chain:`near`,curve:`ed25519`,loading:n}}),e===`closed`&&F(t.onEvent,{phase:_.STEP_06_COMPLETED,status:`succeeded`,flowId:t.flowId,accountId:t.nearAccountId,interaction:{kind:`none`,overlay:`hide`},data:{chain:`near`,curve:`ed25519`}})}},intentDigest:`export-keys:${t.walletId}:near:${t.nearAccountId}:ed25519`})}async function B(e,t){let n=t.chainTarget.kind,r=String(t.walletSessionUserId||``).trim();if(!r)throw Error(`[SigningEngine][export] missing ECDSA export wallet session user id`);return await Ke(e,{walletSessionUserId:t.walletSessionUserId,intent:`ecdsa_export`,curve:`ecdsa`,chain:n,publicKey:t.publicKey,flowId:t.flowId,onEvent:t.onEvent,request:{requestId:I(`export-threshold-ecdsa-auth`),type:w.AUTHORIZE_KEY_EXPORT,summary:{operation:`Export Private Key`,accountId:r,publicKey:t.publicKey,warning:n===`tempo`?`Confirm to reveal your Tempo private key export.`:`Confirm to reveal your EVM private key export.`},payload:{subject:{kind:`evm_wallet`,walletId:r},credentialIdB64u:t.credentialIdB64u,publicKey:t.publicKey,...t.challengeB64u?{challengeB64u:t.challengeB64u}:{}},intentDigest:`export-keys:${r}:${u(t.chainTarget)}:secp256k1`}})}async function V(e,t){let n=t.chainTarget.kind,r=n===`tempo`?`Tempo`:`EVM`,i=t.state===`loading`,a=i?[{scheme:`secp256k1`,label:r,publicKey:t.publicKeyHex,privateKey:``,address:t.ethereumAddress}]:[{scheme:`secp256k1`,label:r,publicKey:t.publicKeyHex,privateKey:t.privateKeyHex,address:t.ethereumAddress}];await e.touchConfirm.requestUserConfirmation({requestId:I(`export-threshold-ecdsa-view`),type:w.SHOW_SECURE_PRIVATE_KEY_UI,summary:{operation:`Export Private Key`,accountId:t.walletId,publicKey:t.publicKeyHex,warning:`Anyone with your private key can fully control your account. Never share it.`},payload:{subject:{kind:`evm_wallet`,walletId:t.walletId},viewerSessionId:t.viewerSessionId,publicKey:t.publicKeyHex,keys:a,variant:t.variant,theme:t.theme??e.theme??`dark`,loading:i,onLifecycle:e=>{F(t.onEvent,{phase:e===`opened`?_.STEP_04_VIEWER_OPENED:_.STEP_05_VIEWER_CLOSED,status:e===`opened`?`waiting_for_user`:`succeeded`,flowId:t.flowId,accountId:String(t.walletId),interaction:{kind:`key_export_viewer`,overlay:e===`opened`?`show`:`hide`},data:{chain:n,curve:`ecdsa`,loading:i}}),e===`closed`&&F(t.onEvent,{phase:_.STEP_06_COMPLETED,status:`succeeded`,flowId:t.flowId,accountId:String(t.walletId),interaction:{kind:`none`,overlay:`hide`},data:{chain:n,curve:`ecdsa`}})}},intentDigest:`export-keys:${t.walletId}:${u(t.chainTarget)}:secp256k1`})}async function Ke(e,t){let n=String(t.walletSessionUserId||``).trim();if(!n)throw Error(`[SigningEngine][export] missing export account identity`);F(t.onEvent,{phase:_.STEP_02_AUTH_PASSKEY_PROMPT_STARTED,status:`waiting_for_user`,flowId:t.flowId,accountId:String(n),authMethod:`passkey`,interaction:{kind:`passkey_assert`,overlay:`show`},data:{intent:t.intent,curve:t.curve}}),T();let r=await e.touchConfirm.requestUserConfirmation(t.request),i=P({method:`passkey`,walletSessionUserId:t.walletSessionUserId,publicKey:t.publicKey,curve:`ecdsa`,intent:`ecdsa_export`,chain:t.chain,decision:r});if(i.kind!==`passkey`)throw Error(`[SigningEngine][export] passkey export returned the wrong step-up method`);return F(t.onEvent,{phase:_.STEP_02_AUTH_PASSKEY_PROMPT_SUCCEEDED,status:`succeeded`,flowId:t.flowId,accountId:String(n),authMethod:`passkey`,interaction:{kind:`passkey_assert`,overlay:`hide`},data:{intent:t.intent,curve:t.curve}}),i}function qe(e){F(e.onEvent,{phase:_.STEP_03_MATERIAL_PREPARE_STARTED,status:`running`,flowId:e.flowId,accountId:String(e.walletId),interaction:{kind:`none`,overlay:`none`},data:{chain:e.chain,curve:`ecdsa`}})}function Je(e){F(e.onEvent,{phase:_.STEP_03_MATERIAL_PREPARE_SUCCEEDED,status:`succeeded`,flowId:e.flowId,accountId:String(e.walletId),interaction:{kind:`none`,overlay:`none`},data:{chain:e.chain,curve:`ecdsa`,...e.source?{source:e.source}:{}}})}async function Ye(e,t){await V({touchConfirm:e.touchConfirm,theme:e.theme},{state:`ready`,walletId:t.walletId,chainTarget:t.exportLane.chainTarget,publicKeyHex:String(t.artifact.publicKeyHex||``).trim(),privateKeyHex:String(t.artifact.privateKeyHex||``).trim(),ethereumAddress:String(t.artifact.ethereumAddress||``).trim(),variant:t.options.variant,theme:t.options.theme,viewerSessionId:t.viewerSessionId,flowId:t.flowId,onEvent:t.onEvent})}async function Xe(e,t){await V({touchConfirm:e.touchConfirm,theme:e.theme},{state:`loading`,walletId:t.walletId,chainTarget:t.exportLane.chainTarget,publicKeyHex:String(t.publicKey||``).trim(),ethereumAddress:String(t.ethereumAddress||``).trim(),variant:t.options.variant,theme:t.options.theme,viewerSessionId:t.viewerSessionId,flowId:t.flowId,onEvent:t.onEvent})}async function H(t,n){let r=D(n.exportLane),i=I(`export-threshold-ecdsa-viewer-session`);qe({flowId:n.flowId,walletId:n.walletId,chain:r,onEvent:n.onEvent});try{await Xe(t,{walletId:n.walletId,exportLane:n.exportLane,publicKey:n.exportPublicKey,ethereumAddress:n.exportLane.publicFacts.thresholdOwnerAddress,options:n.options,viewerSessionId:i,flowId:n.flowId,onEvent:n.onEvent});let a=n.exportLane.laneIdentity.signer.materialActivation,o=await t.withThresholdEcdsaSigningQueue({queueKey:x({materialActivation:a}),walletId:n.exportLane.key.walletId,enabled:!0,task:async()=>{if(n.exportLane.source===`active_wallet_authority`){let e=n.activeRuntime;if(!e)throw Error(`[SigningEngine][ecdsa-export] active runtime is missing`);await tt({ports:t.activeWalletAuthorityEcdsaRuntimeReadPorts,expectedRuntime:e})}else if(n.exportLane.authMethod===`email_otp`){if(!e((await A(t.sessionStore,n.exportLane)).persistedMaterial.materialActivation,a))throw Error(`[SigningEngine][ecdsa-export] prepared material activation was superseded`)}else{let r=await j(t.sessionStore,n.exportLane);if(r.kind!==`fresh_passkey_needs_authorization`)throw Error(`[SigningEngine][ecdsa-export] prepared export authority changed`);if(!e(r.existingRoleLocalMaterial.materialActivation,a))throw Error(`[SigningEngine][ecdsa-export] prepared material activation was superseded`)}return await n.prepareArtifact()}});return Je({flowId:n.flowId,walletId:n.walletId,chain:r,onEvent:n.onEvent}),E(i)&&await Ye(t,{walletId:n.walletId,exportLane:n.exportLane,artifact:o,options:n.options,viewerSessionId:i,flowId:n.flowId,onEvent:n.onEvent}),{accountId:String(n.walletId),exportedSchemes:[`secp256k1`]}}catch(e){throw T(),e}}function U(e){let t=e.laneIdentity.auth;if(t.kind!==`passkey`)throw Error(`[SigningEngine][ecdsa-export] fresh passkey export requires passkey lane`);return t}async function W(e){return i(t(e))}async function G(e){let t=u(e.chainTarget);return await Ce({walletId:e.walletId,operationKind:`evm.export_key`,operationId:e.requestId,operationDigests:{laneDigest:await W({walletId:e.walletId,chainTarget:t,materialActivation:e.materialActivation,keyHandle:e.keyHandle}),intentDigest:await W({operation:`explicit_key_export`,requestId:e.requestId,walletId:e.walletId,chainTarget:t}),displayDigest:await W({operation:`Export Private Key`,publicKey:e.displayPublicKey,address:e.displayAddress})},materialActivation:e.materialActivation,normalSigningScope:e.operationRuntime.normalSigning.scope,keyHandle:e.keyHandle,relayerKeyId:e.operationRuntime.relayerKeyId,participantIds:[Number(e.operationRuntime.participantIds[0]),Number(e.operationRuntime.participantIds[1])],expiresAtMs:e.operationExpiresAtMs})}async function K(e){return await G({walletId:e.walletId,chainTarget:e.chainTarget,requestId:e.requestId,keyHandle:e.keyHandle,displayPublicKey:e.displayPublicKey,displayAddress:e.displayAddress,materialActivation:e.materialActivation,operationRuntime:e.operationRuntime,operationExpiresAtMs:e.operationExpiresAtMs})}async function Ze(t){let n=await j(t.deps.sessionStore,t.exportLane);if(n.kind!==`fresh_passkey_needs_authorization`)throw Error(`[SigningEngine][ecdsa-export] passkey export authority changed`);if(!e(n.existingRoleLocalMaterial.materialActivation,t.expectedMaterialActivation))throw Error(`[SigningEngine][ecdsa-export] active material changed after authorization confirmation`)}async function Qe(t){if(!e((await A(t.deps.sessionStore,t.exportLane)).persistedMaterial.materialActivation,t.expectedMaterialActivation))throw Error(`[SigningEngine][ecdsa-export] active material changed after authorization confirmation`)}function $e(e){if(!et(e.expected,e.actual))throw Error(`[SigningEngine][ecdsa-export] active Wallet Authority runtime was replaced after authorization`)}function et(t,n){let i;switch(t.auth.kind){case`passkey`:i=n.auth.kind===`passkey`&&t.auth.rpId===n.auth.rpId&&t.auth.credentialIdB64u===n.auth.credentialIdB64u;break;case`email_otp`:i=n.auth.kind===`email_otp`&&t.auth.providerSubjectId===n.auth.providerSubjectId;break;default:return t.auth}return t.kind===n.kind&&t.walletId===n.walletId&&t.authorityId===n.authorityId&&t.walletAuthMethodId===n.walletAuthMethodId&&t.authorityDigestB64u===n.authorityDigestB64u&&t.factorAuthorityRef.kind===n.factorAuthorityRef.kind&&t.factorAuthorityRef.walletId===n.factorAuthorityRef.walletId&&t.factorAuthorityRef.authorityDigest===n.factorAuthorityRef.authorityDigest&&t.factorAuthorityRef.walletAuthMethodId===n.factorAuthorityRef.walletAuthMethodId&&t.authorityRevocationEpoch===n.authorityRevocationEpoch&&t.walletSessionId===n.walletSessionId&&t.requiredCapability===n.requiredCapability&&e(t.materialActivation,n.materialActivation)&&t.ecdsaThresholdKeyId===n.ecdsaThresholdKeyId&&t.relayerKeyId===n.relayerKeyId&&t.operationCredential.kind===n.operationCredential.kind&&t.operationCredential.token===n.operationCredential.token&&t.operationCredential.walletSessionId===n.operationCredential.walletSessionId&&r(t.session,n.session)&&ae(t.authMethod,n.authMethod)&&i&&m(t.factorAuthority,n.factorAuthority)&&t.holderRuntime.kind===n.holderRuntime.kind&&t.holderRuntime.walletId===n.holderRuntime.walletId&&t.holderRuntime.authorityId===n.holderRuntime.authorityId&&t.holderRuntime.walletAuthMethodId===n.holderRuntime.walletAuthMethodId&&m(t.holderRuntime.factorAuthority,n.holderRuntime.factorAuthority)&&e(t.holderRuntime.materialActivation,n.holderRuntime.materialActivation)&&t.holderRuntime.holderHandleId===n.holderRuntime.holderHandleId&&t.holderRuntime.ecdsaThresholdKeyId===n.holderRuntime.ecdsaThresholdKeyId&&ne(t.normalSigning,n.normalSigning)}async function q(e){let t=await we({ports:e.ports,input:{walletId:e.expectedRuntime.walletId,requiredCapability:`export_keys`,materialActivation:e.expectedRuntime.materialActivation}});if(t.kind!==`resolved`)throw Error(`[SigningEngine][ecdsa-export] active Wallet Authority runtime is ${t.reason}`);return $e({expected:e.expectedRuntime,actual:t.runtime}),t.runtime}async function tt(e){await q(e)}function J(e){let t=e.credential,n=String(t.rawId||t.id||``).trim();if(!n||n!==e.authority.factor.credentialIdB64u)throw Error(`[SigningEngine][ecdsa-export] passkey credential does not match authority`);return{kind:`passkey`,authority:e.authority,webauthn_authentication:{id:t.id,rawId:t.rawId,type:t.type,authenticatorAttachment:t.authenticatorAttachment??null,response:{clientDataJSON:t.response.clientDataJSON,authenticatorData:t.response.authenticatorData,signature:t.response.signature,userHandle:t.response.userHandle??null},clientExtensionResults:t.clientExtensionResults??null}}}function Y(e){if(!p(e.authority))throw Error(`[SigningEngine][ecdsa-export] Email OTP material authority mismatch`);return{kind:`email_otp`,authority:e.authority,challenge_id:e.challengeId,otp_code:e.otpCode}}async function X(e){let t=await Se({relayerUrl:e.relayerUrl,transport:e.transport,request:{kind:`router_ab_ecdsa_operation_step_up_v1`,operation:e.prepared.operation,proof:e.proof}});if(t.operation_kind!==`evm.export_key`)throw Error(`[SigningEngine][ecdsa-export] operation step-up kind mismatch`);let n=t.authorization.evidence_set_digest,r=nt({proofKind:e.proof.kind,unseal:t.authorization.unseal});return{kind:`verified_step_up`,evidenceSetDigest:n,operation:e.prepared.operation,expiresAtMs:t.expires_at_ms,quotaUse:`none`,unseal:r,exportTopology:t.export_topology}}function nt(e){switch(e.proofKind){case`passkey`:if(e.unseal.kind!==`not_requested`)throw Error(`[SigningEngine][ecdsa-export] passkey step-up returned Email OTP unseal material`);return{kind:`not_requested`};case`email_otp`:if(e.unseal.kind!==`email_otp_grant`)throw Error(`[SigningEngine][ecdsa-export] Email OTP step-up did not return an unseal grant`);return{kind:`email_otp_grant`,grant:e.unseal.grant,challenge_id:e.unseal.challenge_id};default:{let t=e.proofKind;throw Error(`Unsupported ECDSA export step-up proof: ${String(t)}`)}}}async function rt(e,t){U(t.exportLane);let n=I(`tecdsa-export`),r=await K({walletId:t.walletId,chainTarget:t.exportLane.chainTarget,requestId:n,keyHandle:t.material.existingRoleLocalMaterial.publicFacts.keyHandle,displayPublicKey:t.material.existingRoleLocalMaterial.publicFacts.groupPublicKey33B64u,displayAddress:t.material.existingRoleLocalMaterial.publicFacts.ethereumAddress,materialActivation:t.material.existingRoleLocalMaterial.materialActivation,operationRuntime:t.material,operationExpiresAtMs:Date.now()+5*6e4}),i=await B({touchConfirm:e.touchConfirm,theme:e.theme},{walletSessionUserId:t.walletId,credentialIdB64u:U(t.exportLane).credentialIdB64u,publicKey:t.exportPublicKey,chainTarget:t.exportLane.chainTarget,challengeB64u:r.challengeB64u,flowId:t.flowId,onEvent:t.onEvent});await Ze({deps:e,exportLane:t.exportLane,expectedMaterialActivation:t.material.existingRoleLocalMaterial.materialActivation});let a=t.exportLane.capability.authority;if(!f(a))throw Error(`[SigningEngine][ecdsa-export] exact Passkey capability authority changed`);let o=await X({relayerUrl:t.material.relayerUrl,prepared:r,transport:{kind:`factor_proof`},proof:J({authority:a,credential:i.credential})});return{exportActivation:ge({relayerUrl:t.material.relayerUrl,existingRoleLocalMaterial:t.material.existingRoleLocalMaterial,authorization:o}),credential:i.credential}}async function it(e){let t=d({walletId:e.walletId,walletSessionUserId:e.walletId});return await e.deps.emailOtp.exportEcdsaKeyWithDurableAuthorization({walletSession:t,chainTarget:e.material.chainTarget,challengeId:e.authorization.challengeId,otpCode:e.authorization.otpCode,publicFacts:e.material.publicFacts,runtimePolicyScope:e.material.runtimePolicyScope,authority:e.material.authorization.authority,persistedMaterial:e.persistedMaterial,explicitExportAuthorization:e.explicitExportAuthorization})}function Z(e){return{normalSigning:e.runtime.normalSigning,relayerKeyId:e.relayerKeyId,participantIds:e.participantIds}}function Q(e){return Math.min(Date.now()+5*6e4,e.session.expiresAtMs)}async function at(e){if(e.material.runtime.auth.kind!==`passkey`)throw Error(`[SigningEngine][ecdsa-export] active passkey runtime auth mismatch`);if(!f(e.material.factorAuthority))throw Error(`[SigningEngine][ecdsa-export] active passkey factor authority mismatch`);let t=await K({walletId:e.walletId,chainTarget:e.exportLane.chainTarget,requestId:I(`tecdsa-active-passkey-export`),keyHandle:e.material.runtime.publicFacts.keyHandle,displayPublicKey:e.material.runtime.publicFacts.publicKeyB64u,displayAddress:e.material.runtime.publicFacts.thresholdOwnerAddress,materialActivation:e.material.runtime.materialActivation,operationRuntime:Z(e.material),operationExpiresAtMs:Q(e.material.runtime)}),n=await B({touchConfirm:e.deps.touchConfirm,theme:e.deps.theme},{walletSessionUserId:e.walletId,credentialIdB64u:e.material.factorAuthority.factor.credentialIdB64u,publicKey:e.exportPublicKey,chainTarget:e.exportLane.chainTarget,challengeB64u:t.challengeB64u,flowId:e.flowId,onEvent:e.onEvent}),r=await q({ports:e.deps.activeWalletAuthorityEcdsaRuntimeReadPorts,expectedRuntime:e.material.runtime});if(!f(r.factorAuthority))throw Error(`[SigningEngine][ecdsa-export] active passkey factor authority changed`);return{runtime:r,authorization:await X({relayerUrl:e.material.relayerUrl,prepared:t,transport:{kind:`wallet_session`,credential:r.operationCredential},proof:J({authority:r.factorAuthority,credential:n.credential})})}}async function ot(e){if(e.material.runtime.auth.kind!==`email_otp`)throw Error(`[SigningEngine][ecdsa-export] active Email OTP runtime auth mismatch`);if(!p(e.material.factorAuthority))throw Error(`[SigningEngine][ecdsa-export] active Email OTP factor authority mismatch`);let t=await K({walletId:e.walletId,chainTarget:e.exportLane.chainTarget,requestId:I(`tecdsa-active-email-otp-export`),keyHandle:e.material.runtime.publicFacts.keyHandle,displayPublicKey:e.material.runtime.publicFacts.publicKeyB64u,displayAddress:e.material.runtime.publicFacts.thresholdOwnerAddress,materialActivation:e.material.runtime.materialActivation,operationRuntime:Z(e.material),operationExpiresAtMs:Q(e.material.runtime)}),n=await R({touchConfirm:e.deps.touchConfirm,requestExportChallenge:e.deps.emailOtp.requestExportChallenge},{kind:`wallet_session_export_auth`,walletSession:d({walletId:e.walletId,walletSessionUserId:e.walletId}),chain:D(e.exportLane),publicKey:e.exportPublicKey,curve:`ecdsa`,flowId:e.flowId,onEvent:e.onEvent}),r=await q({ports:e.deps.activeWalletAuthorityEcdsaRuntimeReadPorts,expectedRuntime:e.material.runtime});if(!p(r.factorAuthority))throw Error(`[SigningEngine][ecdsa-export] active Email OTP factor authority changed`);return{runtime:r,authorization:await X({relayerUrl:e.material.relayerUrl,prepared:t,transport:{kind:`wallet_session`,credential:r.operationCredential},proof:Y({authority:r.factorAuthority,challengeId:n.challengeId,otpCode:n.otpCode})})}}async function st(e){switch(e.material.kind){case`active_wallet_authority_passkey_needs_authorization`:return await at({deps:e.deps,walletId:e.walletId,exportLane:e.exportLane,material:e.material,exportPublicKey:e.exportPublicKey,flowId:e.flowId,onEvent:e.onEvent});case`active_wallet_authority_email_otp_needs_authorization`:return await ot({deps:e.deps,walletId:e.walletId,exportLane:e.exportLane,material:e.material,exportPublicKey:e.exportPublicKey,flowId:e.flowId,onEvent:e.onEvent});default:return ct(e.material)}}function ct(e){throw Error(`[SigningEngine][ecdsa-export] unsupported active wallet authority material: ${String(e)}`)}async function lt(e,t){let n=String(t.material.publicFacts.publicKeyB64u),r=await st({deps:e,walletId:t.walletId,exportLane:t.exportLane,material:t.material,exportPublicKey:n,flowId:t.flowId,onEvent:t.onEvent});return await H(e,{walletId:t.walletId,exportLane:t.exportLane,activeRuntime:r.runtime,exportPublicKey:n,options:t.options,flowId:t.flowId,onEvent:t.onEvent,prepareArtifact:async()=>{let n=await q({ports:e.activeWalletAuthorityEcdsaRuntimeReadPorts,expectedRuntime:r.runtime});return await _e({getSignerWorkerContext:e.getSignerWorkerContext},{runtime:n,operationAuthorization:r.authorization,relayerUrl:t.material.relayerUrl})}})}async function ut(e,t){let n=D(t.exportLane),r=await G({walletId:t.walletId,chainTarget:t.exportLane.chainTarget,requestId:I(`tecdsa-email-otp-export`),keyHandle:t.material.persistedMaterial.publicFacts.keyHandle,displayPublicKey:t.material.persistedMaterial.publicFacts.groupPublicKey33B64u,displayAddress:t.material.persistedMaterial.publicFacts.ethereumAddress,materialActivation:t.material.persistedMaterial.materialActivation,operationRuntime:t.material,operationExpiresAtMs:Date.now()+5*6e4}),i=await R({touchConfirm:e.touchConfirm,requestExportChallenge:e.emailOtp.requestExportChallenge},{kind:`wallet_session_export_auth`,walletSession:d({walletId:t.walletId,walletSessionUserId:t.walletId}),chain:n,publicKey:String(t.material.publicFacts.publicKeyB64u),curve:`ecdsa`,flowId:t.flowId,onEvent:t.onEvent});await Qe({deps:e,exportLane:t.exportLane,expectedMaterialActivation:t.material.persistedMaterial.materialActivation});let a=await X({relayerUrl:t.material.relayerUrl,prepared:r,transport:{kind:`factor_proof`},proof:Y({authority:t.material.authorization.authority,challengeId:i.challengeId,otpCode:i.otpCode})});return await H(e,{walletId:t.walletId,exportLane:t.exportLane,exportPublicKey:String(t.material.publicFacts.publicKeyB64u),options:t.options,flowId:t.flowId,onEvent:t.onEvent,prepareArtifact:it.bind(void 0,{deps:e,walletId:t.walletId,material:t.material,authorization:i,persistedMaterial:t.material.persistedMaterial,explicitExportAuthorization:a})})}async function dt(e,t){if(t.exportLane.authMethod!==`passkey`)throw Error(`[SigningEngine][ecdsa-export] fresh passkey export requires passkey lane`);let n=String(t.material.publicFacts.publicKeyB64u),r=await rt(e,{walletId:t.walletId,exportLane:t.exportLane,material:t.material,exportPublicKey:n,flowId:t.flowId,onEvent:t.onEvent});return await H(e,{walletId:t.walletId,exportLane:t.exportLane,exportPublicKey:n,options:t.options,flowId:t.flowId,onEvent:t.onEvent,prepareArtifact:async()=>{let n=await e.provisionPasskeyEcdsaExplicitExportSession(r.exportActivation);return await he({getSignerWorkerContext:e.getSignerWorkerContext},{walletSessionUserId:t.walletId,exportProvision:n,factorAuthorization:{kind:`passkey`,passkeyCredentialIdB64u:String(r.credential.rawId||r.credential.id),credential:r.credential}})}})}function $(e){let t=e.source===`canonical_capability`?e.authorization:null;return{authMethod:S(e),curve:e.curve,chain:e.chainTarget.kind,chainTarget:e.chainTarget,state:e.state,source:e.source,...t?{remainingUses:e.remainingUses,expiresAtMs:e.expiresAtMs}:{},updatedAtMs:e.updatedAtMs,evmFamilyKeyFingerprint:g({walletId:e.key.walletId,publicFacts:e.publicFacts})}}function ft(e,t){return String(e.key.walletId)===t.walletId?String(g({walletId:e.key.walletId,publicFacts:e.publicFacts})):``}function pt(e){if(!e.candidates.length)throw y(`evm-family`,{stage:`key_export.exact_lane_no_candidate`,context:e.context,candidateCount:e.candidates.length,candidates:e.candidates.map($)}),Error(`[SigningEngine][${e.context}] exact lane selection failed: no_candidate`);for(let t of e.candidates)if(!ft(t,e.ecdsaContext))return mt(e);if(e.candidates.length!==1)return mt(e);let[t]=e.candidates;return me(`evm-family`,{stage:`key_export.exact_lane_selected`,context:e.context,reason:`single_exact_candidate`,selectedLane:$(t),candidateCount:e.candidates.length}),t}function mt(e){throw y(`evm-family`,{stage:`key_export.exact_lane_ambiguous_material`,context:e.context,candidateCount:e.candidates.length,candidates:e.candidates.map($)}),Error(`[SigningEngine][${e.context}] exact lane selection failed: ambiguous_material`)}function ht(e){return pe({signer:de({walletId:e.lane.key.walletId,chainTarget:e.chainTarget||e.lane.chainTarget,keyHandle:e.lane.publicFacts.keyHandle,key:e.lane.key,materialActivation:e.lane.materialActivation}),auth:e.lane.auth})}function gt(e){return e.source===`active_wallet_authority`||e.state===`ready`?{kind:`loaded_worker_material`}:S(e)===`email_otp`?{kind:`material_pending`,reason:`email_otp_route_auth`}:{kind:`sealed_worker_material`}}function _t(e){if(e.lane.source===`active_wallet_authority`)return{chainTarget:e.chainTarget,authMethod:S(e.lane),material:{kind:`loaded_worker_material`},state:`deferred`};let t=S(e.lane),n=gt(e.lane);switch(e.lane.state){case`expired`:case`exhausted`:throw Error(`[SigningEngine][ecdsa-export] expired export lane requires durable public reauth authority`);case`ready`:case`deferred`:return{chainTarget:e.chainTarget,authMethod:t,material:n,state:e.lane.state}}}async function vt(e){let t=e.lane,n=ht({lane:t}),r=_t({lane:t,chainTarget:e.chainTarget});return t.source===`active_wallet_authority`?{curve:`ecdsa`,laneIdentity:n,source:`active_wallet_authority`,authorizationState:`authorization_required`,key:t.key,publicFacts:t.publicFacts,runtime:t.runtime,chainTarget:e.chainTarget,authMethod:S(t),material:{kind:`loaded_worker_material`},state:`deferred`}:t.authorization?{curve:`ecdsa`,laneIdentity:n,source:`canonical_capability`,authorizationState:`authorized`,authorization:t.authorization,capability:t.capability,key:t.key,publicFacts:t.publicFacts,...r}:{curve:`ecdsa`,laneIdentity:n,source:`canonical_capability`,authorizationState:`authorization_required`,capability:t.capability,key:t.key,publicFacts:t.publicFacts,...r}}function yt(e){return v(e.laneIdentity)===v(e.identity)}async function bt(e){return ht({lane:e})}function xt(e){return Te(e.availableLanes,e.chainTarget).filter(e=>Oe(e))}async function St(e,t){let n=xt({availableLanes:await e.readOwnerScopedAvailableSigningLanesForTargets({walletId:t.walletId,ecdsaChainTargets:[t.signingTarget]}),chainTarget:t.signingTarget}),r=[];for(let e of n)yt({laneIdentity:await bt(e),identity:t.laneIdentity})&&r.push(e);let i=pt({context:`ecdsa-export`,candidates:r,ecdsaContext:{walletId:t.walletId}});return await vt({lane:i,chainTarget:i.chainTarget})}async function Ct(e,t){try{switch(t.kind){case`ecdsa`:return await wt(e,t);case`ed25519`:return await Ot(e,t)}}catch(e){if(ye(e))return{kind:`relink_required`,reason:e.reason};throw e}}async function wt(e,t){let n=String(l(t.walletSession.walletId));return{kind:`ecdsa`,laneIdentity:await bt(pt({context:`ecdsa-export-resolve`,candidates:xt({availableLanes:await e.readOwnerScopedAvailableSigningLanesForTargets({walletId:n,ecdsaChainTargets:[t.chainTarget]}),chainTarget:t.chainTarget}),ecdsaContext:{walletId:n}}))}}function Tt(e){let t=e.lane.source===`durable_sealed_record`||e.lane.source===`public_capability_reference`;return String(e.lane.walletId)===e.walletId&&String(e.lane.nearAccountId)===e.nearAccountId&&t}function Et(e){return ue({signer:fe({walletId:e.walletId,nearAccountId:e.nearAccountId,nearEd25519SigningKeyId:e.nearEd25519SigningKeyId,signerSlot:e.signerSlot}),auth:e.auth,thresholdSessionId:e.thresholdSessionId})}function Dt(e){return[e.walletId,e.nearAccountId,e.nearEd25519SigningKeyId,e.signerSlot,ce(e.auth)].map(e=>String(e)).join(`|`)}async function Ot(e,t){let n=String(l(t.walletSession.walletId)),r=String(t.nearAccount.accountId),i=await e.readOwnerScopedAvailableSigningLanesForTargets({walletId:n,ecdsaChainTargets:[]}),a=i.lanes.ed25519.near;if(!b(a)||a.curve!==`ed25519`||!Tt({lane:a,walletId:n,nearAccountId:r}))throw Error(`[SigningEngine][ed25519-export-resolve] exact Yao lane selection failed: no_candidate`);let o=i.candidates.ed25519.near.filter(e=>b(e)&&e.curve===`ed25519`&&Tt({lane:e,walletId:n,nearAccountId:r})),s=Dt(a);if(o.some(e=>Dt(e)!==s))throw Error(`[SigningEngine][ed25519-export-resolve] exact Yao lane selection failed: ambiguous_material`);return{kind:`ed25519`,laneIdentity:Et(a),materialActivation:a.materialActivation}}async function kt(e,t){let n=await St(e,{walletId:t.walletId,signingTarget:t.signingTarget,laneIdentity:t.laneIdentity});switch(n.material.kind){case`loaded_worker_material`:case`material_pending`:case`sealed_worker_material`:return n}throw n.material,Error(`[SigningEngine][ecdsa-export] unsupported material availability`)}function At(e){return e.capability.materialActivation}function jt(e){return e.material.materialActivation}function Mt(e){return e.auth.kind===`passkey`}function Nt(e){if(!Mt(e.laneIdentity))throw Error(`[SigningEngine][ed25519-export] export requires a passkey Yao lane`);if(e.laneIdentity.signer.account.wallet.walletId!==e.walletId||String(e.laneIdentity.signer.account.nearAccountId)!==String(e.nearAccountId))throw Error(`[SigningEngine][ed25519-export] exact lane subject mismatch`);return e.laneIdentity}function Pt(e){return e.auth.kind===`email_otp`}function Ft(e){if(!Pt(e.laneIdentity))throw Error(`[SigningEngine][ed25519-export] export requires an Email OTP Yao lane`);if(e.laneIdentity.signer.account.wallet.walletId!==e.walletId||String(e.laneIdentity.signer.account.nearAccountId)!==String(e.nearAccountId))throw Error(`[SigningEngine][ed25519-export] exact lane subject mismatch`);return e.laneIdentity}function It(e){let t=e.selected.signer,n=e.context.material;return String(t.account.wallet.walletId)===String(n.walletId)&&String(t.account.nearAccountId)===String(n.nearAccountId)&&String(t.nearEd25519SigningKeyId)===String(n.nearEd25519SigningKeyId)&&t.signerSlot===n.signerSlot&&String(e.selected.auth.rpId)===e.context.rpId&&e.selected.auth.credentialIdB64u===n.credentialIdB64u}function Lt(t){if(!It({selected:t.selectedLaneIdentity,context:t.context}))throw Error(`[SigningEngine][ed25519-export] durable Yao context identity mismatch`);let n=t.context.material;if(!e(t.selectedMaterialActivation,t.context.selectedLaneMaterialActivation))throw Error(`[SigningEngine][ed25519-export] durable Yao context activation mismatch`);let r=t.context.authorization.operationCredential.token;if(!r)throw Error(`[SigningEngine][ed25519-export] active Wallet Session authorization is unavailable`);let i=n.capability.lifecycle;return{laneIdentity:t.selectedLaneIdentity,relayerUrl:t.context.relayerUrl,walletSessionToken:r,walletCustodyEnvelope:t.context.walletCustodyEnvelope,capability:{materialActivation:n.capability.materialActivation,scope:{lifecycle_id:i.lifecycleId,root_share_epoch:i.rootShareEpoch,account_id:i.accountId,threshold_session_id:i.thresholdSessionId,signer_set_id:i.signerSetId,signing_worker_id:i.signingWorkerId,material_activation:re(n.capability.materialActivation)},applicationBinding:n.capability.applicationBinding,participantIds:n.capability.participantIds,registeredPublicKey:n.capability.registeredPublicKey,stateEpoch:n.capability.stateEpoch,activeCapabilityBinding:n.capability.activeCapabilityBinding,runtimePolicyScope:n.capability.runtimePolicyScope}}}async function Rt(e,t){let n=Nt(t),r=await e.resolvePasskeyExportContext({laneIdentity:n,materialActivation:t.materialActivation});switch(r.kind){case`ready`:return Lt({context:r.context,selectedLaneIdentity:n,selectedMaterialActivation:t.materialActivation});case`capability_recovery_required`:throw Error(`[SigningEngine][ed25519-export] passkey material recovery did not publish durable context`)}throw Error(`[SigningEngine][ed25519-export] unsupported passkey export context state`)}async function zt(t,n){let r=Ft(n),i=await t.emailOtp.resolveExportContext({laneIdentity:r,materialActivation:n.materialActivation});if(!e(n.materialActivation,i.material.materialActivation)&&i.material.kind!==`sealed_export_root`)throw Error(`[SigningEngine][ed25519-export] Email OTP Yao context activation mismatch`);return{context:i,laneIdentity:r}}function Bt(e){let t=e.resolved.laneIdentity.signer;return{artifactKind:ve,walletId:String(e.input.walletId),nearAccountId:String(e.input.nearAccountId),relayerUrl:e.resolved.relayerUrl,authorization:{kind:`opaque_wallet_session`,walletSessionToken:e.resolved.walletSessionToken},flowId:e.input.flowId,viewerSessionId:e.viewerSessionId,exactLane:{nearEd25519SigningKeyId:String(t.nearEd25519SigningKeyId),signerSlot:t.signerSlot,credentialIdB64u:e.resolved.laneIdentity.auth.credentialIdB64u,materialActivation:At(e.resolved)},walletCustodyEnvelope:e.resolved.walletCustodyEnvelope,capability:e.resolved.capability,variant:e.input.options.variant,theme:e.input.options.theme??e.theme}}function Vt(e,t){let n=String(e.walletId);F(e.onEvent,{phase:t===`opened`?_.STEP_04_VIEWER_OPENED:_.STEP_05_VIEWER_CLOSED,status:t===`opened`?`waiting_for_user`:`succeeded`,flowId:e.flowId,accountId:n,interaction:{kind:`key_export_viewer`,overlay:t===`opened`?`show`:`hide`},data:{chain:`near`,curve:`ed25519`}}),t===`closed`&&F(e.onEvent,{phase:_.STEP_06_COMPLETED,status:`succeeded`,flowId:e.flowId,accountId:n,interaction:{kind:`none`,overlay:`hide`},data:{chain:`near`,curve:`ed25519`}})}async function Ht(e,t){switch(t.laneIdentity.auth.kind){case`passkey`:break;case`email_otp`:return await Ut(e,t);default:throw t.laneIdentity.auth,Error(`[SigningEngine][ed25519-export] unsupported lane authorization method`)}let n=Rt(e,t),r=e.touchConfirm.initialize(),[i]=await Promise.all([n,r]),a=String(t.walletId),o=I(`export-ed25519-yao-viewer-session`),s=Vt.bind(void 0,{flowId:t.flowId,walletId:t.walletId,onEvent:t.onEvent});F(t.onEvent,{phase:_.STEP_02_AUTH_PASSKEY_PROMPT_STARTED,status:`waiting_for_user`,flowId:t.flowId,accountId:a,authMethod:`passkey`,interaction:{kind:`passkey_assert`,overlay:`show`},data:{intent:`ed25519_export`,chain:`near`,curve:`ed25519`}}),F(t.onEvent,{phase:_.STEP_03_MATERIAL_PREPARE_STARTED,status:`running`,flowId:t.flowId,accountId:a,interaction:{kind:`none`,overlay:`none`},data:{chain:`near`,curve:`ed25519`}});let c=await e.withThresholdEd25519CommitQueue({queueKey:x({materialActivation:At(i)}),nearAccountId:t.nearAccountId,enabled:!0,task:()=>e.passkeyMpcExport.exportPrivateKeysWithUi(Bt({resolved:i,viewerSessionId:o,input:t,theme:e.theme}),{onViewerLifecycle:s})});if(c.kind!==`completed`)throw Error(c.error);if(c.exportedSchemes.length!==1||c.exportedSchemes[0]!==`ed25519`)throw Error(`[SigningEngine][ed25519-export] secure export failed`);return F(t.onEvent,{phase:_.STEP_02_AUTH_PASSKEY_PROMPT_SUCCEEDED,status:`succeeded`,flowId:t.flowId,accountId:a,authMethod:`passkey`,interaction:{kind:`passkey_assert`,overlay:`none`},data:{intent:`ed25519_export`,chain:`near`,curve:`ed25519`}}),F(t.onEvent,{phase:_.STEP_03_MATERIAL_PREPARE_SUCCEEDED,status:`succeeded`,flowId:t.flowId,accountId:a,interaction:{kind:`none`,overlay:`none`},data:{chain:`near`,curve:`ed25519`}}),{accountId:String(t.nearAccountId),exportedSchemes:[`ed25519`]}}async function Ut(e,t){let n=await zt(e,t),r=`ed25519:${s(Uint8Array.from(n.context.material.capability.registeredPublicKey))}`,i=await Ge({touchConfirm:e.touchConfirm,requestExportChallenge:e.emailOtp.requestExportChallenge},{kind:`email_otp_ed25519_export_auth`,walletId:t.walletId,nearAccountId:String(t.nearAccountId),nearEd25519SigningKeyId:String(n.laneIdentity.signer.nearEd25519SigningKeyId),signerSlot:n.laneIdentity.signer.signerSlot,publicKey:r,curve:`ed25519`,chain:`near`,flowId:t.flowId,onEvent:t.onEvent});F(t.onEvent,{phase:_.STEP_03_MATERIAL_PREPARE_STARTED,status:`running`,flowId:t.flowId,accountId:String(t.nearAccountId),interaction:{kind:`none`,overlay:`none`},data:{chain:`near`,curve:`ed25519`}});let a=I(`export-ed25519-yao-viewer-session`);try{await z({touchConfirm:e.touchConfirm,theme:e.theme},{state:`loading`,walletId:String(t.walletId),nearAccountId:String(t.nearAccountId),publicKey:r,variant:t.options.variant,theme:t.options.theme,viewerSessionId:a,flowId:t.flowId,onEvent:t.onEvent});let o=await e.withThresholdEd25519CommitQueue({queueKey:x({materialActivation:jt(n.context)}),nearAccountId:t.nearAccountId,enabled:n.context.material.kind===`active_capability`,task:()=>e.emailOtp.exportSeedWithFreshAuthorization({challengeId:i.challengeId,otpCode:i.otpCode,exportContext:n.context})});return F(t.onEvent,{phase:_.STEP_03_MATERIAL_PREPARE_SUCCEEDED,status:`succeeded`,flowId:t.flowId,accountId:String(t.nearAccountId),interaction:{kind:`none`,overlay:`none`},data:{chain:`near`,curve:`ed25519`}}),E(a)&&await z({touchConfirm:e.touchConfirm,theme:e.theme},{state:`ready`,walletId:String(t.walletId),nearAccountId:String(t.nearAccountId),publicKey:o.publicKey,privateKey:o.privateKey,variant:t.options.variant,theme:t.options.theme,viewerSessionId:a,flowId:t.flowId,onEvent:t.onEvent}),{accountId:String(t.nearAccountId),exportedSchemes:[`ed25519`]}}catch(e){throw T(),e}}function Wt(e){switch(e.kind){case`active`:case`expired`:return e;case`missing`:case`unavailable`:case`invalid`:return null;default:return e}}async function Gt(e){await e.deps.sessionLifecycle.invalidateExpiredAuthorization({state:e.state,source:e.source})}async function Kt(e){let t=await e.deps.sessionLifecycle.readAuthorization(e.request);return t.kind===`expired`&&await Gt({deps:e.deps,state:t,source:oe.operationPreflight}),t}function qt(e){let t=Wt(e.preflightState);return t?Ee({source:e.source,expiresAtMs:t.expiresAtMs,detectedAtMs:e.detectedAtMs}):null}async function Jt(e,t){let n=l(t.walletSession.walletId),r=await kt(e.laneSelection,{walletId:n,signingTarget:De(t.chainTarget),laneIdentity:t.laneIdentity}),i=await j(e.ecdsa.sessionStore,r);if(r.source===`active_wallet_authority`){if(i.source!==`active_wallet_authority`)throw Error(`[SigningEngine][ecdsa-export] active lane material source changed`);return{kind:`active_wallet_authority`,exportLane:r,exportMaterial:i}}if(i.source!==`canonical_capability`)throw Error(`[SigningEngine][ecdsa-export] canonical lane material source changed`);return{kind:`canonical_capability`,exportLane:r,exportMaterial:i}}function Yt(e){if(!(!e||e.source!==`canonical_capability`||!e.authorization))return e.authorization.operationCredential.walletSessionId}function Xt(e){let t=e.exportLane?.publicFacts,n=e.exportLane?g({walletId:e.exportLane.key.walletId,publicFacts:e.exportLane.publicFacts}):void 0;try{console.warn(`[SigningEngine][ecdsa-export][failure]`,{operationId:e.flowId,authMethod:e.exportLane?.authMethod,...n?{evmFamilyKeyFingerprint:n}:{},...t?{keyHandle:String(t.keyHandle)}:{},chainTargetKey:u(e.input.chainTarget),...Yt(e.exportLane)?{walletSessionId:Yt(e.exportLane)}:{},materialActivationId:e.exportLane?.laneIdentity.signer.materialActivation.activationId,freshAuthRetrySideEffectState:`not_applicable`,error:e.error instanceof Error?e.error.message:String(e.error||`unknown error`)})}catch{}}async function Zt(e,t,n){let r=l(t.walletSession.walletId);if(n.kind===`active_wallet_authority`)return await lt(e.ecdsa,{walletId:r,exportLane:n.exportLane,material:n.exportMaterial,options:{variant:t.options.variant,theme:t.options.theme},flowId:t.flowId,onEvent:t.options.onEvent});if(n.exportMaterial.kind===`fresh_email_otp_route_auth_ready`)return await ut(e.ecdsa,{walletId:r,exportLane:n.exportLane,material:n.exportMaterial,options:{variant:t.options.variant,theme:t.options.theme},flowId:t.flowId,onEvent:t.options.onEvent});if(n.exportMaterial.kind===`fresh_passkey_needs_authorization`)return await dt(e.ecdsa,{walletId:r,exportLane:n.exportLane,material:n.exportMaterial,options:{variant:t.options.variant,theme:t.options.theme},flowId:t.flowId,onEvent:t.options.onEvent});throw n.exportMaterial,Error(`[SigningEngine][ecdsa-export] unsupported export material`)}async function Qt(e,t,n){let[r]=await Promise.all([Jt(e,t),e.ecdsa.touchConfirm.initialize()]);if(r.exportLane.authorizationState===`authorization_required`)try{return await Zt(e,t,r)}catch(e){throw Xt({input:t,flowId:t.flowId,exportLane:r.exportLane,exportMaterial:r.exportMaterial,error:e}),e}let i={kind:`ecdsa`,laneIdentity:r.exportLane.laneIdentity,authorization:r.exportLane.authorization},a=await Kt({deps:e,request:{kind:`ecdsa`,laneIdentity:r.exportLane.laneIdentity,authorization:r.exportLane.authorization,nowMs:Date.now()}});try{return await Zt(e,t,r)}catch(o){Xt({input:t,flowId:t.flowId,exportLane:r.exportLane,exportMaterial:r.exportMaterial,error:o});let s=be(o);if(n.kind===`fresh_auth_retry`||s?.kind!==`expired`)throw o;let c=qt({source:i,preflightState:a,detectedAtMs:Date.now()});if(!c)throw o;return await Gt({deps:e,state:c,source:oe.serverRejection}),await Qt(e,t,{kind:`fresh_auth_retry`})}}async function $t(e,t){return await Ht(e.ed25519Yao,{walletId:t.walletSession.walletId,nearAccountId:t.nearAccount.accountId,laneIdentity:t.laneIdentity,materialActivation:t.materialActivation,options:{variant:t.options.variant,theme:t.options.theme},flowId:t.flowId,onEvent:t.options.onEvent})}async function en(e,t){return await Ue(t,async t=>{switch(t.kind){case`ecdsa`:return await Qt(e,t,{kind:`initial`});case`ed25519`:return await $t(e,t)}})}async function tn(e,t){return await Ct(e.laneSelection,t)}export{en as exportKeypairWithUI,tn as resolveExactKeyExportLane};
@@ -1 +0,0 @@
1
- import{C as e,S as t}from"./chains-C_X_fNuS.js";import{n}from"./walletRegistrationSetupPrewarm-B9kpnrbK.js";import{_ as r,c as i,f as a,g as o,h as s,l as c,m as l,n as u,o as d,t as f,v as p}from"./messages-DgJlG9NU.js";import{a as m,c as h,i as g,l as _,n as v,o as y,s as b,t as x,u as S}from"./transactionReviewAdmission-CIvR4W5_.js";import{t as C}from"./events-1dzC4Ocx.js";import{t as w}from"./walletIframeIdentity-Cz82I_Uh.js";import{t as T}from"./errors-DIWY1KR9.js";function E(){let e=globalThis;e.global===void 0&&(e.global=globalThis),!e.process||typeof e.process!=`object`?e.process={env:{}}:(!e.process.env||typeof e.process.env!=`object`)&&(e.process.env={})}function D(){E(),window.location.origin===`null`&&(window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`),console.warn(`[WalletHost] iframe is running with opaque (null) origin. Check COEP/CORP headers and ensure navigation succeeded.`)),O(),window.parent?.postMessage({type:`SERVICE_HOST_BOOTED`},`*`),window.parent?.postMessage({type:`SERVICE_HOST_DEBUG_ORIGIN`,origin:window.location.origin,href:window.location.href},`*`);let e=new URL(import.meta.url),t=e.searchParams.get(`v`);t&&l(t);let n=new URL(`.`,e).toString(),r=n.endsWith(`/`)?n:n+`/`;a()||s(r)}function O(){let e=()=>{let e=document;e.documentElement.classList.add(`seams-transparent`),e.body?.classList.add(`seams-transparent`),e.documentElement.classList.remove(`dark`),e.body?.classList.remove(`dark`)};document.readyState===`loading`?document.addEventListener(`DOMContentLoaded`,()=>e(),{once:!0}):e(),window.addEventListener(`load`,()=>e(),{once:!0})}const k={};let A=null,j=null;function M(e){return e.type===`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`?(A??=import(`./runtime-recovery-codes-rLR4Guy4.js`),A):(k[e.kind]??=P(e.kind),k[e.kind])}async function N(){A??=import(`./runtime-recovery-codes-rLR4Guy4.js`),j??=Promise.all([A,import(`./mountRecoveryCodeBackupSurface-D1G-iCPI.js`)]).then(()=>void 0),await j}function P(e){switch(e){case`auth`:return import(`./runtime-auth-TZw6JD8N.js`);case`near`:return import(`./runtime-near-B-vYxGjl.js`);case`ecdsa`:return import(`./runtime-ecdsa-tempo-DlKMIbyP.js`);case`email_otp`:return import(`./runtime-email-otp-BBPghU2G.js`);case`recovery`:return import(`./runtime-recovery-Vg1ND2nl.js`);case`export`:return import(`./runtime-export-pw-xJL8o.js`);case`device_link`:return import(`./runtime-device-link-DXjabXJb.js`);case`preferences`:return import(`./runtime-preferences-D-hY0RfC.js`)}return F(e)}function F(e){throw Error(`Unhandled wallet host runtime route: ${String(e)}`)}function I(e){throw Error(`Unhandled wallet host route: ${String(e)}`)}function L(e,t){if(e===null)throw Error(`Invalid ${t} payload`);return e}function R(e){try{return w(e)}catch{throw Error(`Hosted auth-menu request requires a non-empty requestId`)}}function z(e){switch(e.type){case`PM_ACTIVATE_TRANSACTION_REVIEW`:case`PING`:case`PM_SET_CONFIG`:case`PM_CANCEL`:case`PM_SET_TRANSACTION_VIEW`:case`PM_TRANSACTION_BROADCAST_STARTED`:return{kind:`boot`,type:e.type,request:e};case`PM_REGISTER_WALLET`:case`PM_ADD_WALLET_SIGNER`:case`PM_ADD_PASSKEY`:case`PM_ADD_EMAIL_OTP`:case`PM_REVOKE_AUTH_METHOD`:case`PM_GET_NEAR_PROVISIONING_STATE`:case`PM_SIGN_TX_WITH_ACTIONS`:case`PM_SIGN_AND_SEND_TX`:case`PM_SEND_TRANSACTION`:case`PM_SIGN_DELEGATE_ACTION`:case`PM_SIGN_NEP413`:return{kind:`near`,type:e.type,request:e};case`PM_OPEN_AUTH_MENU`:{let t=R(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:L(c(e.payload),`hosted auth-menu open`)}}}case`PM_CANCEL_AUTH_MENU`:{let t=R(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:L(d(e.payload),`hosted auth-menu cancellation`)}}}case`PM_RESOLVE_AUTH_MENU_EXTERNAL_AUTH`:{let t=R(e.requestId);return{kind:`auth`,type:e.type,request:{...e,requestId:t,payload:L(i(e.payload),`hosted auth-menu external-auth resolution`)}}}case`PM_UNLOCK`:case`PM_LOCK`:case`PM_LOCK_EXACT_WALLET_SESSION`:case`PM_GET_LAST_WALLET_MOVE_REQUEST`:case`PM_MOVE_WALLET`:case`PM_GET_WALLET_MOVE`:case`PM_GET_WALLET_PLACEMENT`:case`PM_GET_WALLET_SESSION`:case`PM_GET_EXACT_WALLET_SESSION_STATE`:case`PM_GET_RECENT_UNLOCKS`:return{kind:`auth`,type:e.type,request:e};case`PM_SIGN_TEMPO`:case`PM_REPORT_TEMPO_BROADCAST_ACCEPTED`:case`PM_REPORT_TEMPO_BROADCAST_REJECTED`:case`PM_REPORT_TEMPO_FINALIZED`:case`PM_REPORT_TEMPO_DROPPED_OR_REPLACED`:case`PM_RECONCILE_TEMPO_NONCE_LANE`:return{kind:`ecdsa`,type:e.type,request:e};case`PM_REDEEM_HOSTED_WALLET_SEAMS_SESSION`:case`PM_REQUEST_EMAIL_OTP_CHALLENGE`:case`PM_BEGIN_GOOGLE_EMAIL_OTP_WALLET_AUTH`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_RESEND`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_REROLL_WALLET_ID`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_SUBMIT`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_COMPLETE_REGISTRATION`:case`PM_GOOGLE_EMAIL_OTP_WALLET_AUTH_CANCEL`:case`PM_GET_WALLET_RECOVERY_CODE_STATUS`:case`PM_ACKNOWLEDGE_WALLET_RECOVERY_CODE_BACKUP`:case`PM_ROTATE_WALLET_RECOVERY_CODES`:case`PM_REQUEST_WALLET_CUSTODY_EMAIL_OTP_CHALLENGE`:return{kind:`email_otp`,type:e.type,request:e};case`PM_SYNC_ACCOUNT_FLOW`:return{kind:`recovery`,type:e.type,request:e};case`PM_RESOLVE_EXACT_KEY_EXPORT_LANE`:case`PM_EXPORT_KEYPAIR_UI`:return{kind:`export`,type:e.type,request:e};case`PM_HAS_PASSKEY`:case`PM_LIST_LINKED_DEVICES`:case`PM_REVOKE_LINKED_DEVICE`:case`PM_SCAN_AND_LINK_DEVICE`:case`PM_START_DEVICE2_LINKING_FLOW`:case`PM_DEVICE_LINK_TARGET_FACTOR_ACTION`:case`PM_DEVICE_LINK_EMAIL_OTP_BASE_FACTOR_ACTION`:case`PM_CANCEL_DEVICE_LINKING`:return{kind:`device_link`,type:e.type,request:e};case`PM_SET_CONFIRM_BEHAVIOR`:case`PM_SET_CONFIRMATION_CONFIG`:case`PM_GET_CONFIRMATION_CONFIG`:return{kind:`preferences`,type:e.type,request:e}}return I(e)}function B(e){return e.kind!==`boot`}let V=!1;const H=[{selector:`.seams-auth-menu-surface`,cancellationKind:`native_cancel`},{selector:`.seams-confirmation-surface`,cancellationKind:`native_cancel`},{selector:`.seams-export-surface`,cancellationKind:`wallet_iframe_cancel`},{selector:`[data-seams-wallet-recovery-backup-dialog]`,cancellationKind:`native_cancel`}];function U(e,t){let n=new Set(t),r=Object.keys(e);return r.length===t.length&&r.every(e=>n.has(e))}function W(t){return!e(t)||!U(t,[`type`,`payload`])||t.type!==`CONNECT`||!e(t.payload)||!U(t.payload,[`protocolVersion`])?null:typeof t.payload.protocolVersion==`string`?{type:`CONNECT`,payload:{protocolVersion:t.payload.protocolVersion}}:null}function G(e){if(e===`null`)return!0;try{let t=new URL(e);return(t.protocol===`https:`||t.protocol===`http:`)&&t.origin===e}catch{return!1}}function K(e){try{e.close()}catch{}}function q(e,t){if(t===`15.0.0`)return!1;let n={expectedProtocolVersion:u,receivedProtocolVersion:t};try{e.postMessage({type:`ERROR`,payload:{code:f,message:`Wallet iframe protocol version mismatch: expected ${u}, received ${t??`missing`}`,details:n}})}catch{}return K(e),!0}function J(e,t){return!t||t.has(e.kind)}function Y(e,t,n,r){e.executionGeneration===t&&n(r)}function X(e,t,n,r){return e.executionGeneration!==t||n(r)}function Z(e={}){if(V)return;V=!0,D(),(!e.supportedRuntimeRouteKinds||e.supportedRuntimeRouteKinds.has(`email_otp`))&&N().catch(()=>void 0);let i=new Set,a=new Set,s={parentOrigin:null,port:null,configuration:{kind:`unconfigured`},executionGeneration:0,onConfigurationChanged:null},c=e=>{try{s.port?.postMessage(e)}catch{}},l=e=>{e&&i.add(e)},d=e=>!!e&&(i.has(e)||g(e)?.cancelled===!0),f=e=>{e&&i.delete(e)},w=e=>{e&&c({type:`ERROR`,requestId:e,payload:{code:`cancelled`,message:`Request cancelled`}})},E=e=>!e||!d(e)?!1:g(e)?.cancelled?!0:(w(e),f(e),!0),O=()=>{for(let e of H){let t=document.querySelectorAll(e.selector);for(let n of t)try{e.cancellationKind===`native_cancel`?n.dispatchEvent(new Event(`cancel`,{cancelable:!0})):n.dispatchEvent(new CustomEvent(C.TX_CONFIRMER_CANCEL,{bubbles:!0,composed:!0}))}catch{}}},k=async i=>{let u=i.data;if(!u||!t(u))return;let C=u.requestId,D=s.executionGeneration,k=Y.bind(null,s,D,c),A=null;try{if(`transactionReview`in u){if(u.type!==`PM_SIGN_AND_SEND_TX`&&u.type!==`PM_SIGN_TEMPO`)throw new m(`review_invalid_input`,`Review is unsupported for this request`);let e=h(u.transactionReview);if(e.requestId!==C)throw new m(`review_invalid_input`,`Review request identity mismatch`);let t=u.payload?.options?.confirmationConfig;if(t?.uiMode!==`modal`||t.behavior!==`requireClick`)throw new m(`review_unsupported_mode`,`Review requires modal presentation and explicit approval`);A=new x(e,u.type===`PM_SIGN_TEMPO`&&u.payload?.request.senderSignatureAlgorithm!==`secp256k1`?`credential`:`mpc`,e=>k({type:`TRANSACTION_REVIEW_STATE`,requestId:C,payload:e}),e=>k({type:`ERROR`,requestId:C,payload:{code:e instanceof m?e.code:`cancelled`,message:e.message}}))}(u.type===`PM_LOCK`||u.type===`PM_LOCK_EXACT_WALLET_SESSION`)&&v(new m(`review_identity_changed`,`The wallet session changed`));let t=z(u);if(!B(t))switch(t.type){case`PING`:c({type:`PONG`,requestId:C});return;case`PM_SET_CONFIG`:{let e=o(s.configuration,r(t.request.payload)),i=p(s.configuration.kind===`configured`?s.configuration.config:null)!==p(e.config);if(s.configuration=e,i){s.executionGeneration+=1;let t=e.config;t.registration.publishableKey&&t.registration.projectEnvironmentId&&n(t.network.relayer.url);for(let e of a)c({type:`ERROR`,requestId:e,payload:{code:`wallet_configuration_changed`,message:`Wallet configuration changed during request`}});a.clear()}s.onConfigurationChanged?.(),i&&(v(new m(`review_identity_changed`,`Wallet execution configuration changed`)),O()),c({type:`PONG`,requestId:C});return}case`PM_ACTIVATE_TRANSACTION_REVIEW`:{let e=b(t.request.payload);e&&g(e.requestId)?.activate(e);return}case`PM_CANCEL`:{let e=t.request.payload?.requestId,n=t.request.payload,r=n&&typeof n==`object`?Reflect.get(n,`transactionReview`):void 0;if(r!==void 0){let t=h(r),i=g(t.requestId);if(t.requestId===e&&i&&_(t,i.metadata)){let e=new m(S(n&&typeof n==`object`?Reflect.get(n,`reviewErrorCode`):void 0),`Reviewed request cancelled`);try{y(i.metadata.validity)}catch(t){t instanceof Error&&(e=t)}i.cancel(e)}c({type:`PONG`,requestId:C});return}let i=e?g(e):void 0;if(i){i.cancel(new m(`cancelled`,`Request cancelled`)),c({type:`PONG`,requestId:C});return}l(e),O(),e&&w(e),c({type:`PONG`,requestId:C});return}case`PM_SET_TRANSACTION_VIEW`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`requestId`):null,r=e&&typeof e==`object`?Reflect.get(e,`view`):null;typeof n==`string`&&(r===`toast`||r===`closed`)&&(await import(`./transaction-activity-xfeHKJoq.js`).then(e=>e.o)).setTransactionActivityView(n,r);return}case`PM_TRANSACTION_BROADCAST_STARTED`:{let e=t.request.payload,n=e&&typeof e==`object`?Reflect.get(e,`signedTransaction`):null;typeof n==`string`&&(await import(`./transaction-activity-xfeHKJoq.js`).then(e=>e.o)).transactionBroadcastStarted(n);return}}if(!J(t,e.supportedRuntimeRouteKinds)){c({type:`ERROR`,requestId:C,payload:{code:`unsupported_request`,message:`Unsupported wallet iframe request type: ${t.type}`}});return}C&&a.add(C);let i=await M(t);if(D!==s.executionGeneration)return;await i.handleWalletHostRuntimeRequest({transactionReview:A,state:s,executionGeneration:D,req:t.request,post:Y.bind(null,s,D,c),isCancelled:X.bind(null,s,D,d),respondIfCancelled:X.bind(null,s,D,E)})}catch(e){if(D!==s.executionGeneration&&u.type!==`PM_SET_CONFIG`||A?.cancelled)return;let t=await import(`./canonicalSignerErrorCode-Cz48v4oy.js`);if(D!==s.executionGeneration&&u.type!==`PM_SET_CONFIG`)return;let n=e&&typeof e==`object`&&`code`in e?e.code:void 0,r=T(e),i=t.resolveWalletBoundaryErrorCode({requestType:u.type,rawCode:n,message:r,defaultCode:`HOST_ERROR`}),a=t.resolveWalletBoundaryErrorMessage({requestType:u.type,rawCode:n,code:i,message:r}),o=t.resolveWalletBoundarySignerKind(u.type);c({type:`ERROR`,requestId:C,payload:{code:i,message:a,...t.isWalletSignerBoundaryRequestType(u.type)&&t.isCanonicalSignerSessionBoundaryCode(i)&&o?{signerKind:o}:{}}})}finally{C&&(a.delete(C),f(C)),A?.finish()}};window.addEventListener(`message`,e=>{let t=W(e.data),n=e.ports[0];if(!(!t||!n||s.port)){if(e.source!==window.parent||!G(e.origin)){K(n);return}if(!q(n,t.payload.protocolVersion)){typeof e.origin==`string`&&e.origin.length&&e.origin!==`null`&&(s.parentOrigin=e.origin),s.port=n;try{s.port.onmessage=k,s.port.start?.()}catch{}c({type:`READY`,payload:{protocolVersion:u}})}}})}try{Z()}catch(e){console.error(`[WalletHost] init failed`,e)}export{Z as t};
@@ -1 +0,0 @@
1
- import{M as e,O as t,T as n}from"./domainIds-BzkGsRqO.js";import{C as r,T as i,b as a,k as o,n as s,r as c}from"./chains-C_X_fNuS.js";import"./signingSessionSeal-DX41aXUL.js";import{t as l}from"./configBuilder-BMawmNpz.js";import{r as u}from"./activeWalletSession-WdZkhtBB.js";import{t as d}from"./walletIframeIdentity-Cz82I_Uh.js";function f(e){return r(e)&&Object.values(e).every(i)}function p(e){if(!r(e)||e.palette!==`default`||!r(e.theme))return!1;let t=e.theme;return i(t.id)&&t.id.trim().length>0&&(t.mode===`dark`||t.mode===`light`)&&f(t.colors)&&(t.shape===void 0||f(t.shape))}function m(e){return!r(e)||!c(e.network)?!1:i(e.rpcUrl)&&e.rpcUrl.trim().length>0&&i(e.explorerUrl)&&(s(e.network)||a(e.chainId)&&Number.isSafeInteger(e.chainId)&&e.chainId>0)}function h(e){if(!r(e)||!Array.isArray(e.chains)||!e.chains.every(m))return!1;let t=e.relayer;return r(t)&&i(t.accountId)&&i(t.url)&&t.url.trim().length>0&&r(t.routes)&&i(t.routes.delegateAction)}function g(e){if(!r(e)||e.mode!==`managed`)return!1;let t=e.nearAccountProvisioning;return i(e.publishableKey)&&i(e.projectEnvironmentId)&&(e.paymentMode===`disabled`||e.paymentMode===`quota_then_x402`||e.paymentMode===`always_x402`)&&r(t)&&(t.kind===`implicit_account`||t.kind===`relayer_named_subaccount`)}function _(e){return r(e)&&a(e.ttlMs)&&a(e.remainingUses)}function v(e){if(!r(e)||typeof e.enabled!=`boolean`||!_(e.signingSession))return!1;let t=o(e.signingSession,`signingSession`);return t.kind===`jwt`||t.kind===`cookie`}function y(e){return r(e)?e.mode===`disabled`?e.signingWorkerId===void 0:e.mode===`enabled`&&i(e.signingWorkerId)&&e.signingWorkerId.trim().length>0:!1}function ee(e){return r(e)?typeof e.enabled==`boolean`&&a(e.targetDepth)&&Number.isInteger(e.targetDepth)&&e.targetDepth>=l.targetDepth.min&&e.targetDepth<=l.targetDepth.max&&a(e.lowWatermark)&&Number.isInteger(e.lowWatermark)&&e.lowWatermark>=0&&e.lowWatermark<=e.targetDepth&&a(e.maxRefillInFlight)&&Number.isInteger(e.maxRefillInFlight)&&e.maxRefillInFlight>=l.maxRefillInFlight.min&&e.maxRefillInFlight<=l.maxRefillInFlight.max&&a(e.refillAttemptTimeoutMs)&&Number.isInteger(e.refillAttemptTimeoutMs)&&e.refillAttemptTimeoutMs>=l.refillAttemptTimeoutMs.min&&e.refillAttemptTimeoutMs<=l.refillAttemptTimeoutMs.max:!1}function te(e){if(!r(e)||!_(e.sessionDefaults)||!r(e.emailOtp)||e.emailOtp.authPolicy!==`session`&&e.emailOtp.authPolicy!==`per_operation`||!r(e.routerAb)||!y(e.routerAb.normalSigning)||!r(e.routerAbEcdsaDerivation)||!ee(e.routerAbEcdsaDerivation.presignaturePool)||!r(e.thresholdEcdsa)||!r(e.thresholdEcdsa.provisioningDefaults))return!1;let t=e.thresholdEcdsa.provisioningDefaults;if(!v(t.tempo)||!v(t.evm))return!1;let n=e.sessionSeal;return r(n)?e.sessionPersistenceMode===`none`?n.mode===`none`&&n.protocol===void 0:e.sessionPersistenceMode===`sealed_refresh_v1`&&n.mode===`sealed_refresh_v1`&&r(n.protocol)&&n.protocol.algorithm===`shamir3pass-v2`&&n.protocol.groupId===`rfc2409-group2`:!1}function ne(e){if(!r(e)||!r(e.authenticatorOptions))return!1;let t=e.authenticatorOptions;if(t.userVerification!==`required`&&t.userVerification!==`preferred`&&t.userVerification!==`discouraged`)return!1;let n=t.originPolicy;return r(n)&&(n.single===void 0||typeof n.single==`boolean`)&&(n.all_subdomains===void 0||typeof n.all_subdomains==`boolean`)&&(n.multiple===void 0||Array.isArray(n.multiple)&&n.multiple.every(i))}function b(t){if(!r(t)||t.mode!==`direct`||t.iframe!==void 0)return!1;let n=e(t.rpId);return n.ok&&n.value===t.rpId}function x(e){return r(e)&&h(e.network)&&g(e.registration)&&te(e.signing)&&ne(e.webauthn)&&b(e.wallet)&&r(e.ui)&&p(e.ui.appearance)}function S(e){if(!x(e))throw Error(`Invalid resolved wallet host configuration`);return e}function C(e,t){return{network:e.network,registration:e.registration,signing:e.signing,webauthn:e.webauthn,wallet:e.wallet,ui:{appearance:t}}}function w(e){let t=o(e,`wallet configuration update`);if(t.kind===`configure`&&i(t.assetsBaseUrl)&&t.assetsBaseUrl.length>0&&t.appearance===void 0)return{kind:`configure`,config:S(t.config),assetsBaseUrl:t.assetsBaseUrl};if(t.kind===`appearance`&&p(t.appearance)&&t.config===void 0&&t.assetsBaseUrl===void 0)return{kind:`appearance`,appearance:t.appearance};throw Error(`Invalid wallet configuration update`)}function T(e,t){switch(t.kind){case`configure`:return{kind:`configured`,config:t.config,assetsBaseUrl:t.assetsBaseUrl};case`appearance`:if(e.kind!==`configured`)throw Error(`Wallet configuration is required before appearance updates`);return{kind:`configured`,config:C(e.config,t.appearance),assetsBaseUrl:e.assetsBaseUrl}}}function E(e){if(Array.isArray(e))return e.map(E);if(e&&typeof e==`object`){let t=e,n={};for(let e of Object.keys(t).sort())n[e]=E(t[e]);return n}return e}function D(e){return JSON.stringify(E({network:e?.network,registration:e?.registration,signing:e?.signing,webauthn:e?.webauthn,rpId:e?.wallet.rpId}))}const O=`__SEAMS_WALLET_SDK_BASE__`,k=`SEAMS_WALLET_SDK_BASE_CHANGED`,A=`__SEAMS_WALLET_ASSET_VERSION__`;function re(){if(typeof window>`u`)return;let e=window[O];return typeof e==`string`&&e.length>0?e:void 0}function j(e){if(typeof window>`u`)return;let t=window;t[O]=e,window.dispatchEvent(new CustomEvent(k,{detail:e}))}function M(){if(typeof window>`u`)return;let e=window[A];return typeof e==`string`&&e.length>0?e:void 0}function N(e){if(typeof window>`u`)return;let t=e.trim();t&&(window[A]=t)}function P(e){if(typeof window>`u`)return()=>{};let t=t=>{let n=t.detail;typeof n==`string`&&n.length>0&&e(n)};return window.addEventListener(k,t,{passive:!0}),()=>window.removeEventListener(k,t)}const F={login:{title:`Welcome back`,subtitle:``,passkeyCta:`Unlock with passkey`},register:{title:`Create a wallet`,subtitle:``,passkeyNameLabel:`Wallet name`,passkeyCta:`Create wallet with passkey`},common:{closeLabel:`Close`}};function I(e,t){return typeof e==`string`&&e.trim()||null}function L(e,t){let n=I(e,t);return n===null?null:n}function R(e){try{return d(e)}catch{return null}}function z(e,t){let n=new Set(t);return Object.keys(e).every(e=>n.has(e))}function B(e){return L(e,`authMenuSessionId`)}function V(e){return L(e,`externalAuthRequestId`)}function H(e){return r(e)?e:null}function U(e,t=new Set,n=!1){if(e===void 0)return n;if(e===null||typeof e==`string`||typeof e==`boolean`)return!0;if(typeof e==`number`)return Number.isFinite(e);if(typeof e!=`object`||t.has(e))return!1;if(t.add(e),Array.isArray(e))return e.every(e=>U(e,t,n));let r=H(e);return r!==null&&Object.values(r).every(e=>U(e,t,n))}function W(e,t){return I(e,`copy`)??t}function G(e,t){let n=H(e);return{title:W(n?.title,t.title),subtitle:W(n?.subtitle,t.subtitle),passkeyCta:W(n?.passkeyCta,t.passkeyCta)}}function K(e){let t=H(e),n=H(t?.register);return{login:G(t?.login,F.login),register:{...G(t?.register,F.register),passkeyNameLabel:W(n?.passkeyNameLabel,F.register.passkeyNameLabel)},common:{closeLabel:W(H(t?.common)?.closeLabel,F.common.closeLabel)}}}function ie(e){return e===`google`?e:null}function q(e){return e===`login`||e===`register`?e:null}function J(e){return e===`implicit_wallet`||e===`sponsored_named_near_account`?e:null}function Y(e){return e===`close_button`||e===`component_unmounted`||e===`connection_closed`?e:null}function X(e,t){if(e===void 0)return!0;let n=H(e);return n!==null&&z(n,t)}function ae(e){let t=H(e);return!t||!z(t,[`login`,`register`,`common`])?!1:X(t.login,[`title`,`subtitle`,`passkeyCta`])&&X(t.register,[`title`,`subtitle`,`passkeyCta`,`passkeyNameLabel`])&&X(t.common,[`closeLabel`])}function oe(e){if(!Array.isArray(e))return null;let t=[];for(let n of e){let e=ie(n);if(!e)return null;t.push(e)}return t}function se(e){let n=H(e);if(!n||!U(n,new Set,!0)||n.kind!==`hosted_auth_menu_open_v1`||!z(n,[`kind`,`authMenuSessionId`,`initialMode`,`loginTarget`,`registrationAccountInput`,`showRegistrationInput`,`showProgress`,`copy`,`enabledExternalProviders`])||!ae(n.copy))return null;let r=B(n.authMenuSessionId),i=q(n.initialMode),a=H(n.loginTarget),o=a?.kind===`wallet`||a?.kind===`wallet_sync`?t(a.walletId):null,s=a?.kind===`discoverable`&&z(a,[`kind`])?{kind:`discoverable`}:a?.kind===`wallet`&&z(a,[`kind`,`walletId`])&&o?.ok?{kind:`wallet`,walletId:o.value}:a?.kind===`wallet_sync`&&z(a,[`kind`,`walletId`])&&o?.ok?{kind:`wallet_sync`,walletId:o.value}:null,c=J(n.registrationAccountInput),l=oe(n.enabledExternalProviders);return!r||!i||!s||!c||typeof n.showRegistrationInput!=`boolean`||typeof n.showProgress!=`boolean`||!l||!U(n.copy,new Set,!0)?null:{kind:`hosted_auth_menu_open_v1`,authMenuSessionId:r,initialMode:i,loginTarget:s,registrationAccountInput:c,showRegistrationInput:n.showRegistrationInput,showProgress:n.showProgress,copy:K(n.copy),enabledExternalProviders:l}}function ce(e){let t=H(e);if(!t||!U(t)||t.kind!==`hosted_auth_menu_error_v1`||!z(t,[`kind`,`authMenuSessionId`,`mode`,`message`]))return null;let n=B(t.authMenuSessionId),r=q(t.mode),i=I(t.message,`message`);return n&&r&&i?{kind:t.kind,authMenuSessionId:n,mode:r,message:i}:null}function le(e){let t=H(e);if(!t||!U(t))return null;switch(t.kind){case`google_id_token`:{if(!z(t,[`kind`,`idToken`]))return null;let e=I(t.idToken,`idToken`);return e?{kind:t.kind,idToken:e}:null}case`cancelled`:return z(t,[`kind`,`reason`])&&t.reason===`user_cancelled`?{kind:t.kind,reason:t.reason}:null;case`failed`:{if(!z(t,[`kind`,`code`,`message`]))return null;let e=t.code===`provider_unavailable`||t.code===`provider_error`||t.code===`invalid_evidence`?t.code:null,n=I(t.message,`message`);return e&&n?{kind:t.kind,code:e,message:n}:null}default:return null}}function ue(e){let t=H(e);if(!t||!U(t)||t.kind!==`hosted_auth_menu_external_auth_resolution_v1`||!z(t,[`kind`,`authMenuSessionId`,`externalAuthRequestId`,`requestId`,`evidence`]))return null;let n=B(t.authMenuSessionId),r=V(t.externalAuthRequestId),i=R(t.requestId),a=le(t.evidence);return!n||!r||!i||!a?null:{kind:t.kind,authMenuSessionId:n,externalAuthRequestId:r,requestId:i,evidence:a}}function de(e){let t=H(e);if(!t||!U(t)||t.kind!==`hosted_auth_menu_cancel_v1`||!z(t,[`kind`,`authMenuSessionId`,`requestId`,`reason`]))return null;let n=B(t.authMenuSessionId),r=R(t.requestId),i=Y(t.reason);return n&&r&&i?{kind:t.kind,authMenuSessionId:n,requestId:r,reason:i}:null}const fe=`15.0.0`,pe=`WALLET_IFRAME_PROTOCOL_VERSION_MISMATCH`,Z=[`home`,`exchangeCode`,`nonce`,`appOrigin`,`walletOrigin`,`relayUrl`];function Q(e,t){if(typeof e!=`string`||e.length===0||e.length>512||e.trim()!==e||/[\s\u0000-\u001f\u007f]/.test(e))throw Error(`${t} must be a compact opaque identifier`);return e}function $(e,t){if(typeof e!=`string`||e.length===0||e.trim()!==e)throw Error(`${t} must be a canonical HTTP origin`);let n;try{n=new URL(e)}catch{throw Error(`${t} must be a canonical HTTP origin`)}if(n.protocol!==`https:`&&n.protocol!==`http:`||n.origin!==e||n.pathname!==`/`||n.search!==``||n.hash!==``)throw Error(`${t} must be a canonical HTTP origin`);return n.origin}function me(e){if(!r(e))throw Error(`hosted-wallet redemption payload must be an exact object`);if(Object.keys(e).length!==Z.length)throw Error(`hosted-wallet redemption payload fields are invalid`);for(let t of Z)if(!Object.hasOwn(e,t))throw Error(`hosted-wallet redemption payload fields are invalid`);return{home:u(e.home),exchangeCode:Q(e.exchangeCode,`exchangeCode`),nonce:Q(e.nonce,`nonce`),appOrigin:$(e.appOrigin,`appOrigin`),walletOrigin:$(e.walletOrigin,`walletOrigin`),relayUrl:Q(e.relayUrl,`relayUrl`)}}function he(e){if(!r(e)||!z(e,[`scanRequestId`,`action`])||typeof e.scanRequestId!=`string`||e.scanRequestId.length===0||!r(e.action))return null;let t=e.action;if(t.kind===`cancel`)return z(t,[`kind`])?{scanRequestId:e.scanRequestId,action:{kind:t.kind}}:null;if(t.kind!==`select`||!z(t,[`kind`,`baseWalletAuthMethodId`]))return null;let i=n(t.baseWalletAuthMethodId);return i.ok?{scanRequestId:e.scanRequestId,action:{kind:t.kind,baseWalletAuthMethodId:i.value}}:null}function ge(e){if(!r(e)||!z(e,[`activationId`,`action`])||typeof e.activationId!=`string`||e.activationId.length===0||!r(e.action))return null;let t=e.action;switch(t.kind){case`create_passkey`:case`send_email_otp`:case`resend_email_otp`:return z(t,[`kind`])?{activationId:e.activationId,action:{kind:t.kind}}:null;case`submit_email_otp`:return z(t,[`kind`,`otpCode`])&&typeof t.otpCode==`string`&&/^\d{6}$/.test(t.otpCode)?{activationId:e.activationId,action:{kind:t.kind,otpCode:t.otpCode}}:null;default:return null}}export{w as _,ge as a,ue as c,M as d,re as f,T as g,j as h,he as i,se as l,N as m,fe as n,de as o,P as p,V as r,ce as s,pe as t,me as u,D as v};