@crossmint/wallets-sdk 1.6.1 → 1.7.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 (293) hide show
  1. package/dist/api/__tests__/constants.d.cts +1 -1
  2. package/dist/api/__tests__/constants.d.ts +1 -1
  3. package/dist/api/__tests__/test-utils.cjs +1 -1
  4. package/dist/api/__tests__/test-utils.d.cts +1 -1
  5. package/dist/api/__tests__/test-utils.d.ts +1 -1
  6. package/dist/api/__tests__/test-utils.js +1 -1
  7. package/dist/api/client.cjs +1 -1
  8. package/dist/api/client.d.cts +1 -1
  9. package/dist/api/client.d.ts +1 -1
  10. package/dist/api/client.js +1 -1
  11. package/dist/api/gen/index.cjs +1 -1
  12. package/dist/api/gen/index.js +1 -1
  13. package/dist/api/index.cjs +1 -1
  14. package/dist/api/index.d.cts +1 -1
  15. package/dist/api/index.d.ts +1 -1
  16. package/dist/api/index.js +1 -1
  17. package/dist/api/types.d.cts +1 -1
  18. package/dist/api/types.d.ts +1 -1
  19. package/dist/chains/adapters/evm.cjs +1 -1
  20. package/dist/chains/adapters/evm.d.cts +1 -1
  21. package/dist/chains/adapters/evm.d.ts +1 -1
  22. package/dist/chains/adapters/evm.js +1 -1
  23. package/dist/chains/adapters/solana.cjs +1 -1
  24. package/dist/chains/adapters/solana.d.cts +1 -1
  25. package/dist/chains/adapters/solana.d.ts +1 -1
  26. package/dist/chains/adapters/solana.js +1 -1
  27. package/dist/chains/adapters/stellar.cjs +1 -1
  28. package/dist/chains/adapters/stellar.d.cts +1 -1
  29. package/dist/chains/adapters/stellar.d.ts +1 -1
  30. package/dist/chains/adapters/stellar.js +1 -1
  31. package/dist/chains/chain-adapter.cjs +1 -1
  32. package/dist/chains/chain-adapter.d.cts +1 -1
  33. package/dist/chains/chain-adapter.d.ts +1 -1
  34. package/dist/chains/chain-adapter.js +1 -1
  35. package/dist/chains/chains.cjs +1 -1
  36. package/dist/chains/chains.js +1 -1
  37. package/dist/{chunk-YWZMLT47.js → chunk-3PDACUM7.js} +1 -1
  38. package/dist/{chunk-NE2Y6VFQ.js → chunk-3WDIJIBZ.js} +1 -1
  39. package/dist/chunk-6CNBIQGF.cjs +1 -0
  40. package/dist/{chunk-JFJXQGW5.cjs → chunk-72MJS3AC.cjs} +1 -1
  41. package/dist/{chunk-A3N6JH3M.cjs → chunk-7FQTFYO6.cjs} +1 -1
  42. package/dist/{chunk-SO32FMP7.cjs → chunk-ARN45RZ4.cjs} +1 -1
  43. package/dist/chunk-BBMFGUOH.js +1 -0
  44. package/dist/{chunk-HI72AV4W.cjs → chunk-BCXIEWZK.cjs} +1 -1
  45. package/dist/{chunk-NFDWJLL6.cjs → chunk-BJZM3EV2.cjs} +1 -1
  46. package/dist/{chunk-PNYAMSZ7.cjs → chunk-BOB3OT66.cjs} +1 -1
  47. package/dist/chunk-BZJ5TU7H.cjs +1 -0
  48. package/dist/{chunk-EFAZ2WYW.cjs → chunk-CIMSRCXA.cjs} +1 -1
  49. package/dist/{chunk-UEM7C5FY.js → chunk-CISUOQT6.js} +1 -1
  50. package/dist/{chunk-RKVJZO7O.js → chunk-CNXZJOVE.js} +1 -1
  51. package/dist/{chunk-SJ5MLAQI.cjs → chunk-DBWMNPH7.cjs} +1 -1
  52. package/dist/{chunk-OWDSSX2P.js → chunk-DCKFFFPG.js} +1 -1
  53. package/dist/{chunk-JZYDIP5D.cjs → chunk-DDNFHKJR.cjs} +1 -1
  54. package/dist/{chunk-6A7SZ3QD.js → chunk-DMNULXGD.js} +1 -1
  55. package/dist/{chunk-KSW27XVT.js → chunk-EJCR7VKJ.js} +1 -1
  56. package/dist/chunk-EXFV7SBW.cjs +1 -0
  57. package/dist/{chunk-73FKNIUX.cjs → chunk-EXY6WMAQ.cjs} +1 -1
  58. package/dist/{chunk-TUSSLVSF.cjs → chunk-FO2AO5HQ.cjs} +1 -1
  59. package/dist/chunk-FXMXIAPL.js +1 -0
  60. package/dist/{chunk-LJKNUBZA.js → chunk-GCIDUJF2.js} +1 -1
  61. package/dist/{chunk-CHDHMS5R.cjs → chunk-GIXJ5P3D.cjs} +1 -1
  62. package/dist/chunk-GNON524X.js +1 -0
  63. package/dist/{chunk-NUO3MBBE.cjs → chunk-GZSM6NWF.cjs} +1 -1
  64. package/dist/{chunk-2WS6SXS6.cjs → chunk-HIKDNSEI.cjs} +1 -1
  65. package/dist/{chunk-SWBJ2RMN.cjs → chunk-HIWBYW72.cjs} +1 -1
  66. package/dist/{chunk-BNC4HX7P.js → chunk-HJNJJGK6.js} +1 -1
  67. package/dist/{chunk-K55DPXZQ.cjs → chunk-I3H3U7XW.cjs} +1 -1
  68. package/dist/{chunk-RKUCX4Z4.cjs → chunk-IW4FVUP5.cjs} +2 -2
  69. package/dist/{chunk-JTWVCUVZ.js → chunk-J5SLH6DG.js} +1 -1
  70. package/dist/{chunk-Q4VN3MG7.cjs → chunk-K4CPNZQP.cjs} +1 -1
  71. package/dist/{chunk-46Z5EE2F.js → chunk-KQOBLF64.js} +1 -1
  72. package/dist/{chunk-4DLKWRLY.cjs → chunk-LSJDT5QL.cjs} +1 -1
  73. package/dist/{chunk-7SKKGHMB.js → chunk-M4U7HAZ6.js} +1 -1
  74. package/dist/{chunk-UAB6KH63.js → chunk-M5A2GB2R.js} +1 -1
  75. package/dist/{chunk-7KF4AULF.cjs → chunk-MQE44PAR.cjs} +2 -2
  76. package/dist/{chunk-66XVKHJQ.cjs → chunk-MYLHEIBD.cjs} +1 -1
  77. package/dist/{chunk-6GEBK257.cjs → chunk-MYWEABPN.cjs} +1 -1
  78. package/dist/{chunk-K7BNQDN2.cjs → chunk-N2YQ7SK2.cjs} +1 -1
  79. package/dist/{chunk-ULAIS6HM.js → chunk-N6LXJTAC.js} +1 -1
  80. package/dist/chunk-NFX2WUB6.js +1 -0
  81. package/dist/{chunk-6ZD7NFX6.js → chunk-NLMPNCXE.js} +1 -1
  82. package/dist/{chunk-M7BGVCMZ.cjs → chunk-NML6ZUFM.cjs} +1 -1
  83. package/dist/{chunk-Z5DV2DB7.js → chunk-OE4UVHAK.js} +1 -1
  84. package/dist/{chunk-RPBBYBNA.js → chunk-OEMMPPUX.js} +1 -1
  85. package/dist/{chunk-SNAWZWNR.cjs → chunk-OI6QI264.cjs} +1 -1
  86. package/dist/{chunk-WK67OXB3.js → chunk-OMTJMVSG.js} +1 -1
  87. package/dist/{chunk-QOSA6B55.js → chunk-OTFPEC53.js} +1 -1
  88. package/dist/{chunk-PVXNJEBO.js → chunk-P4P3Q7F2.js} +1 -1
  89. package/dist/chunk-PH5XGZFF.cjs +1 -0
  90. package/dist/{chunk-76TBLKLF.js → chunk-QJALSMVI.js} +1 -1
  91. package/dist/{chunk-5HBCBS5W.cjs → chunk-QPCZFIUV.cjs} +1 -1
  92. package/dist/{chunk-LKFW3NS5.js → chunk-R23CUQZX.js} +1 -1
  93. package/dist/chunk-R7S55N7J.cjs +1 -0
  94. package/dist/{chunk-VPBJ7L4I.js → chunk-S7DYRZI2.js} +1 -1
  95. package/dist/{chunk-U7MO5CYP.cjs → chunk-SEXK7X55.cjs} +1 -1
  96. package/dist/{chunk-S7XUH7XP.js → chunk-T6VDXOWC.js} +1 -1
  97. package/dist/{chunk-6VH3KWLM.js → chunk-U37UWZ6M.js} +1 -1
  98. package/dist/{chunk-7VMBZI5M.cjs → chunk-U6SAS52Q.cjs} +1 -1
  99. package/dist/chunk-V3BCKXZ6.js +1 -0
  100. package/dist/{chunk-KQNMPKVE.js → chunk-VBM6V2GS.js} +1 -1
  101. package/dist/chunk-VKXHD6UP.js +1 -0
  102. package/dist/{chunk-CTQFY3MR.js → chunk-WE32RGKM.js} +1 -1
  103. package/dist/chunk-WT45L3WI.cjs +1 -0
  104. package/dist/chunk-XMN42YI5.cjs +1 -0
  105. package/dist/{chunk-KGQWE3HH.js → chunk-ZLKQZHEG.js} +1 -1
  106. package/dist/chunk-ZUG5BIGQ.js +1 -0
  107. package/dist/index.cjs +1 -1
  108. package/dist/index.d.cts +1 -1
  109. package/dist/index.d.ts +1 -1
  110. package/dist/index.js +1 -1
  111. package/dist/logger/index.cjs +1 -1
  112. package/dist/logger/index.js +1 -1
  113. package/dist/logger/init.cjs +1 -1
  114. package/dist/logger/init.js +1 -1
  115. package/dist/sdk.cjs +1 -1
  116. package/dist/sdk.d.cts +1 -1
  117. package/dist/sdk.d.ts +1 -1
  118. package/dist/sdk.js +1 -1
  119. package/dist/signers/descriptors/api-key.cjs +1 -1
  120. package/dist/signers/descriptors/api-key.d.cts +1 -1
  121. package/dist/signers/descriptors/api-key.d.ts +1 -1
  122. package/dist/signers/descriptors/api-key.js +1 -1
  123. package/dist/signers/descriptors/device.cjs +1 -1
  124. package/dist/signers/descriptors/device.d.cts +1 -1
  125. package/dist/signers/descriptors/device.d.ts +1 -1
  126. package/dist/signers/descriptors/device.js +1 -1
  127. package/dist/signers/descriptors/email.cjs +1 -1
  128. package/dist/signers/descriptors/email.d.cts +1 -1
  129. package/dist/signers/descriptors/email.d.ts +1 -1
  130. package/dist/signers/descriptors/email.js +1 -1
  131. package/dist/signers/descriptors/external-wallet.cjs +1 -1
  132. package/dist/signers/descriptors/external-wallet.d.cts +1 -1
  133. package/dist/signers/descriptors/external-wallet.d.ts +1 -1
  134. package/dist/signers/descriptors/external-wallet.js +1 -1
  135. package/dist/signers/descriptors/index.cjs +1 -1
  136. package/dist/signers/descriptors/index.d.cts +1 -1
  137. package/dist/signers/descriptors/index.d.ts +1 -1
  138. package/dist/signers/descriptors/index.js +1 -1
  139. package/dist/signers/descriptors/passkey.d.cts +1 -1
  140. package/dist/signers/descriptors/passkey.d.ts +1 -1
  141. package/dist/signers/descriptors/phone.cjs +1 -1
  142. package/dist/signers/descriptors/phone.d.cts +1 -1
  143. package/dist/signers/descriptors/phone.d.ts +1 -1
  144. package/dist/signers/descriptors/phone.js +1 -1
  145. package/dist/signers/descriptors/server.cjs +1 -1
  146. package/dist/signers/descriptors/server.d.cts +1 -1
  147. package/dist/signers/descriptors/server.d.ts +1 -1
  148. package/dist/signers/descriptors/server.js +1 -1
  149. package/dist/signers/descriptors/types.d.cts +2 -1
  150. package/dist/signers/descriptors/types.d.ts +2 -1
  151. package/dist/signers/device.d.cts +1 -1
  152. package/dist/signers/device.d.ts +1 -1
  153. package/dist/signers/evm-api-key.d.cts +1 -1
  154. package/dist/signers/evm-api-key.d.ts +1 -1
  155. package/dist/signers/evm-external-wallet.d.cts +1 -1
  156. package/dist/signers/evm-external-wallet.d.ts +1 -1
  157. package/dist/signers/external-wallet-signer.d.cts +1 -1
  158. package/dist/signers/external-wallet-signer.d.ts +1 -1
  159. package/dist/signers/index.cjs +1 -1
  160. package/dist/signers/index.d.cts +1 -1
  161. package/dist/signers/index.d.ts +1 -1
  162. package/dist/signers/index.js +1 -1
  163. package/dist/signers/non-custodial/index.cjs +1 -1
  164. package/dist/signers/non-custodial/index.d.cts +1 -1
  165. package/dist/signers/non-custodial/index.d.ts +1 -1
  166. package/dist/signers/non-custodial/index.js +1 -1
  167. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  168. package/dist/signers/non-custodial/ncs-evm-signer.d.cts +1 -1
  169. package/dist/signers/non-custodial/ncs-evm-signer.d.ts +1 -1
  170. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  171. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  172. package/dist/signers/non-custodial/ncs-signer.d.cts +3 -1
  173. package/dist/signers/non-custodial/ncs-signer.d.ts +3 -1
  174. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  175. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  176. package/dist/signers/non-custodial/ncs-solana-signer.d.cts +1 -1
  177. package/dist/signers/non-custodial/ncs-solana-signer.d.ts +1 -1
  178. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  179. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  180. package/dist/signers/non-custodial/ncs-stellar-signer.d.cts +1 -1
  181. package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +1 -1
  182. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  183. package/dist/signers/passkey.d.cts +1 -1
  184. package/dist/signers/passkey.d.ts +1 -1
  185. package/dist/signers/server/assemble-server-signer.d.cts +1 -1
  186. package/dist/signers/server/assemble-server-signer.d.ts +1 -1
  187. package/dist/signers/server/evm-server-signer.d.cts +1 -1
  188. package/dist/signers/server/evm-server-signer.d.ts +1 -1
  189. package/dist/signers/server/helpers/derive-server-signer.d.cts +1 -1
  190. package/dist/signers/server/helpers/derive-server-signer.d.ts +1 -1
  191. package/dist/signers/server/helpers/index.d.cts +1 -1
  192. package/dist/signers/server/helpers/index.d.ts +1 -1
  193. package/dist/signers/server/index.d.cts +1 -1
  194. package/dist/signers/server/index.d.ts +1 -1
  195. package/dist/signers/server/resolver.cjs +1 -1
  196. package/dist/signers/server/resolver.d.cts +1 -1
  197. package/dist/signers/server/resolver.d.ts +1 -1
  198. package/dist/signers/server/resolver.js +1 -1
  199. package/dist/signers/server/solana-server-signer.d.cts +1 -1
  200. package/dist/signers/server/solana-server-signer.d.ts +1 -1
  201. package/dist/signers/server/stellar-server-signer.d.cts +1 -1
  202. package/dist/signers/server/stellar-server-signer.d.ts +1 -1
  203. package/dist/signers/solana-api-key.d.cts +1 -1
  204. package/dist/signers/solana-api-key.d.ts +1 -1
  205. package/dist/signers/solana-external-wallet.d.cts +1 -1
  206. package/dist/signers/solana-external-wallet.d.ts +1 -1
  207. package/dist/signers/stellar-external-wallet.d.cts +1 -1
  208. package/dist/signers/stellar-external-wallet.d.ts +1 -1
  209. package/dist/signers/types.cjs +1 -1
  210. package/dist/signers/types.d.cts +1 -1
  211. package/dist/signers/types.d.ts +1 -1
  212. package/dist/signers/types.js +1 -1
  213. package/dist/{types-D6r1qRCA.d.cts → types-DUaBfLJv.d.cts} +11 -1
  214. package/dist/{types-VTpasnqi.d.ts → types-DnpNYkDF.d.ts} +11 -1
  215. package/dist/utils/constants.cjs +1 -1
  216. package/dist/utils/constants.js +1 -1
  217. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  218. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  219. package/dist/utils/device-signers/createDeviceSigner.d.cts +1 -1
  220. package/dist/utils/device-signers/createDeviceSigner.d.ts +1 -1
  221. package/dist/utils/device-signers/index.cjs +1 -1
  222. package/dist/utils/device-signers/index.d.cts +1 -1
  223. package/dist/utils/device-signers/index.d.ts +1 -1
  224. package/dist/utils/device-signers/index.js +1 -1
  225. package/dist/utils/locators.d.cts +1 -1
  226. package/dist/utils/locators.d.ts +1 -1
  227. package/dist/utils/signer-locator.cjs +1 -1
  228. package/dist/utils/signer-locator.d.cts +1 -1
  229. package/dist/utils/signer-locator.d.ts +1 -1
  230. package/dist/utils/signer-locator.js +1 -1
  231. package/dist/utils/signer-mapping.d.cts +1 -1
  232. package/dist/utils/signer-mapping.d.ts +1 -1
  233. package/dist/utils/signer-validation.cjs +1 -1
  234. package/dist/utils/signer-validation.d.cts +10 -1
  235. package/dist/utils/signer-validation.d.ts +10 -1
  236. package/dist/utils/signer-validation.js +1 -1
  237. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  238. package/dist/wallets/__tests__/test-helpers.d.cts +1 -1
  239. package/dist/wallets/__tests__/test-helpers.d.ts +1 -1
  240. package/dist/wallets/__tests__/test-helpers.js +1 -1
  241. package/dist/wallets/evm.cjs +1 -1
  242. package/dist/wallets/evm.d.cts +1 -1
  243. package/dist/wallets/evm.d.ts +1 -1
  244. package/dist/wallets/evm.js +1 -1
  245. package/dist/wallets/services/balance-formatter.cjs +1 -1
  246. package/dist/wallets/services/balance-formatter.d.cts +1 -1
  247. package/dist/wallets/services/balance-formatter.d.ts +1 -1
  248. package/dist/wallets/services/balance-formatter.js +1 -1
  249. package/dist/wallets/services/device-recovery-service.cjs +1 -1
  250. package/dist/wallets/services/device-recovery-service.d.cts +1 -1
  251. package/dist/wallets/services/device-recovery-service.d.ts +1 -1
  252. package/dist/wallets/services/device-recovery-service.js +1 -1
  253. package/dist/wallets/services/operation-poller.cjs +1 -1
  254. package/dist/wallets/services/operation-poller.d.cts +1 -1
  255. package/dist/wallets/services/operation-poller.d.ts +1 -1
  256. package/dist/wallets/services/operation-poller.js +1 -1
  257. package/dist/wallets/services/signer-manager.cjs +1 -1
  258. package/dist/wallets/services/signer-manager.d.cts +1 -1
  259. package/dist/wallets/services/signer-manager.d.ts +1 -1
  260. package/dist/wallets/services/signer-manager.js +1 -1
  261. package/dist/wallets/solana.cjs +1 -1
  262. package/dist/wallets/solana.d.cts +1 -1
  263. package/dist/wallets/solana.d.ts +1 -1
  264. package/dist/wallets/solana.js +1 -1
  265. package/dist/wallets/stellar.cjs +1 -1
  266. package/dist/wallets/stellar.d.cts +1 -1
  267. package/dist/wallets/stellar.d.ts +1 -1
  268. package/dist/wallets/stellar.js +1 -1
  269. package/dist/wallets/types.d.cts +1 -1
  270. package/dist/wallets/types.d.ts +1 -1
  271. package/dist/wallets/wallet-factory.cjs +1 -1
  272. package/dist/wallets/wallet-factory.d.cts +1 -1
  273. package/dist/wallets/wallet-factory.d.ts +1 -1
  274. package/dist/wallets/wallet-factory.js +1 -1
  275. package/dist/wallets/wallet.cjs +1 -1
  276. package/dist/wallets/wallet.d.cts +1 -1
  277. package/dist/wallets/wallet.d.ts +1 -1
  278. package/dist/wallets/wallet.js +1 -1
  279. package/package.json +4 -4
  280. package/dist/chunk-64JQSHXM.js +0 -1
  281. package/dist/chunk-EE6XMYUL.js +0 -1
  282. package/dist/chunk-GOXB2RBF.js +0 -1
  283. package/dist/chunk-HBHDN4G7.js +0 -1
  284. package/dist/chunk-HHVYXPUL.cjs +0 -1
  285. package/dist/chunk-IKHH67TL.cjs +0 -1
  286. package/dist/chunk-LV5QR6LK.js +0 -1
  287. package/dist/chunk-NX256LAH.cjs +0 -1
  288. package/dist/chunk-OWJS5ITO.cjs +0 -1
  289. package/dist/chunk-RWRESDZR.cjs +0 -1
  290. package/dist/chunk-TIRSLCAM.js +0 -1
  291. package/dist/chunk-TL2BD4MX.cjs +0 -1
  292. package/dist/chunk-WK2RGS25.cjs +0 -1
  293. package/dist/chunk-WPNLE54U.js +0 -1
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkATIC4ENGcjs = require('./chunk-ATIC4ENG.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=class{constructor(i){this.config=i;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let i=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:i.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkMYWEABPNcjs.a.info("TEE connection not initialized, initializing now");let i=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:i.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkMYWEABPNcjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;let i=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);_chunkMYWEABPNcjs.a.info("get-status: sending request");let t=Date.now(),e=yield i.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),n=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw _chunkMYWEABPNcjs.a.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:n}),new (0, _chunkQPCZFIUVcjs.c)(c,p)}if(_chunkMYWEABPNcjs.a.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:n}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkMYWEABPNcjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:o,reject:a}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:o,reject:a},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkMYWEABPNcjs.a.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new _chunkQPCZFIUVcjs.a)})),a(new _chunkQPCZFIUVcjs.a)}))}catch(c){_chunkMYWEABPNcjs.a.error("handleAuthRequired error",{error:c}),a(c)}try{yield s}catch(c){throw _chunkMYWEABPNcjs.a.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null)throw new Error("JWT is required");return i}createAuthPromise(){let i,t;return{promise:new Promise((n,s)=>{i=n,t=s}),resolve:i,reject:t}}sendMessageWithOtp(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o;let i=yield this.getTEEConnection(),t=this.getAuthId();_chunkMYWEABPNcjs.a.info("start-onboarding: sending request");let e=Date.now(),n=yield i.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(o=this.config.crossmint.jwt)!=null?o:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:l}),s=Date.now()-e;if(this._onboardingConnectionGeneration=i.connectionGeneration,_chunkMYWEABPNcjs.a.info("start-onboarding: response received",{status:n==null?void 0:n.status,durationMs:s}),(n==null?void 0:n.status)==="success"&&n.signerStatus==="ready"){this._needsAuth=!1;return}if((n==null?void 0:n.status)==="error")throw _chunkMYWEABPNcjs.a.error("start-onboarding: failed",{error:n.error,code:n.code}),new (0, _chunkQPCZFIUVcjs.b)(n.error||"Failed to initiate OTP process.",n.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var s,o;let t;try{let a=yield this.getTEEConnection();_chunkMYWEABPNcjs.a.info("complete-onboarding: sending request");let d=Date.now();t=yield a.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:i}}},options:l}),_chunkMYWEABPNcjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(a){return _chunkMYWEABPNcjs.a.error("complete-onboarding: error",{error:a}),yield this.handleOnboardingVerificationFailure(a)}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),a=>this.verifyOtp(a),()=>{var a;return(a=this._authPromise)==null?void 0:a.reject(new _chunkQPCZFIUVcjs.a)})),(o=this._authPromise)==null||o.resolve();return}_chunkMYWEABPNcjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",n=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new (0, _chunkQPCZFIUVcjs.b)(e,n))})}handleOnboardingVerificationFailure(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var n,s,o;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){_chunkMYWEABPNcjs.a.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(a){throw(n=this._authPromise)==null||n.reject(a),a}if(!this._needsAuth){(s=this._authPromise)==null||s.resolve();return}throw new _chunkQPCZFIUVcjs.e}throw(o=this._authPromise)==null||o.reject(i),i})}_exportPrivateKey(i,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:n,encoding:s}=this.getChainKeyParams();if(t!=null){let a=i.on("event:key-exported",d=>{i.off(a),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let o=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:s,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((o==null?void 0:o.status)==="error")throw _chunkMYWEABPNcjs.a.error("export-signer: failed",{error:o.error,code:o.code}),new (0, _chunkQPCZFIUVcjs.d)(o.error||"Failed to export private key",o.code)})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};exports.a = m; exports.b = l;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkIKHH67TLcjs = require('./chunk-IKHH67TL.cjs');var _chunk6GEBK257cjs = require('./chunk-6GEBK257.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunkIKHH67TLcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=_bs582.default.decode(n),y=_web3js.VersionedTransaction.deserialize(m).message.serialize();_chunk6GEBK257cjs.a.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(y)),encoding:"base58"}},options:_chunkIKHH67TLcjs.b});if(_chunk6GEBK257cjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkBZJ5TU7Hcjs = require('./chunk-BZJ5TU7H.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunkBZJ5TU7Hcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=_bs582.default.decode(n),y=_web3js.VersionedTransaction.deserialize(m).message.serialize();_chunkMYWEABPNcjs.a.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(y)),encoding:"base58"}},options:_chunkBZJ5TU7Hcjs.b});if(_chunkMYWEABPNcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;
@@ -1 +1 @@
1
- import{a as P}from"./chunk-NZXYWQE5.js";import{a as v}from"./chunk-IOSADDL5.js";import{n as w}from"./chunk-TGFHY5PL.js";import{a as l}from"./chunk-QOSA6B55.js";import{c as m,h as n}from"./chunk-NU7VF7MC.js";import{getEnvironmentForKey as K,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as b}from"ox";var R={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},E=6e4,L="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;if(typeof window!="undefined"&&!P())throw new w("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=K(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield b.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield b.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};m([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
1
+ import{a as P}from"./chunk-NZXYWQE5.js";import{a as v}from"./chunk-IOSADDL5.js";import{n as w}from"./chunk-TGFHY5PL.js";import{a as l}from"./chunk-OTFPEC53.js";import{c as m,h as n}from"./chunk-NU7VF7MC.js";import{getEnvironmentForKey as K,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as b}from"ox";var R={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},E=6e4,L="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;if(typeof window!="undefined"&&!P())throw new w("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=K(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield b.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield b.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};m([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-WPNLE54U.js";import{a as r}from"./chunk-QOSA6B55.js";import{h as t}from"./chunk-NU7VF7MC.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
1
+ import{a as s,b as o}from"./chunk-BBMFGUOH.js";import{a as r}from"./chunk-OTFPEC53.js";import{h as t}from"./chunk-NU7VF7MC.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var a={type:"api-key",validateConfig(){},buildInternalConfig(e,i){return{type:"api-key",locator:"api-key",address:i.walletAddress}},canAutoAssemble(){return!0},addSignerPayload(e){return _chunkNX256LAHcjs.a.call(void 0, e)},matchesRecovery(e,i){return _chunkNX256LAHcjs.a.call(void 0, e)===_chunkNX256LAHcjs.a.call(void 0, i)},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>null};exports.a = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkR7S55N7Jcjs = require('./chunk-R7S55N7J.cjs');var a={type:"api-key",validateConfig(){},buildInternalConfig(e,i){return{type:"api-key",locator:"api-key",address:i.walletAddress}},canAutoAssemble(){return!0},addSignerPayload(e){return _chunkR7S55N7Jcjs.a.call(void 0, e)},matchesRecovery(e,i){return _chunkR7S55N7Jcjs.a.call(void 0, e)===_chunkR7S55N7Jcjs.a.call(void 0, i)},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>null};exports.a = a;
@@ -1 +1 @@
1
- var t=class extends Error{constructor(){super("Authentication was rejected by the user"),this.name="AuthRejectedError"}},i=class extends Error{constructor(n,r){super(n),this.name="OtpValidationError",this.code=r}},o=class extends Error{constructor(n,r){super(n),this.name="SignerStatusError",this.code=r}},a=class extends Error{constructor(n,r){super(n),this.name="KeyExportError",this.code=r}};function l(e){return e.type==="server"&&!("secret"in e)}function p(e){return e._exportPrivateKey!==void 0}export{t as a,i as b,o as c,a as d,l as e,p as f};
1
+ var t=class extends Error{constructor(){super("Authentication was rejected by the user"),this.name="AuthRejectedError"}},i=class extends Error{constructor(n,r){super(n),this.name="OtpValidationError",this.code=r}},o=class extends Error{constructor(n,r){super(n),this.name="SignerStatusError",this.code=r}},a=class extends Error{constructor(n,r){super(n),this.name="KeyExportError",this.code=r}},s=class extends Error{constructor(n="The signer session expired before the code could be verified. A new code has been sent."){super(n),this.name="OnboardingSessionExpiredError"}};function p(e){return e.type==="server"&&!("secret"in e)}function S(e){return e._exportPrivateKey!==void 0}export{t as a,i as b,o as c,a as d,s as e,p as f,S as g};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFN64UU7Mcjs = require('./chunk-FN64UU7M.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunk6GEBK257cjs = require('./chunk-6GEBK257.cjs');var f={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw _chunk6GEBK257cjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw _chunk6GEBK257cjs.a.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new (0, _chunk3F4FMM3Rcjs.j)(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return _chunkFN64UU7Mcjs.c.call(void 0, e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};exports.a = f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFN64UU7Mcjs = require('./chunk-FN64UU7M.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var f={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw _chunkMYWEABPNcjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw _chunkMYWEABPNcjs.a.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new (0, _chunk3F4FMM3Rcjs.j)(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return _chunkFN64UU7Mcjs.c.call(void 0, e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};exports.a = f;
@@ -1 +1 @@
1
- import{a as i}from"./chunk-UAB6KH63.js";import{y as u}from"./chunk-TGFHY5PL.js";import{a as t}from"./chunk-QOSA6B55.js";import{a as f,c,h as s}from"./chunk-NU7VF7MC.js";import{isValidStellarAddress as T,WithLoggerContext as g}from"@crossmint/common-sdk-base";var m=409,l=class l extends i{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:i.getOptions(e),alias:e.alias,recovery:i.getRecovery(e),apiRecoveryServerSignerAddress:i.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:i.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:i.getInitialSigners(e)},i.getApiClient(e))}static from(e){if(!T(e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return s(this,null,function*(){var d;t.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return t.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return t.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return s(this,null,function*(){t.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return t.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),t.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else t.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return t.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return s(this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return s(this,null,function*(){t.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new u("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return t.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return t.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return s(this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new u(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return s(this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:f({transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new u(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};c([g({logger:t,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),c([g({logger:t,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),c([g({logger:t,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}export{h as a};
1
+ import{a as i}from"./chunk-M5A2GB2R.js";import{y as u}from"./chunk-TGFHY5PL.js";import{a as t}from"./chunk-OTFPEC53.js";import{a as f,c,h as s}from"./chunk-NU7VF7MC.js";import{isValidStellarAddress as T,WithLoggerContext as g}from"@crossmint/common-sdk-base";var m=409,l=class l extends i{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:i.getOptions(e),alias:e.alias,recovery:i.getRecovery(e),apiRecoveryServerSignerAddress:i.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:i.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:i.getInitialSigners(e)},i.getApiClient(e))}static from(e){if(!T(e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return s(this,null,function*(){var d;t.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return t.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return t.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return s(this,null,function*(){t.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return t.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),t.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else t.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return t.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return s(this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return s(this,null,function*(){t.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new u("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return t.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return t.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return s(this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new u(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return s(this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:f({transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new u(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};c([g({logger:t,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),c([g({logger:t,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),c([g({logger:t,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}export{h as a};
@@ -1 +1 @@
1
- import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{b as i,c as s}from"./chunk-TGFHY5PL.js";import{a as E}from"./chunk-QOSA6B55.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as R,arbitrum as N,arbitrumNova as p,modeTestnet as h,mode as d,mainnet as f,bsc as W,shape as U,zora as V,zoraSepolia as B,sepolia as y,flowMainnet as H,flowTestnet as v,plume as x,plumeTestnet as b}from"viem/chains";var w=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],D=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.ETHEREUM,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function ee(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return R;case e.ARBITRUM:return N;case e.ARBITRUMNOVA:return p;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return W;case e.SHAPE:return U;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return y;case e.ETHEREUM:return f;case e.FLOW:return H;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return b;case e.PLUME:return x;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return w.includes(t)}function C(t){return D.includes(t)}var Y={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.ETHEREUM]:e.ETHEREUM_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function g(t){return Y[t]}function F(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function te(t,a){if(!F(t))throw new s(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=g(r);if(n!=null)return E.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;E.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}export{ee as a,I as b,C as c,g as d,F as e,te as f};
1
+ import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{b as i,c as s}from"./chunk-TGFHY5PL.js";import{a as E}from"./chunk-OTFPEC53.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as R,arbitrum as N,arbitrumNova as p,modeTestnet as h,mode as d,mainnet as f,bsc as W,shape as U,zora as V,zoraSepolia as B,sepolia as y,flowMainnet as H,flowTestnet as v,plume as x,plumeTestnet as b}from"viem/chains";var w=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],D=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.ETHEREUM,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function ee(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return R;case e.ARBITRUM:return N;case e.ARBITRUMNOVA:return p;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return W;case e.SHAPE:return U;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return y;case e.ETHEREUM:return f;case e.FLOW:return H;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return b;case e.PLUME:return x;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return w.includes(t)}function C(t){return D.includes(t)}var Y={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.ETHEREUM]:e.ETHEREUM_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function g(t){return Y[t]}function F(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function te(t,a){if(!F(t))throw new s(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=g(r);if(n!=null)return E.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;E.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}export{ee as a,I as b,C as c,g as d,F as e,te as f};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIW4FVUP5cjs = require('./chunk-IW4FVUP5.cjs');var _chunkDBWMNPH7cjs = require('./chunk-DBWMNPH7.cjs');var _chunkNML6ZUFMcjs = require('./chunk-NML6ZUFM.cjs');var _chunkPH5XGZFFcjs = require('./chunk-PH5XGZFF.cjs');var _chunkMQE44PARcjs = require('./chunk-MQE44PAR.cjs');var _chunkUWX7ID4Xcjs = require('./chunk-UWX7ID4X.cjs');var _chunkXMN42YI5cjs = require('./chunk-XMN42YI5.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');function u(r){switch(r){case"email":return _chunkPH5XGZFFcjs.a;case"phone":return _chunkXMN42YI5cjs.a;case"passkey":return _chunkUWX7ID4Xcjs.a;case"device":return _chunkNML6ZUFMcjs.a;case"api-key":return _chunkDBWMNPH7cjs.a;case"server":return _chunkIW4FVUP5cjs.a;case"external-wallet":return _chunkMQE44PARcjs.b;default:throw new (0, _chunk3F4FMM3Rcjs.k)(`Unknown signer type: ${r}`)}}exports.a = u;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSNAWZWNRcjs = require('./chunk-SNAWZWNR.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunk6GEBK257cjs = require('./chunk-6GEBK257.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=409,l=class l extends _chunkSNAWZWNRcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkSNAWZWNRcjs.a.getOptions(e),alias:e.alias,recovery:_chunkSNAWZWNRcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkSNAWZWNRcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkSNAWZWNRcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkSNAWZWNRcjs.a.getInitialSigners(e)},_chunkSNAWZWNRcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidStellarAddress.call(void 0, e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;_chunk6GEBK257cjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunk6GEBK257cjs.a.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return _chunk6GEBK257cjs.a.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunk6GEBK257cjs.a.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return _chunk6GEBK257cjs.a.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),_chunk6GEBK257cjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else _chunk6GEBK257cjs.a.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return _chunk6GEBK257cjs.a.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunk6GEBK257cjs.a.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new (0, _chunk3F4FMM3Rcjs.y)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunk6GEBK257cjs.a.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return _chunk6GEBK257cjs.a.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:_chunkDSIFRRBScjs.a.call(void 0, {transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6GEBK257cjs.a,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6GEBK257cjs.a,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6GEBK257cjs.a,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOI6QI264cjs = require('./chunk-OI6QI264.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=409,l=class l extends _chunkOI6QI264cjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkOI6QI264cjs.a.getOptions(e),alias:e.alias,recovery:_chunkOI6QI264cjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkOI6QI264cjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkOI6QI264cjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkOI6QI264cjs.a.getInitialSigners(e)},_chunkOI6QI264cjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidStellarAddress.call(void 0, e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;_chunkMYWEABPNcjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunkMYWEABPNcjs.a.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return _chunkMYWEABPNcjs.a.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkMYWEABPNcjs.a.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return _chunkMYWEABPNcjs.a.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),_chunkMYWEABPNcjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else _chunkMYWEABPNcjs.a.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return _chunkMYWEABPNcjs.a.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkMYWEABPNcjs.a.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new (0, _chunk3F4FMM3Rcjs.y)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunkMYWEABPNcjs.a.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return _chunkMYWEABPNcjs.a.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:_chunkDSIFRRBScjs.a.call(void 0, {transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}exports.a = h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkSNAWZWNRcjs = require('./chunk-SNAWZWNR.cjs');var _chunkNFDWJLL6cjs = require('./chunk-NFDWJLL6.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunk6GEBK257cjs = require('./chunk-6GEBK257.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkSNAWZWNRcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkSNAWZWNRcjs.a.getOptions(e),alias:e.alias,recovery:_chunkSNAWZWNRcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkSNAWZWNRcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkSNAWZWNRcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkSNAWZWNRcjs.a.getInitialSigners(e)},_chunkSNAWZWNRcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunk6GEBK257cjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=this.buildTransaction(e),r=yield this.createTransaction(t,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunk6GEBK257cjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return _chunk6GEBK257cjs.a.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunk6GEBK257cjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),r=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:t.locator(),chain:this.chain}});if("error"in r)throw _chunk6GEBK257cjs.a.error("evmWallet.signMessage.error",{error:r}),new (0, _chunk3F4FMM3Rcjs.t)(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return _chunk6GEBK257cjs.a.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return _chunk6GEBK257cjs.a.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var C;_chunk6GEBK257cjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),{domain:r,message:a,primaryType:i,types:g,chain:T}=e;if(!r||!a||!g||!T)throw _chunk6GEBK257cjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunk3F4FMM3Rcjs.p)("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw _chunk6GEBK257cjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunk3F4FMM3Rcjs.p)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:v,chainId:Number(S),verifyingContract:I,salt:b},message:y(a),primaryType:i,types:g},signer:t.locator(),chain:T}});if("error"in d)throw _chunk6GEBK257cjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunk3F4FMM3Rcjs.t)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunk6GEBK257cjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return _chunk6GEBK257cjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return _viem.createPublicClient.call(void 0, {transport:(t=e==null?void 0:e.transport)!=null?t:_viem.http.call(void 0, ),chain:_chunkNFDWJLL6cjs.a.call(void 0, this.chain)})}createTransaction(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r;(t==null?void 0:t.signer)==null?r=this.signerManager.require().locator():typeof t.signer=="string"?r=t.signer:r=this.resolveServerSignerApiLocator(t.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:r,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(a));return a})}buildTransaction(e){var t,r,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(r=(t=e.value)==null?void 0:t.toString())!=null?r:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6GEBK257cjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6GEBK257cjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6GEBK257cjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var M=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,y(t)])):s}exports.a = M;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOI6QI264cjs = require('./chunk-OI6QI264.cjs');var _chunkBJZM3EV2cjs = require('./chunk-BJZM3EV2.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkOI6QI264cjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkOI6QI264cjs.a.getOptions(e),alias:e.alias,recovery:_chunkOI6QI264cjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkOI6QI264cjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkOI6QI264cjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkOI6QI264cjs.a.getInitialSigners(e)},_chunkOI6QI264cjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkMYWEABPNcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=this.buildTransaction(e),r=yield this.createTransaction(t,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkMYWEABPNcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return _chunkMYWEABPNcjs.a.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkMYWEABPNcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),r=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:t.locator(),chain:this.chain}});if("error"in r)throw _chunkMYWEABPNcjs.a.error("evmWallet.signMessage.error",{error:r}),new (0, _chunk3F4FMM3Rcjs.t)(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return _chunkMYWEABPNcjs.a.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return _chunkMYWEABPNcjs.a.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var C;_chunkMYWEABPNcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),{domain:r,message:a,primaryType:i,types:g,chain:T}=e;if(!r||!a||!g||!T)throw _chunkMYWEABPNcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunk3F4FMM3Rcjs.p)("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw _chunkMYWEABPNcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunk3F4FMM3Rcjs.p)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:v,chainId:Number(S),verifyingContract:I,salt:b},message:y(a),primaryType:i,types:g},signer:t.locator(),chain:T}});if("error"in d)throw _chunkMYWEABPNcjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunk3F4FMM3Rcjs.t)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkMYWEABPNcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return _chunkMYWEABPNcjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return _viem.createPublicClient.call(void 0, {transport:(t=e==null?void 0:e.transport)!=null?t:_viem.http.call(void 0, ),chain:_chunkBJZM3EV2cjs.a.call(void 0, this.chain)})}createTransaction(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r;(t==null?void 0:t.signer)==null?r=this.signerManager.require().locator():typeof t.signer=="string"?r=t.signer:r=this.resolveServerSignerApiLocator(t.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:r,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunk3F4FMM3Rcjs.y)(JSON.stringify(a));return a})}buildTransaction(e){var t,r,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(r=(t=e.value)==null?void 0:t.toString())!=null?r:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var M=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,y(t)])):s}exports.a = M;
@@ -0,0 +1 @@
1
+ var s="@crossmint/wallets-sdk",t="1.7.0";var c="WALLETS_SDK",r=t,a=s,d=500;export{c as a,r as b,a as c,d};
@@ -1 +1 @@
1
- import{a as m}from"./chunk-YWZMLT47.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=m(n).balanceTokenFields(t);return u({symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=m(n).emptyBalanceTokenFields();return u(u({},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=C(t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function g(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}export{g as a};
1
+ import{a as m}from"./chunk-3PDACUM7.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=m(n).balanceTokenFields(t);return u({symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=m(n).emptyBalanceTokenFields();return u(u({},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=C(t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function g(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}export{g as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkU7MO5CYPcjs = require('./chunk-U7MO5CYP.cjs');var _chunkSNAWZWNRcjs = require('./chunk-SNAWZWNR.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunkQ66YRLSWcjs = require('./chunk-Q66YRLSW.cjs');var _chunkNFDWJLL6cjs = require('./chunk-NFDWJLL6.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunk6GEBK257cjs = require('./chunk-6GEBK257.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var $="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",u= exports.a =class{constructor(r){this.apiClient=r}getWallet(r,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i,t;if(typeof r=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunk3F4FMM3Rcjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunk3F4FMM3Rcjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");i=r,t=e}else{if(this.apiClient.isServerSide)throw new (0, _chunk3F4FMM3Rcjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");t=r,i=this.getWalletLocator(t)}let a=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{chain:_chunkNFDWJLL6cjs.f.call(void 0, t.chain,this.apiClient.environment)});_chunk6GEBK257cjs.a.info("walletFactory.getWallet.start");let n=yield this.apiClient.getWallet(i);if("error"in n)throw _chunk6GEBK257cjs.a.warn("walletFactory.getWallet.notFound",{error:n.error}),new (0, _chunk3F4FMM3Rcjs.e)(JSON.stringify(n));return _chunk6GEBK257cjs.a.info("walletFactory.getWallet.success",{address:n.address}),yield this.createWalletInstance(n,a)})}createWallet(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o,c,d,h,C,p,F,P;let e=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},r),{chain:_chunkNFDWJLL6cjs.f.call(void 0, r.chain,this.apiClient.environment)});if(yield(d=(c=(o=e.options)==null?void 0:o.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:d.call(c),_chunk6GEBK257cjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunk6GEBK257cjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunk3F4FMM3Rcjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let t=((h=e.options)==null?void 0:h.deviceSignerKeyStorage)!=null&&e.chain!=="solana"?this.ensureDeviceSignerInSigners(e):(C=e.signers)!=null?C:[],a=yield this.registerSigners(t,e.chain,(p=e.options)==null?void 0:p.deviceSignerKeyStorage),n;if(e.recovery.type==="passkey"&&e.recovery.id==null)n=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:I}=_chunkQ66YRLSWcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);n={type:"server",address:I}}else n=e.recovery;let s=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {adminSigner:n},e.plugins?{plugins:e.plugins}:{}),a!=null?{delegatedSigners:a}:{}),owner:(F=e.owner)!=null?F:void 0,alias:(P=e.alias)!=null?P:void 0});if("error"in s)throw _chunk6GEBK257cjs.a.error("walletFactory.createWallet.error",{error:s.error}),new (0, _chunk3F4FMM3Rcjs.g)(JSON.stringify(s));return _chunk6GEBK257cjs.a.info("walletFactory.createWallet.success",{address:s.address}),yield this.createWalletInstance(s,e)})}createWalletInstance(r,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h,C;this.validateExistingWalletConfig(r,e);let i=e,t=r.config.adminSigner,a=((h=i.recovery)==null?void 0:h.type)==="server"||((C=i.recovery)==null?void 0:C.type)==="external-wallet"?i.recovery:t,n=r.config.delegatedSigners,s=n;s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet")&&(s=i.signers);let o=t.type==="server"&&"address"in t&&!("secret"in t)?t.address:void 0,c=(n!=null?n:[]).filter(p=>p.type==="server"&&"address"in p&&!("secret"in p)).map(p=>p.address),d=new (0, _chunkSNAWZWNRcjs.a)({chain:e.chain,address:r.address,owner:r.owner,options:e.options,alias:e.alias,recovery:a,apiRecoveryServerSignerAddress:o,apiDelegatedServerSignerAddresses:c,signers:s!=null?s:[]},this.apiClient);return yield d.waitForInit(),d})}getWalletLocator(r){return`me:${this.getChainType(r.chain)}:smart`+(r.alias!=null?`:alias:${r.alias}`:"")}createPasskeySigner(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var t;if(r.type!=="passkey")throw new Error("Signer is not a passkey");let e=(t=r.name)!=null?t:`Crossmint Wallet ${Date.now()}`,i=r.onCreatePasskey?yield r.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:i.id,name:e,publicKey:{x:i.publicKey.x.toString(),y:i.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(r){var t;let e=(t=r.signers)!=null?t:[];return e.some(a=>a.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(r,e){if(e.owner!=null&&r.owner!=null&&_chunkU7MO5CYPcjs.a.call(void 0, e.owner)!==_chunkU7MO5CYPcjs.a.call(void 0, r.owner))throw new (0, _chunk3F4FMM3Rcjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&r.chainType!=="solana"||e.chain!=="solana"&&r.chainType==="solana"||e.chain==="stellar"&&r.chainType!=="stellar"||e.chain!=="stellar"&&r.chainType==="stellar")throw new (0, _chunk3F4FMM3Rcjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${r.chainType}.`);if(r.type!=="smart")return;let i=e;if(i.recovery!=null||i.signers!=null){let t=r.config,a=t==null?void 0:t.adminSigner;if(i.recovery!=null&&a!=null){if(i.recovery.type!==a.type)throw new (0, _chunk3F4FMM3Rcjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkU7MO5CYPcjs.b.call(void 0, i.recovery,a)}let n=i.signers;n!=null&&this.validateSigners(r,n,e.chain)}}validateSigners(r,e,i){let t=r.config,a=t==null?void 0:t.delegatedSigners;if(e.length!==0){if(a==null||a.length===0)throw new (0, _chunk3F4FMM3Rcjs.g)(`${e.length} signer(s) specified, but wallet "${r.address}" has no signers. ${$}`);for(let n of e){let s=a.find(o=>{if(this.isMatchingPasskeySigner(n,o,t)||o.type==="device"&&n.type==="device")return!0;if(n.type==="server"){let{primary:c,legacy:d}=_chunkQ66YRLSWcjs.c.call(void 0, n,i,this.apiClient.projectId,this.apiClient.environment);return o.locator===`server:${c.derivedAddress}`||d!=null&&o.locator===`server:${d.derivedAddress}`}return o.locator===_chunkNX256LAHcjs.a.call(void 0, n)});if(s==null){let o=a.map(c=>c.locator).join(", ");throw new (0, _chunk3F4FMM3Rcjs.g)(`Signer '${n.type}' does not exist in wallet "${r.address}". Available signers: ${o}. ${$}`)}_chunkU7MO5CYPcjs.b.call(void 0, n,s)}}}isMatchingPasskeySigner(r,e,i){var a,n;let t=((n=(a=i.delegatedSigners)==null?void 0:a.filter(s=>s.type==="passkey").length)!=null?n:0)+(i.adminSigner.type==="passkey"?1:0);if(r.type==="passkey"){if(r.id==null&&t===1)return e.type==="passkey";if(r.id==null&&t>1)throw new (0, _chunk3F4FMM3Rcjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(r,e,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var t;return yield Promise.all((t=r==null?void 0:r.map(a=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(a.type==="passkey")return a.id==null?{signer:yield this.createPasskeySigner(a)}:{signer:a};if(a.type==="device"){if(a.publicKey!=null)return{signer:{type:"device",publicKey:a.publicKey,name:a.name}};if(a.locator!=null)return{signer:a.locator};if(i==null)throw new (0, _chunk3F4FMM3Rcjs.g)("Device signer key storage is required for device signers");let n=yield _chunkGMU3ZYLScjs.a.call(void 0, i);return{signer:{type:"device",publicKey:n.publicKey,name:n.name}}}if(a.type==="server"&&e!=null){let{derivedAddress:n}=_chunkQ66YRLSWcjs.b.call(void 0, a,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${n}`}}return{signer:_chunkNX256LAHcjs.a.call(void 0, a)}})))!=null?t:[])})}getChainType(r){return r==="solana"?"solana":r==="stellar"?"stellar":"evm"}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6GEBK257cjs.a,methodName:"walletFactory.getWallet",buildContext(r,e){if(typeof e[0]=="string"){let t=e[1];return{walletLocator:e[0],chain:t==null?void 0:t.chain}}let i=e[0];return{chain:i==null?void 0:i.chain}}})],u.prototype,"getWallet",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6GEBK257cjs.a,methodName:"walletFactory.createWallet",buildContext(r,e){return{chain:e[0].chain}}})],u.prototype,"createWallet",1);exports.a = u;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOI6QI264cjs = require('./chunk-OI6QI264.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkR7S55N7Jcjs = require('./chunk-R7S55N7J.cjs');var _chunkSEXK7X55cjs = require('./chunk-SEXK7X55.cjs');var _chunkQ66YRLSWcjs = require('./chunk-Q66YRLSW.cjs');var _chunkBJZM3EV2cjs = require('./chunk-BJZM3EV2.cjs');var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var $="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",u= exports.a =class{constructor(r){this.apiClient=r}getWallet(r,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i,t;if(typeof r=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunk3F4FMM3Rcjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunk3F4FMM3Rcjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");i=r,t=e}else{if(this.apiClient.isServerSide)throw new (0, _chunk3F4FMM3Rcjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");t=r,i=this.getWalletLocator(t)}let a=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{chain:_chunkBJZM3EV2cjs.f.call(void 0, t.chain,this.apiClient.environment)});_chunkMYWEABPNcjs.a.info("walletFactory.getWallet.start");let n=yield this.apiClient.getWallet(i);if("error"in n)throw _chunkMYWEABPNcjs.a.warn("walletFactory.getWallet.notFound",{error:n.error}),new (0, _chunk3F4FMM3Rcjs.e)(JSON.stringify(n));return _chunkMYWEABPNcjs.a.info("walletFactory.getWallet.success",{address:n.address}),yield this.createWalletInstance(n,a)})}createWallet(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o,c,d,h,C,p,F,P;let e=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},r),{chain:_chunkBJZM3EV2cjs.f.call(void 0, r.chain,this.apiClient.environment)});if(yield(d=(c=(o=e.options)==null?void 0:o.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:d.call(c),_chunkMYWEABPNcjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunkMYWEABPNcjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunk3F4FMM3Rcjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let t=((h=e.options)==null?void 0:h.deviceSignerKeyStorage)!=null&&e.chain!=="solana"?this.ensureDeviceSignerInSigners(e):(C=e.signers)!=null?C:[],a=yield this.registerSigners(t,e.chain,(p=e.options)==null?void 0:p.deviceSignerKeyStorage),n;if(e.recovery.type==="passkey"&&e.recovery.id==null)n=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:I}=_chunkQ66YRLSWcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);n={type:"server",address:I}}else n=e.recovery;let s=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {adminSigner:n},e.plugins?{plugins:e.plugins}:{}),a!=null?{delegatedSigners:a}:{}),owner:(F=e.owner)!=null?F:void 0,alias:(P=e.alias)!=null?P:void 0});if("error"in s)throw _chunkMYWEABPNcjs.a.error("walletFactory.createWallet.error",{error:s.error}),new (0, _chunk3F4FMM3Rcjs.g)(JSON.stringify(s));return _chunkMYWEABPNcjs.a.info("walletFactory.createWallet.success",{address:s.address}),yield this.createWalletInstance(s,e)})}createWalletInstance(r,e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h,C;this.validateExistingWalletConfig(r,e);let i=e,t=r.config.adminSigner,a=((h=i.recovery)==null?void 0:h.type)==="server"||((C=i.recovery)==null?void 0:C.type)==="external-wallet"?i.recovery:t,n=r.config.delegatedSigners,s=n;s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet")&&(s=i.signers);let o=t.type==="server"&&"address"in t&&!("secret"in t)?t.address:void 0,c=(n!=null?n:[]).filter(p=>p.type==="server"&&"address"in p&&!("secret"in p)).map(p=>p.address),d=new (0, _chunkOI6QI264cjs.a)({chain:e.chain,address:r.address,owner:r.owner,options:e.options,alias:e.alias,recovery:a,apiRecoveryServerSignerAddress:o,apiDelegatedServerSignerAddresses:c,signers:s!=null?s:[]},this.apiClient);return yield d.waitForInit(),d})}getWalletLocator(r){return`me:${this.getChainType(r.chain)}:smart`+(r.alias!=null?`:alias:${r.alias}`:"")}createPasskeySigner(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var t;if(r.type!=="passkey")throw new Error("Signer is not a passkey");let e=(t=r.name)!=null?t:`Crossmint Wallet ${Date.now()}`,i=r.onCreatePasskey?yield r.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:i.id,name:e,publicKey:{x:i.publicKey.x.toString(),y:i.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(r){var t;let e=(t=r.signers)!=null?t:[];return e.some(a=>a.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(r,e){if(e.owner!=null&&r.owner!=null&&_chunkSEXK7X55cjs.b.call(void 0, e.owner)!==_chunkSEXK7X55cjs.b.call(void 0, r.owner))throw new (0, _chunk3F4FMM3Rcjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&r.chainType!=="solana"||e.chain!=="solana"&&r.chainType==="solana"||e.chain==="stellar"&&r.chainType!=="stellar"||e.chain!=="stellar"&&r.chainType==="stellar")throw new (0, _chunk3F4FMM3Rcjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${r.chainType}.`);if(r.type!=="smart")return;let i=e;if(i.recovery!=null||i.signers!=null){let t=r.config,a=t==null?void 0:t.adminSigner;if(i.recovery!=null&&a!=null){if(i.recovery.type!==a.type)throw new (0, _chunk3F4FMM3Rcjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkSEXK7X55cjs.c.call(void 0, i.recovery,a)}let n=i.signers;n!=null&&this.validateSigners(r,n,e.chain)}}validateSigners(r,e,i){let t=r.config,a=t==null?void 0:t.delegatedSigners;if(e.length!==0){if(a==null||a.length===0)throw new (0, _chunk3F4FMM3Rcjs.g)(`${e.length} signer(s) specified, but wallet "${r.address}" has no signers. ${$}`);for(let n of e){let s=a.find(o=>{if(this.isMatchingPasskeySigner(n,o,t)||o.type==="device"&&n.type==="device")return!0;if(n.type==="server"){let{primary:c,legacy:d}=_chunkQ66YRLSWcjs.c.call(void 0, n,i,this.apiClient.projectId,this.apiClient.environment);return o.locator===`server:${c.derivedAddress}`||d!=null&&o.locator===`server:${d.derivedAddress}`}return o.locator===_chunkR7S55N7Jcjs.a.call(void 0, n)});if(s==null){let o=a.map(c=>c.locator).join(", ");throw new (0, _chunk3F4FMM3Rcjs.g)(`Signer '${n.type}' does not exist in wallet "${r.address}". Available signers: ${o}. ${$}`)}_chunkSEXK7X55cjs.c.call(void 0, n,s)}}}isMatchingPasskeySigner(r,e,i){var a,n;let t=((n=(a=i.delegatedSigners)==null?void 0:a.filter(s=>s.type==="passkey").length)!=null?n:0)+(i.adminSigner.type==="passkey"?1:0);if(r.type==="passkey"){if(r.id==null&&t===1)return e.type==="passkey";if(r.id==null&&t>1)throw new (0, _chunk3F4FMM3Rcjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(r,e,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var t;return yield Promise.all((t=r==null?void 0:r.map(a=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(a.type==="passkey")return a.id==null?{signer:yield this.createPasskeySigner(a)}:{signer:a};if(a.type==="device"){if(a.publicKey!=null)return{signer:{type:"device",publicKey:a.publicKey,name:a.name}};if(a.locator!=null)return{signer:a.locator};if(i==null)throw new (0, _chunk3F4FMM3Rcjs.g)("Device signer key storage is required for device signers");let n=yield _chunkGMU3ZYLScjs.a.call(void 0, i);return{signer:{type:"device",publicKey:n.publicKey,name:n.name}}}if(a.type==="server"&&e!=null){let{derivedAddress:n}=_chunkQ66YRLSWcjs.b.call(void 0, a,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${n}`}}return{signer:_chunkR7S55N7Jcjs.a.call(void 0, a)}})))!=null?t:[])})}getChainType(r){return r==="solana"?"solana":r==="stellar"?"stellar":"evm"}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"walletFactory.getWallet",buildContext(r,e){if(typeof e[0]=="string"){let t=e[1];return{walletLocator:e[0],chain:t==null?void 0:t.chain}}let i=e[0];return{chain:i==null?void 0:i.chain}}})],u.prototype,"getWallet",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkMYWEABPNcjs.a,methodName:"walletFactory.createWallet",buildContext(r,e){return{chain:e[0].chain}}})],u.prototype,"createWallet",1);exports.a = u;
@@ -0,0 +1 @@
1
+ import{a as r}from"./chunk-M4U7HAZ6.js";function o(e){return e.type==="external-wallet"?`external-wallet:${e.address}`:e.type==="email"&&e.email?`email:${r(e.email)}`:e.type==="phone"&&e.phone?`phone:${e.phone}`:e.type==="passkey"&&"id"in e?`passkey:${e.id}`:e.type==="api-key"?"api-key":e.type==="device"?"locator"in e&&e.locator!=null?e.locator:"device:":e.type}function p(e){let t=e.indexOf(":");return t===-1?{type:e,value:""}:{type:e.substring(0,t),value:e.substring(t+1)}}export{o as a,p as b};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCHDHMS5Rcjs = require('./chunk-CHDHMS5R.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunk66XVKHJQcjs = require('./chunk-66XVKHJQ.cjs');var _chunk6GEBK257cjs = require('./chunk-6GEBK257.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunk6GEBK257cjs.b.call(void 0, e.apiKey);let t=new (0, _chunk66XVKHJQcjs.a)(e);this.walletFactory=new (0, _chunkCHDHMS5Rcjs.a)(t),_chunk6GEBK257cjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkGMU3ZYLScjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGIXJ5P3Dcjs = require('./chunk-GIXJ5P3D.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkMYLHEIBDcjs = require('./chunk-MYLHEIBD.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkMYWEABPNcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkMYLHEIBDcjs.a)(e);this.walletFactory=new (0, _chunkGIXJ5P3Dcjs.a)(t),_chunkMYWEABPNcjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkGMU3ZYLScjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.6.1";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =500;exports.a = p; exports.b = c; exports.c = r; exports.d = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.7.0";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =500;exports.a = p; exports.b = c; exports.c = r; exports.d = a;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkIKHH67TLcjs = require('./chunk-IKHH67TL.cjs');var _chunk6GEBK257cjs = require('./chunk-6GEBK257.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a=class g extends _chunkIKHH67TLcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunk6GEBK257cjs.a.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:_chunkIKHH67TLcjs.b});if(_chunk6GEBK257cjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkBZJ5TU7Hcjs = require('./chunk-BZJ5TU7H.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a=class g extends _chunkBZJ5TU7Hcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkMYWEABPNcjs.a.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:_chunkBZJ5TU7Hcjs.b});if(_chunkMYWEABPNcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
@@ -1 +1 @@
1
- import{c as g}from"./chunk-IUMKG7QD.js";import{j as s}from"./chunk-TGFHY5PL.js";import{a as i}from"./chunk-QOSA6B55.js";var h={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw i.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw i.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new s(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return g(e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};export{h as a};
1
+ import{c as g}from"./chunk-IUMKG7QD.js";import{j as s}from"./chunk-TGFHY5PL.js";import{a as i}from"./chunk-OTFPEC53.js";var h={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw i.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw i.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new s(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return g(e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};export{h as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQ66YRLSWcjs = require('./chunk-Q66YRLSW.cjs');var _chunk5HBCBS5Wcjs = require('./chunk-5HBCBS5W.cjs');var _chunkLWA3SX6Zcjs = require('./chunk-LWA3SX6Z.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var y,c,A,u,f,C,g,t,o,k,w,a,K= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,o);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,c);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,f);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,g,null);_chunkDSIFRRBScjs.e.call(void 0, this,t,null);_chunkDSIFRRBScjs.f.call(void 0, this,y,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,c,r.projectId),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.environment),_chunkDSIFRRBScjs.f.call(void 0, this,u,r.apiRecoveryAddress),_chunkDSIFRRBScjs.f.call(void 0, this,f,r.apiDelegatedAddresses),_chunkDSIFRRBScjs.f.call(void 0, this,C,r.knownOnChainAddresses)}deriveCandidates(r){return _chunkQ66YRLSWcjs.c.call(void 0, r,_chunkDSIFRRBScjs.d.call(void 0, this,y),_chunkDSIFRRBScjs.d.call(void 0, this,c),_chunkDSIFRRBScjs.d.call(void 0, this,A))}resolveDerivation(r){var l;if(_chunk5HBCBS5Wcjs.e.call(void 0, r)){if(_chunkDSIFRRBScjs.d.call(void 0, this,t)!=null)return _chunkDSIFRRBScjs.d.call(void 0, this,t);throw new Error('Cannot resolve server signer derivation: no secret available and no cached recovery resolution. Call wallet.useSigner({ type: "server", secret: ... }) first.')}let{primary:e,legacy:i}=this.deriveCandidates(r),s=(l=_chunkDSIFRRBScjs.d.call(void 0, this,g))!=null?l:_chunkDSIFRRBScjs.d.call(void 0, this,t);if(s!=null){let p=s.derivedAddress;if(p===e.derivedAddress||i!=null&&p===i.derivedAddress)return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),s}if(i!=null){if(i.derivedAddress===_chunkDSIFRRBScjs.d.call(void 0, this,u))return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),i;if(_chunkDSIFRRBScjs.d.call(void 0, this,C).call(this).includes(i.derivedAddress))return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),i;_chunkLWA3SX6Zcjs.a.call(void 0, i.derivedKeyBytes)}return e}apiLocator(r){let e=this.resolveDerivation(r);return e!==_chunkDSIFRRBScjs.d.call(void 0, this,g)&&e!==_chunkDSIFRRBScjs.d.call(void 0, this,t)&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),`server:${e.derivedAddress}`}resolveForUseSigner(r,e,i){let{primary:s,legacy:l}=this.deriveCandidates(r);if(_chunkDSIFRRBScjs.g.call(void 0, this,o,k).call(this,s,l,e)!=null)return{kind:"delegated"};if(i())return _chunkDSIFRRBScjs.g.call(void 0, this,o,w).call(this,s,l),{kind:"recovery"};let p=l!=null?`"server:${s.derivedAddress}" or "server:${l.derivedAddress}"`:`"server:${s.derivedAddress}"`;return _chunkLWA3SX6Zcjs.a.call(void 0, s.derivedKeyBytes,l==null?void 0:l.derivedKeyBytes),{kind:"unregistered",message:`Signer ${p} is not registered in this wallet.`}}keyMaterialForAssembly(r){let e=this.resolveDerivation(r),i=new Uint8Array(e.derivedKeyBytes);return e!==_chunkDSIFRRBScjs.d.call(void 0, this,g)&&e!==_chunkDSIFRRBScjs.d.call(void 0, this,t)&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),{derivedKeyBytes:i,derivedAddress:e.derivedAddress}}candidateAddresses(r){if(_chunk5HBCBS5Wcjs.e.call(void 0, r))return[r.address];let{primary:e,legacy:i}=this.deriveCandidates(r),s=[e.derivedAddress];return i!=null&&s.push(i.derivedAddress),_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),s}resetDelegatedCache(){var r;_chunkLWA3SX6Zcjs.a.call(void 0, (r=_chunkDSIFRRBScjs.d.call(void 0, this,g))==null?void 0:r.derivedKeyBytes),_chunkDSIFRRBScjs.f.call(void 0, this,g,null)}get hasRecoveryResolution(){return _chunkDSIFRRBScjs.d.call(void 0, this,t)!=null}get resolvedRecoveryAddress(){var r,e;return(e=(r=_chunkDSIFRRBScjs.d.call(void 0, this,t))==null?void 0:r.derivedAddress)!=null?e:null}get apiRecoveryAddress(){return _chunkDSIFRRBScjs.d.call(void 0, this,u)}get apiDelegatedAddresses(){return _chunkDSIFRRBScjs.d.call(void 0, this,f)}};y=new WeakMap,c=new WeakMap,A=new WeakMap,u=new WeakMap,f=new WeakMap,C=new WeakMap,g=new WeakMap,t=new WeakMap,o=new WeakSet,k=function(r,e,i){return i.includes(`server:${r.derivedAddress}`)?(_chunkDSIFRRBScjs.f.call(void 0, this,g,r),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,r,e),r):e!=null&&i.includes(`server:${e.derivedAddress}`)?(_chunkDSIFRRBScjs.f.call(void 0, this,g,e),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,e,r),e):null},w=function(r,e){return _chunkDSIFRRBScjs.d.call(void 0, this,u)!=null&&e!=null&&e.derivedAddress===_chunkDSIFRRBScjs.d.call(void 0, this,u)?(_chunkDSIFRRBScjs.f.call(void 0, this,t,e),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,e,r),e):(_chunkDSIFRRBScjs.f.call(void 0, this,t,r),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,r,e),r)},a=function(r,e){e!=null&&e!==r&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes)};exports.a = K;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQ66YRLSWcjs = require('./chunk-Q66YRLSW.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkLWA3SX6Zcjs = require('./chunk-LWA3SX6Z.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var y,c,A,u,f,C,g,t,o,k,w,a,K= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,o);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,c);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,f);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,g,null);_chunkDSIFRRBScjs.e.call(void 0, this,t,null);_chunkDSIFRRBScjs.f.call(void 0, this,y,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,c,r.projectId),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.environment),_chunkDSIFRRBScjs.f.call(void 0, this,u,r.apiRecoveryAddress),_chunkDSIFRRBScjs.f.call(void 0, this,f,r.apiDelegatedAddresses),_chunkDSIFRRBScjs.f.call(void 0, this,C,r.knownOnChainAddresses)}deriveCandidates(r){return _chunkQ66YRLSWcjs.c.call(void 0, r,_chunkDSIFRRBScjs.d.call(void 0, this,y),_chunkDSIFRRBScjs.d.call(void 0, this,c),_chunkDSIFRRBScjs.d.call(void 0, this,A))}resolveDerivation(r){var l;if(_chunkQPCZFIUVcjs.f.call(void 0, r)){if(_chunkDSIFRRBScjs.d.call(void 0, this,t)!=null)return _chunkDSIFRRBScjs.d.call(void 0, this,t);throw new Error('Cannot resolve server signer derivation: no secret available and no cached recovery resolution. Call wallet.useSigner({ type: "server", secret: ... }) first.')}let{primary:e,legacy:i}=this.deriveCandidates(r),s=(l=_chunkDSIFRRBScjs.d.call(void 0, this,g))!=null?l:_chunkDSIFRRBScjs.d.call(void 0, this,t);if(s!=null){let p=s.derivedAddress;if(p===e.derivedAddress||i!=null&&p===i.derivedAddress)return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),s}if(i!=null){if(i.derivedAddress===_chunkDSIFRRBScjs.d.call(void 0, this,u))return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),i;if(_chunkDSIFRRBScjs.d.call(void 0, this,C).call(this).includes(i.derivedAddress))return _chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),i;_chunkLWA3SX6Zcjs.a.call(void 0, i.derivedKeyBytes)}return e}apiLocator(r){let e=this.resolveDerivation(r);return e!==_chunkDSIFRRBScjs.d.call(void 0, this,g)&&e!==_chunkDSIFRRBScjs.d.call(void 0, this,t)&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),`server:${e.derivedAddress}`}resolveForUseSigner(r,e,i){let{primary:s,legacy:l}=this.deriveCandidates(r);if(_chunkDSIFRRBScjs.g.call(void 0, this,o,k).call(this,s,l,e)!=null)return{kind:"delegated"};if(i())return _chunkDSIFRRBScjs.g.call(void 0, this,o,w).call(this,s,l),{kind:"recovery"};let p=l!=null?`"server:${s.derivedAddress}" or "server:${l.derivedAddress}"`:`"server:${s.derivedAddress}"`;return _chunkLWA3SX6Zcjs.a.call(void 0, s.derivedKeyBytes,l==null?void 0:l.derivedKeyBytes),{kind:"unregistered",message:`Signer ${p} is not registered in this wallet.`}}keyMaterialForAssembly(r){let e=this.resolveDerivation(r),i=new Uint8Array(e.derivedKeyBytes);return e!==_chunkDSIFRRBScjs.d.call(void 0, this,g)&&e!==_chunkDSIFRRBScjs.d.call(void 0, this,t)&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes),{derivedKeyBytes:i,derivedAddress:e.derivedAddress}}candidateAddresses(r){if(_chunkQPCZFIUVcjs.f.call(void 0, r))return[r.address];let{primary:e,legacy:i}=this.deriveCandidates(r),s=[e.derivedAddress];return i!=null&&s.push(i.derivedAddress),_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),s}resetDelegatedCache(){var r;_chunkLWA3SX6Zcjs.a.call(void 0, (r=_chunkDSIFRRBScjs.d.call(void 0, this,g))==null?void 0:r.derivedKeyBytes),_chunkDSIFRRBScjs.f.call(void 0, this,g,null)}get hasRecoveryResolution(){return _chunkDSIFRRBScjs.d.call(void 0, this,t)!=null}get resolvedRecoveryAddress(){var r,e;return(e=(r=_chunkDSIFRRBScjs.d.call(void 0, this,t))==null?void 0:r.derivedAddress)!=null?e:null}get apiRecoveryAddress(){return _chunkDSIFRRBScjs.d.call(void 0, this,u)}get apiDelegatedAddresses(){return _chunkDSIFRRBScjs.d.call(void 0, this,f)}};y=new WeakMap,c=new WeakMap,A=new WeakMap,u=new WeakMap,f=new WeakMap,C=new WeakMap,g=new WeakMap,t=new WeakMap,o=new WeakSet,k=function(r,e,i){return i.includes(`server:${r.derivedAddress}`)?(_chunkDSIFRRBScjs.f.call(void 0, this,g,r),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,r,e),r):e!=null&&i.includes(`server:${e.derivedAddress}`)?(_chunkDSIFRRBScjs.f.call(void 0, this,g,e),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,e,r),e):null},w=function(r,e){return _chunkDSIFRRBScjs.d.call(void 0, this,u)!=null&&e!=null&&e.derivedAddress===_chunkDSIFRRBScjs.d.call(void 0, this,u)?(_chunkDSIFRRBScjs.f.call(void 0, this,t,e),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,e,r),e):(_chunkDSIFRRBScjs.f.call(void 0, this,t,r),_chunkDSIFRRBScjs.g.call(void 0, this,o,a).call(this,r,e),r)},a=function(r,e){e!=null&&e!==r&&_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes)};exports.a = K;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5HBCBS5Wcjs = require('./chunk-5HBCBS5W.cjs');var g=`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
2
- Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`,C= exports.a ={type:"server",validateConfig(){},buildInternalConfig(e,r){let{derivedKeyBytes:n,derivedAddress:i}=r.serverSigners.keyMaterialForAssembly(e);return{type:"server",derivedKeyBytes:n,locator:`server:${i}`,address:i}},canAutoAssemble(e,r){return!_chunk5HBCBS5Wcjs.e.call(void 0, e)||r.serverSigners.hasRecoveryResolution},addSignerPayload(e,r){return r.serverSigners.apiLocator(e)},matchesRecovery(e,r,n){let i=n.serverSigners.candidateAddresses(e),s=n.serverSigners.candidateAddresses(r);return i.some(t=>s.includes(t))},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>g};exports.a = C;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var g=`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
2
+ Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`,C= exports.a ={type:"server",validateConfig(){},buildInternalConfig(e,r){let{derivedKeyBytes:n,derivedAddress:i}=r.serverSigners.keyMaterialForAssembly(e);return{type:"server",derivedKeyBytes:n,locator:`server:${i}`,address:i}},canAutoAssemble(e,r){return!_chunkQPCZFIUVcjs.f.call(void 0, e)||r.serverSigners.hasRecoveryResolution},addSignerPayload(e,r){return r.serverSigners.apiLocator(e)},matchesRecovery(e,r,n){let i=n.serverSigners.candidateAddresses(e),s=n.serverSigners.candidateAddresses(r);return i.some(t=>s.includes(t))},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>g};exports.a = C;
@@ -1 +1 @@
1
- import{a as i}from"./chunk-GOXB2RBF.js";var g={type:"device",validateConfig(e){},buildInternalConfig(e,r){return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:r.walletAddress}},canAutoAssemble(e,r){return r.deviceSignerKeyStorage!=null},addSignerPayload(e){return"publicKey"in e&&e.publicKey!=null?{type:"device",publicKey:e.publicKey,name:e.name}:i(e)},matchesRecovery(){return!1},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>null};export{g as a};
1
+ import{a as i}from"./chunk-GNON524X.js";var g={type:"device",validateConfig(e){},buildInternalConfig(e,r){return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:r.walletAddress}},canAutoAssemble(e,r){return r.deviceSignerKeyStorage!=null},addSignerPayload(e){return"publicKey"in e&&e.publicKey!=null?{type:"device",publicKey:e.publicKey,name:e.name}:i(e)},matchesRecovery(){return!1},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>null};export{g as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkRWRESDZRcjs = require('./chunk-RWRESDZR.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=_chunkRWRESDZRcjs.a.call(void 0, n).balanceTokenFields(t);return _chunkDSIFRRBScjs.a.call(void 0, {symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=_chunkRWRESDZRcjs.a.call(void 0, n).emptyBalanceTokenFields();return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=_chunkENU3EKBGcjs.a.call(void 0, t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function T(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}exports.a = T;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6CNBIQGFcjs = require('./chunk-6CNBIQGF.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=_chunk6CNBIQGFcjs.a.call(void 0, n).balanceTokenFields(t);return _chunkDSIFRRBScjs.a.call(void 0, {symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=_chunk6CNBIQGFcjs.a.call(void 0, n).emptyBalanceTokenFields();return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=_chunkENU3EKBGcjs.a.call(void 0, t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function T(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}exports.a = T;
@@ -1 +1 @@
1
- import{a,b as g}from"./chunk-WPNLE54U.js";import{a as s}from"./chunk-QOSA6B55.js";import{h as t}from"./chunk-NU7VF7MC.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
1
+ import{a,b as g}from"./chunk-BBMFGUOH.js";import{a as s}from"./chunk-OTFPEC53.js";import{h as t}from"./chunk-NU7VF7MC.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunk6GEBK257cjs = require('./chunk-6GEBK257.cjs');var _chunk2WS6SXS6cjs = require('./chunk-2WS6SXS6.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function N(i,a,e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var w,p;let{timeoutMs:s=6e4,backoffMultiplier:u=1.1,maxBackoffMs:n=2e3}=r!=null?r:{},{initialBackoffMs:o=_chunk2WS6SXS6cjs.d}=r!=null?r:{};_chunk6GEBK257cjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:s});let M=Date.now(),t;do{if(Date.now()-M>s)throw new (0, _chunk3F4FMM3Rcjs.A)("Transaction confirmation timeout");if(t=yield i.getTransaction(a,e),t.error)throw new (0, _chunk3F4FMM3Rcjs.z)(JSON.stringify(t));yield E(o),o=Math.min(o*u,n)}while(t.status==="pending");if(t.status==="failed")throw new (0, _chunk3F4FMM3Rcjs.B)(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new (0, _chunk3F4FMM3Rcjs.C)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let A="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(w=t.onChain.txId)!=null?w:A;if(g==null)throw new (0, _chunk3F4FMM3Rcjs.D)("Transaction hash not found on transaction response");return{hash:g,explorerLink:(p=t.onChain.explorerLink)!=null?p:"",transactionId:t.id}})}function O(i,a,e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{timeoutMs:s=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>s)throw new (0, _chunk3F4FMM3Rcjs.w)("Signature confirmation timeout");if(yield new Promise(o=>setTimeout(o,_chunk2WS6SXS6cjs.d)),n=yield i.getSignature(a,e),"error"in n)throw new (0, _chunk3F4FMM3Rcjs.u)(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new (0, _chunk3F4FMM3Rcjs.r)("Signature signing failed");if(!n.outputSignature)throw new (0, _chunk3F4FMM3Rcjs.u)("Signature not available");return{signature:n.outputSignature,signatureId:e}})}function E(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(a=>setTimeout(a,i))})}exports.a = N; exports.b = O;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3F4FMM3Rcjs = require('./chunk-3F4FMM3R.cjs');var _chunkMYWEABPNcjs = require('./chunk-MYWEABPN.cjs');var _chunkHIKDNSEIcjs = require('./chunk-HIKDNSEI.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function N(i,a,e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var w,p;let{timeoutMs:s=6e4,backoffMultiplier:u=1.1,maxBackoffMs:n=2e3}=r!=null?r:{},{initialBackoffMs:o=_chunkHIKDNSEIcjs.d}=r!=null?r:{};_chunkMYWEABPNcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:s});let M=Date.now(),t;do{if(Date.now()-M>s)throw new (0, _chunk3F4FMM3Rcjs.A)("Transaction confirmation timeout");if(t=yield i.getTransaction(a,e),t.error)throw new (0, _chunk3F4FMM3Rcjs.z)(JSON.stringify(t));yield E(o),o=Math.min(o*u,n)}while(t.status==="pending");if(t.status==="failed")throw new (0, _chunk3F4FMM3Rcjs.B)(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new (0, _chunk3F4FMM3Rcjs.C)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let A="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(w=t.onChain.txId)!=null?w:A;if(g==null)throw new (0, _chunk3F4FMM3Rcjs.D)("Transaction hash not found on transaction response");return{hash:g,explorerLink:(p=t.onChain.explorerLink)!=null?p:"",transactionId:t.id}})}function O(i,a,e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{timeoutMs:s=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>s)throw new (0, _chunk3F4FMM3Rcjs.w)("Signature confirmation timeout");if(yield new Promise(o=>setTimeout(o,_chunkHIKDNSEIcjs.d)),n=yield i.getSignature(a,e),"error"in n)throw new (0, _chunk3F4FMM3Rcjs.u)(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new (0, _chunk3F4FMM3Rcjs.r)("Signature signing failed");if(!n.outputSignature)throw new (0, _chunk3F4FMM3Rcjs.u)("Signature not available");return{signature:n.outputSignature,signatureId:e}})}function E(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(a=>setTimeout(a,i))})}exports.a = N; exports.b = O;
@@ -1 +1 @@
1
- import{g as a}from"./chunk-TGFHY5PL.js";import{isEmailValid as c}from"@crossmint/common-sdk-auth";var m=(n,t,o)=>`Wallet signer configuration mismatch at "${n}" - expected "${o}" from existing wallet but found "${t}"`;function u(n){let o=n.toLowerCase().split("@"),r=o[1],i=r==="googlemail.com",e=(i||r==="gmail.com")&&o[0].includes(".");return i&&(o[1]="gmail.com"),e&&(o[0]=o[0].replace(/\./g,"")),`${o[0]}@${o[1]}`}function f(n){return/^0x[0-9a-fA-F]+$/.test(n)?BigInt(n).toString():n}function l(n,t=""){if(typeof n=="string"){if(c(n))return u(n);if(t.endsWith(".x")||t.endsWith(".y"))return f(n)}return n}function d(n,t,o=""){if(n!==t){if(n==null||t==null)throw new Error(`Cannot compare null or undefined signer configs at path: ${o}`);for(let r of Object.keys(n)){if(!(r in t))continue;let i=o?`${o}.${r}`:r,s=n[r],e=t[r];if(typeof s=="object"&&s!==null&&typeof e=="object"&&e!==null)d(s,e,i);else if(l(s,i)!==l(e,i))throw new a(m(i,s,e))}}}export{l as a,d as b};
1
+ import{g as a}from"./chunk-TGFHY5PL.js";import{isEmailValid as c}from"@crossmint/common-sdk-auth";var m=(n,t,o)=>`Wallet signer configuration mismatch at "${n}" - expected "${o}" from existing wallet but found "${t}"`;function u(n){let o=n.toLowerCase().split("@"),r=o[1],i=r==="googlemail.com",e=(i||r==="gmail.com")&&o[0].includes(".");return i&&(o[1]="gmail.com"),e&&(o[0]=o[0].replace(/\./g,"")),`${o[0]}@${o[1]}`}function f(n){return/^0x[0-9a-fA-F]+$/.test(n)?BigInt(n).toString():n}function l(n,t=""){if(typeof n=="string"){if(c(n))return u(n);if(t.endsWith(".x")||t.endsWith(".y"))return f(n)}return n}function d(n,t,o=""){if(n!==t){if(n==null||t==null)throw new Error(`Cannot compare null or undefined signer configs at path: ${o}`);for(let r of Object.keys(n)){if(!(r in t))continue;let i=o?`${o}.${r}`:r,s=n[r],e=t[r];if(typeof s=="object"&&s!==null&&typeof e=="object"&&e!==null)d(s,e,i);else if(l(s,i)!==l(e,i))throw new a(m(i,s,e))}}}export{u as a,l as b,d as c};
@@ -1 +1 @@
1
- import{a as ae}from"./chunk-ULAIS6HM.js";import{a as se,b as oe}from"./chunk-S7XUH7XP.js";import{a as ne}from"./chunk-TIRSLCAM.js";import{a as ie}from"./chunk-LJKNUBZA.js";import{a as ee}from"./chunk-WK67OXB3.js";import{a as F}from"./chunk-64JQSHXM.js";import{a as k}from"./chunk-GOXB2RBF.js";import{a as re,b as te}from"./chunk-XKMIK6EW.js";import{a as Z}from"./chunk-WPNLE54U.js";import{e as $}from"./chunk-OWDSSX2P.js";import{a as X,b as Y}from"./chunk-YWZMLT47.js";import{b as Q}from"./chunk-IUMKG7QD.js";import{f as K}from"./chunk-KSW27XVT.js";import{E as z,d as J,e as _,j as O,l as G,m as U,u as B,v as H,x as j,y as q,z as V}from"./chunk-TGFHY5PL.js";import{a}from"./chunk-QOSA6B55.js";import{d as M}from"./chunk-LV5QR6LK.js";import{a as y,b as N,c as R,d as i,e as b,f as m,h as o}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as W}from"@crossmint/common-sdk-base";var L,c,T,P,l,S,x,I,E,A=class{constructor(e,r){b(this,L);b(this,c);b(this,T);b(this,P);b(this,l);b(this,S);b(this,x,[]);b(this,I);b(this,E,null);let{chain:t,address:n,owner:s,options:h,alias:g,recovery:d,apiRecoveryServerSignerAddress:v,apiDelegatedServerSignerAddresses:p,signers:C,signer:f}=e;m(this,c,r),this.chain=t,this.address=n,this.owner=s,m(this,L,h),this.alias=g;let w=null;v!=null?w=v:d.type==="server"&&$(d)&&(w=d.address),m(this,x,p!=null?p:[]),m(this,T,C!=null?C:[]),m(this,P,new ee({chain:t,projectId:i(this,c).projectId,environment:i(this,c).environment,apiRecoveryAddress:w,apiDelegatedAddresses:i(this,x),knownOnChainAddresses:()=>[...i(this,T).filter(u=>u.type==="server"&&$(u)).map(u=>u.address),...i(this,x)]})),m(this,l,new ne({apiClient:r,options:h,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:i(this,P),recovery:d,initialSigners:i(this,T),signers:()=>this.signers(),signer:f})),m(this,S,new ae({chain:t,walletAddress:this.address,options:h,signerManager:i(this,l),serverSignerResolver:i(this,P),signers:()=>this.signers(),addSigner:u=>this.addSigner(u),approveSignature:u=>this.approveSignatureAndWait(u),approveTransaction:u=>this.approveTransactionAndWait(u)})),m(this,I,this.initDefaultSigner())}get signer(){return i(this,l).activeSigner}waitForInit(){return o(this,null,function*(){yield i(this,I)})}initDefaultSigner(){return o(this,null,function*(){if(i(this,l).activeSigner!=null||(yield i(this,S).initDeviceSigner(),i(this,l).activeSigner!=null||i(this,S).needsRecovery))return;let e=i(this,T).length===0?i(this,l).recovery:i(this,T).length===1?i(this,T)[0]:null;if(e==null)return;let r=F(e.type),t=i(this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===i(this,l).recovery;try{let s=r.buildInternalConfig(e,t);i(this,l).setActiveSigner(yield i(this,l).assemble(s,{isAdminSigner:n}))}catch(s){a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,l).recovery.type,signerCount:i(this,T).length,error:s})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return i(e,l).recovery}static getInitialSigners(e){return i(e,T)}static getApiRecoveryServerSignerAddress(e){var r;return(r=i(e,P).apiRecoveryAddress)!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return i(e,x)}get apiClient(){return i(this,c)}get options(){return i(this,L)}get chainAdapter(){return X(this.chain)}resolveServerSignerApiLocator(e){return i(this,P).apiLocator(e)}get recovery(){return i(this,l).recovery}balances(e){return o(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],s=yield i(this,c).getBalance(this.address,{chains:[r],tokens:n});if("error"in s)throw a.error("wallet.balances.error",{error:s}),new Error(`Failed to get balances for wallet: ${JSON.stringify(s.message)}`);return a.info("wallet.balances.success"),ie(s,this.chain,t,e)})}stagingFund(e,r){return o(this,null,function*(){a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return a.info("wallet.stagingFund.success"),t})}nfts(e){return o(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield i(this,c).getNfts(N(y({},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return o(this,null,function*(){let e=yield i(this,c).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return o(this,null,function*(){let r=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return o(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return o(this,null,function*(){let s=Number(t);if(Number.isNaN(s)||!Number.isFinite(s)||s<=0)throw new j(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let h=re(e),g=this.resolveChainForEnvironment(),d=te(r,g);a.info("wallet.send.start",y({recipient:h,token:d,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let v=i(this,l).require(),p;(n==null?void 0:n.signer)==null?p=v.locator():typeof n.signer=="string"?p=n.signer:p=this.resolveServerSignerApiLocator(n.signer);let C=y({recipient:h,amount:t,signer:p},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),f=yield i(this,c).send(this.walletLocator,d,C);if("message"in f)throw a.error("wallet.send.error",{error:f}),new q(`Failed to send token: ${JSON.stringify(f.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:f.id}),{hash:void 0,explorerLink:void 0,transactionId:f.id};let w=yield this.approveTransactionAndWait(f.id);return a.info("wallet.send.success",{transactionId:f.id,hash:w.hash}),w})}approveTransaction(e){return o(this,null,function*(){return console.warn("approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."),yield this.approve(e)})}approve(e){return o(this,null,function*(){if(a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return o(this,null,function*(){a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,l).withRecoverySigner(()=>o(this,null,function*(){let n=typeof t=="string"?t:k(t),s=yield i(this,l).getSignerState(n);if(s.signer!=null){if(i(this,l).isApprovedSignerStatus(s.signer.status))return(r==null?void 0:r.scopes)!=null&&a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:n}),a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(s.signer,null,r);if(s.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return a.info("wallet.addSigner.resuming",{operationType:s.pendingOperation.type,operationId:s.pendingOperation.id}),this.completeSignerRegistration(s.signer,s.pendingOperation,r)}}let h=typeof t=="string"?t:F(t.type).addSignerPayload(t,i(this,l).descriptorContext()),g=yield i(this,c).registerSigner(this.walletLocator,y({signer:h,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}));if("error"in g)throw a.error("wallet.addSigner.error",{error:g}),g.code===G?new U(g.message):new O(`Failed to register signer: ${JSON.stringify(g.message)}`);let d=Q(g,this.chain);if(d==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let v=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:n,type:e.type});return this.completeSignerRegistration(d,v,r)}))})}completeSignerRegistration(e,r,t){return o(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return y({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return a.info("wallet.addSigner.prepared",n),y(y({},e),n)}case"signature":{let n={signatureId:r.id};return a.info("wallet.addSigner.prepared",n),y(y({},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else a.info("wallet.addSigner.success");return N(y({},e),{status:"success"})})}removeSigner(e,r){return o(this,null,function*(){let t=this.resolveSignerLocator(e);return a.info("wallet.removeSigner.start",{signerLocator:t}),i(this,l).withRecoverySigner(()=>o(this,null,function*(){let n=yield i(this,c).removeSigner(this.walletLocator,t,{chain:this.chainAdapter.addSignerChain(this.chain)});if("error"in n)throw a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let s=n.id;return r!=null&&r.prepareOnly?(a.info("wallet.removeSigner.prepared",{transactionId:s}),{transactionId:s,status:void 0}):(yield this.approveTransactionAndWait(s),a.info("wallet.removeSigner.success",{transactionId:s}),{transactionId:s,status:"success"})}))})}useSigner(e){return o(this,null,function*(){a.info("wallet.useSigner.start"),e.type==="server"&&i(this,P).resetDelegatedCache(),F(e.type).validateConfig(e);let r=!1;e.type==="device"?yield i(this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=F(e.type).buildInternalConfig(e,i(this,l).descriptorContext()),n=k(e);i(this,l).setActiveSigner(yield i(this,l).assemble(t,{isAdminSigner:r})),a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return o(this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return i(this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return o(this,null,function*(){let t=(yield this.signers()).map(s=>s.locator),n=i(this,P).resolveForUseSigner(e,t,()=>this.isRecoverySigner(e));switch(n.kind){case"delegated":return i(this,S).onSignerSelected(),!1;case"recovery":return i(this,l).stripSecretFromRecovery(),i(this,S).onSignerSelected(),!0;case"unregistered":throw new Error(n.message)}})}tryAutoSelectPasskey(e){return o(this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):k(e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return o(this,null,function*(){return i(this,l).signerIsRegistered(e)})}isSignerApproved(e){return o(this,null,function*(){return i(this,l).isSignerApproved(e)})}needsRecovery(){return i(this,S).needsRecovery}recover(){return o(this,null,function*(){yield i(this,S).recover()})}signers(){return o(this,null,function*(){var s,h;a.info("wallet.signers.start");let e=yield i(this,c).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new _(JSON.stringify(e));if(!pe(e)){let g=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw a.error("wallet.signers.error",{error:g}),new J(g)}let r=(h=(s=e==null?void 0:e.config)==null?void 0:s.delegatedSigners)!=null?h:[],n=(yield Promise.all(r.map(g=>o(this,null,function*(){try{return(yield i(this,l).getSignerState(g.locator)).signer}catch(d){return null}})))).filter(g=>g!=null);return a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,c).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return i(this,l)}preAuthIfNeeded(){return o(this,null,function*(){yield i(this,I),i(this,E)==null&&m(this,E,this.recover());try{yield i(this,E)}finally{m(this,E,null)}let e=i(this,l).require();e instanceof Z&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=i(this,l).recovery;if(r==null||r.type!==e.type)return!1;let t=F(e.type);return t.matchesRecovery(e,r,i(this,l).descriptorContext())?(t.adoptsRecoveryConfigOnMatch&&i(this,l).adoptRecoveryConfig(e),!0):!1}resolveChainForEnvironment(){let e=K(this.chain,i(this,c).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return o(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return o(this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return o(this,null,function*(){var d,v;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=i(this,l).require(),n=yield i(this,c).getSignature(this.walletLocator,e);if("error"in n)throw new B(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let p=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,p)}let s=(d=n.approvals)==null?void 0:d.pending;if(s==null||s.length===0)return n;let h=[...(v=r==null?void 0:r.additionalSigners)!=null?v:[],t],g=yield Promise.all(s.map(p=>o(this,null,function*(){let C=h.find(w=>w.locator()===p.signer.locator);if(C==null)throw new O(`Signer ${p.signer.locator} not found in pending approvals`);let f=yield C.signMessage(p.message);return N(y({},f),{signer:C.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return o(this,null,function*(){var d,v,p,C,f;let t=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in t)throw new V(JSON.stringify(t));yield(p=(v=(d=i(this,L))==null?void 0:d.callbacks)==null?void 0:v.onTransactionStart)==null?void 0:p.call(v);let n=i(this,l).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let w=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,w)}let s=(C=t.approvals)==null?void 0:C.pending;if(s==null||s.length===0)return t;let h=[...(f=r==null?void 0:r.additionalSigners)!=null?f:[],n],g=yield Promise.all(s.map(w=>o(this,null,function*(){let u=h.find(de=>de.locator()===w.signer.locator);if(u==null)throw new O(`Signer ${w.signer.locator} not found in pending approvals`);let le=u.type==="device",ce=t.chainType==="solana"&&"transaction"in t.onChain&&!le?t.onChain.transaction:w.message,ge=yield u.signTransaction(ce);return N(y({},ge),{signer:u.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return o(this,null,function*(){a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,c).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new z(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return o(this,null,function*(){let t=yield i(this,c).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new H(JSON.stringify(t));return t})}waitForSignature(e){return o(this,null,function*(){return yield oe(i(this,c),this.walletLocator,e)})}waitForTransaction(h){return o(this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:n=2e3,initialBackoffMs:s=M}={}){return yield se(i(this,c),this.walletLocator,e,{timeoutMs:r,backoffMultiplier:t,maxBackoffMs:n,initialBackoffMs:s})})}sleep(e){return o(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};L=new WeakMap,c=new WeakMap,T=new WeakMap,P=new WeakMap,l=new WeakMap,S=new WeakMap,x=new WeakMap,I=new WeakMap,E=new WeakMap,R([W({logger:a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),R([W({logger:a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),R([W({logger:a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),R([W({logger:a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),R([W({logger:a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),R([W({logger:a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"removeSigner",1),R([W({logger:a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),R([W({logger:a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),R([W({logger:a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function pe(D){return D.type==="smart"&&Y(D.chainType)}export{A as a};
1
+ import{a as ie}from"./chunk-GCIDUJF2.js";import{a as ae}from"./chunk-N6LXJTAC.js";import{a as se,b as oe}from"./chunk-T6VDXOWC.js";import{a as ne}from"./chunk-ZUG5BIGQ.js";import{a as ee}from"./chunk-OMTJMVSG.js";import{a as F}from"./chunk-NFX2WUB6.js";import{a as k}from"./chunk-GNON524X.js";import{a as re,b as te}from"./chunk-XKMIK6EW.js";import{a as Z}from"./chunk-BBMFGUOH.js";import{f as $}from"./chunk-DCKFFFPG.js";import{a as X,b as Y}from"./chunk-3PDACUM7.js";import{b as Q}from"./chunk-IUMKG7QD.js";import{f as K}from"./chunk-EJCR7VKJ.js";import{E as z,d as J,e as _,j as O,l as G,m as U,u as B,v as H,x as j,y as q,z as V}from"./chunk-TGFHY5PL.js";import{a}from"./chunk-OTFPEC53.js";import{d as M}from"./chunk-FXMXIAPL.js";import{a as y,b as N,c as R,d as i,e as b,f as m,h as o}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as W}from"@crossmint/common-sdk-base";var L,c,T,P,l,S,x,I,E,A=class{constructor(e,r){b(this,L);b(this,c);b(this,T);b(this,P);b(this,l);b(this,S);b(this,x,[]);b(this,I);b(this,E,null);let{chain:t,address:n,owner:s,options:h,alias:g,recovery:d,apiRecoveryServerSignerAddress:v,apiDelegatedServerSignerAddresses:p,signers:C,signer:f}=e;m(this,c,r),this.chain=t,this.address=n,this.owner=s,m(this,L,h),this.alias=g;let w=null;v!=null?w=v:d.type==="server"&&$(d)&&(w=d.address),m(this,x,p!=null?p:[]),m(this,T,C!=null?C:[]),m(this,P,new ee({chain:t,projectId:i(this,c).projectId,environment:i(this,c).environment,apiRecoveryAddress:w,apiDelegatedAddresses:i(this,x),knownOnChainAddresses:()=>[...i(this,T).filter(u=>u.type==="server"&&$(u)).map(u=>u.address),...i(this,x)]})),m(this,l,new ne({apiClient:r,options:h,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:i(this,P),recovery:d,initialSigners:i(this,T),signers:()=>this.signers(),signer:f})),m(this,S,new ae({chain:t,walletAddress:this.address,options:h,signerManager:i(this,l),serverSignerResolver:i(this,P),signers:()=>this.signers(),addSigner:u=>this.addSigner(u),approveSignature:u=>this.approveSignatureAndWait(u),approveTransaction:u=>this.approveTransactionAndWait(u)})),m(this,I,this.initDefaultSigner())}get signer(){return i(this,l).activeSigner}waitForInit(){return o(this,null,function*(){yield i(this,I)})}initDefaultSigner(){return o(this,null,function*(){if(i(this,l).activeSigner!=null||(yield i(this,S).initDeviceSigner(),i(this,l).activeSigner!=null||i(this,S).needsRecovery))return;let e=i(this,T).length===0?i(this,l).recovery:i(this,T).length===1?i(this,T)[0]:null;if(e==null)return;let r=F(e.type),t=i(this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===i(this,l).recovery;try{let s=r.buildInternalConfig(e,t);i(this,l).setActiveSigner(yield i(this,l).assemble(s,{isAdminSigner:n}))}catch(s){a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,l).recovery.type,signerCount:i(this,T).length,error:s})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return i(e,l).recovery}static getInitialSigners(e){return i(e,T)}static getApiRecoveryServerSignerAddress(e){var r;return(r=i(e,P).apiRecoveryAddress)!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return i(e,x)}get apiClient(){return i(this,c)}get options(){return i(this,L)}get chainAdapter(){return X(this.chain)}resolveServerSignerApiLocator(e){return i(this,P).apiLocator(e)}get recovery(){return i(this,l).recovery}balances(e){return o(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],s=yield i(this,c).getBalance(this.address,{chains:[r],tokens:n});if("error"in s)throw a.error("wallet.balances.error",{error:s}),new Error(`Failed to get balances for wallet: ${JSON.stringify(s.message)}`);return a.info("wallet.balances.success"),ie(s,this.chain,t,e)})}stagingFund(e,r){return o(this,null,function*(){a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return a.info("wallet.stagingFund.success"),t})}nfts(e){return o(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield i(this,c).getNfts(N(y({},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return o(this,null,function*(){let e=yield i(this,c).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return o(this,null,function*(){let r=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return o(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return o(this,null,function*(){let s=Number(t);if(Number.isNaN(s)||!Number.isFinite(s)||s<=0)throw new j(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let h=re(e),g=this.resolveChainForEnvironment(),d=te(r,g);a.info("wallet.send.start",y({recipient:h,token:d,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let v=i(this,l).require(),p;(n==null?void 0:n.signer)==null?p=v.locator():typeof n.signer=="string"?p=n.signer:p=this.resolveServerSignerApiLocator(n.signer);let C=y({recipient:h,amount:t,signer:p},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),f=yield i(this,c).send(this.walletLocator,d,C);if("message"in f)throw a.error("wallet.send.error",{error:f}),new q(`Failed to send token: ${JSON.stringify(f.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:f.id}),{hash:void 0,explorerLink:void 0,transactionId:f.id};let w=yield this.approveTransactionAndWait(f.id);return a.info("wallet.send.success",{transactionId:f.id,hash:w.hash}),w})}approveTransaction(e){return o(this,null,function*(){return console.warn("approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."),yield this.approve(e)})}approve(e){return o(this,null,function*(){if(a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return o(this,null,function*(){a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,l).withRecoverySigner(()=>o(this,null,function*(){let n=typeof t=="string"?t:k(t),s=yield i(this,l).getSignerState(n);if(s.signer!=null){if(i(this,l).isApprovedSignerStatus(s.signer.status))return(r==null?void 0:r.scopes)!=null&&a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:n}),a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(s.signer,null,r);if(s.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return a.info("wallet.addSigner.resuming",{operationType:s.pendingOperation.type,operationId:s.pendingOperation.id}),this.completeSignerRegistration(s.signer,s.pendingOperation,r)}}let h=typeof t=="string"?t:F(t.type).addSignerPayload(t,i(this,l).descriptorContext()),g=yield i(this,c).registerSigner(this.walletLocator,y({signer:h,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}));if("error"in g)throw a.error("wallet.addSigner.error",{error:g}),g.code===G?new U(g.message):new O(`Failed to register signer: ${JSON.stringify(g.message)}`);let d=Q(g,this.chain);if(d==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let v=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:n,type:e.type});return this.completeSignerRegistration(d,v,r)}))})}completeSignerRegistration(e,r,t){return o(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return y({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return a.info("wallet.addSigner.prepared",n),y(y({},e),n)}case"signature":{let n={signatureId:r.id};return a.info("wallet.addSigner.prepared",n),y(y({},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else a.info("wallet.addSigner.success");return N(y({},e),{status:"success"})})}removeSigner(e,r){return o(this,null,function*(){let t=this.resolveSignerLocator(e);return a.info("wallet.removeSigner.start",{signerLocator:t}),i(this,l).withRecoverySigner(()=>o(this,null,function*(){let n=yield i(this,c).removeSigner(this.walletLocator,t,{chain:this.chainAdapter.addSignerChain(this.chain)});if("error"in n)throw a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let s=n.id;return r!=null&&r.prepareOnly?(a.info("wallet.removeSigner.prepared",{transactionId:s}),{transactionId:s,status:void 0}):(yield this.approveTransactionAndWait(s),a.info("wallet.removeSigner.success",{transactionId:s}),{transactionId:s,status:"success"})}))})}useSigner(e){return o(this,null,function*(){a.info("wallet.useSigner.start"),e.type==="server"&&i(this,P).resetDelegatedCache(),F(e.type).validateConfig(e);let r=!1;e.type==="device"?yield i(this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=F(e.type).buildInternalConfig(e,i(this,l).descriptorContext()),n=k(e);i(this,l).setActiveSigner(yield i(this,l).assemble(t,{isAdminSigner:r})),a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return o(this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return i(this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return i(this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return o(this,null,function*(){let t=(yield this.signers()).map(s=>s.locator),n=i(this,P).resolveForUseSigner(e,t,()=>this.isRecoverySigner(e));switch(n.kind){case"delegated":return i(this,S).onSignerSelected(),!1;case"recovery":return i(this,l).stripSecretFromRecovery(),i(this,S).onSignerSelected(),!0;case"unregistered":throw new Error(n.message)}})}tryAutoSelectPasskey(e){return o(this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):k(e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return o(this,null,function*(){return i(this,l).signerIsRegistered(e)})}isSignerApproved(e){return o(this,null,function*(){return i(this,l).isSignerApproved(e)})}needsRecovery(){return i(this,S).needsRecovery}recover(){return o(this,null,function*(){yield i(this,S).recover()})}signers(){return o(this,null,function*(){var s,h;a.info("wallet.signers.start");let e=yield i(this,c).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new _(JSON.stringify(e));if(!pe(e)){let g=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw a.error("wallet.signers.error",{error:g}),new J(g)}let r=(h=(s=e==null?void 0:e.config)==null?void 0:s.delegatedSigners)!=null?h:[],n=(yield Promise.all(r.map(g=>o(this,null,function*(){try{return(yield i(this,l).getSignerState(g.locator)).signer}catch(d){return null}})))).filter(g=>g!=null);return a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,c).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return i(this,l)}preAuthIfNeeded(){return o(this,null,function*(){yield i(this,I),i(this,E)==null&&m(this,E,this.recover());try{yield i(this,E)}finally{m(this,E,null)}let e=i(this,l).require();e instanceof Z&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=i(this,l).recovery;if(r==null||r.type!==e.type)return!1;let t=F(e.type);return t.matchesRecovery(e,r,i(this,l).descriptorContext())?(t.adoptsRecoveryConfigOnMatch&&i(this,l).adoptRecoveryConfig(e),!0):!1}resolveChainForEnvironment(){let e=K(this.chain,i(this,c).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return o(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return o(this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return o(this,null,function*(){var d,v;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=i(this,l).require(),n=yield i(this,c).getSignature(this.walletLocator,e);if("error"in n)throw new B(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let p=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,p)}let s=(d=n.approvals)==null?void 0:d.pending;if(s==null||s.length===0)return n;let h=[...(v=r==null?void 0:r.additionalSigners)!=null?v:[],t],g=yield Promise.all(s.map(p=>o(this,null,function*(){let C=h.find(w=>w.locator()===p.signer.locator);if(C==null)throw new O(`Signer ${p.signer.locator} not found in pending approvals`);let f=yield C.signMessage(p.message);return N(y({},f),{signer:C.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return o(this,null,function*(){var d,v,p,C,f;let t=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in t)throw new V(JSON.stringify(t));yield(p=(v=(d=i(this,L))==null?void 0:d.callbacks)==null?void 0:v.onTransactionStart)==null?void 0:p.call(v);let n=i(this,l).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let w=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,w)}let s=(C=t.approvals)==null?void 0:C.pending;if(s==null||s.length===0)return t;let h=[...(f=r==null?void 0:r.additionalSigners)!=null?f:[],n],g=yield Promise.all(s.map(w=>o(this,null,function*(){let u=h.find(de=>de.locator()===w.signer.locator);if(u==null)throw new O(`Signer ${w.signer.locator} not found in pending approvals`);let le=u.type==="device",ce=t.chainType==="solana"&&"transaction"in t.onChain&&!le?t.onChain.transaction:w.message,ge=yield u.signTransaction(ce);return N(y({},ge),{signer:u.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return o(this,null,function*(){a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,c).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new z(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return o(this,null,function*(){let t=yield i(this,c).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new H(JSON.stringify(t));return t})}waitForSignature(e){return o(this,null,function*(){return yield oe(i(this,c),this.walletLocator,e)})}waitForTransaction(h){return o(this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:n=2e3,initialBackoffMs:s=M}={}){return yield se(i(this,c),this.walletLocator,e,{timeoutMs:r,backoffMultiplier:t,maxBackoffMs:n,initialBackoffMs:s})})}sleep(e){return o(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};L=new WeakMap,c=new WeakMap,T=new WeakMap,P=new WeakMap,l=new WeakMap,S=new WeakMap,x=new WeakMap,I=new WeakMap,E=new WeakMap,R([W({logger:a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),R([W({logger:a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),R([W({logger:a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),R([W({logger:a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),R([W({logger:a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),R([W({logger:a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"removeSigner",1),R([W({logger:a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),R([W({logger:a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),R([W({logger:a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function pe(D){return D.type==="smart"&&Y(D.chainType)}export{A as a};
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var o=`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
2
- Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`,l= exports.b ={type:"external-wallet",validateConfig(e){if(!("address"in e)||e.address==null)throw new Error("External wallet signer requires a wallet address");if(!("onSign"in e)||typeof e.onSign!="function")throw new Error("External wallet signer requires an onSign callback")},buildInternalConfig(e){let n=e;return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},n),{locator:`external-wallet:${n.address}`})},canAutoAssemble(e){return"onSign"in e&&typeof e.onSign=="function"},addSignerPayload(e){return _chunkNX256LAHcjs.a.call(void 0, e)},matchesRecovery(e,n){return _chunkNX256LAHcjs.a.call(void 0, e)===_chunkNX256LAHcjs.a.call(void 0, n)},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>o};exports.a = o; exports.b = l;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkR7S55N7Jcjs = require('./chunk-R7S55N7J.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var o=`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
2
+ Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`,l= exports.b ={type:"external-wallet",validateConfig(e){if(!("address"in e)||e.address==null)throw new Error("External wallet signer requires a wallet address");if(!("onSign"in e)||typeof e.onSign!="function")throw new Error("External wallet signer requires an onSign callback")},buildInternalConfig(e){let n=e;return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},n),{locator:`external-wallet:${n.address}`})},canAutoAssemble(e){return"onSign"in e&&typeof e.onSign=="function"},addSignerPayload(e){return _chunkR7S55N7Jcjs.a.call(void 0, e)},matchesRecovery(e,n){return _chunkR7S55N7Jcjs.a.call(void 0, e)===_chunkR7S55N7Jcjs.a.call(void 0, n)},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>o};exports.a = o; exports.b = l;