@crossmint/wallets-sdk 1.0.0-beta.2 → 1.0.0-beta.4

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 (237) hide show
  1. package/dist/api/__tests__/constants.d.cts +5 -5
  2. package/dist/api/__tests__/constants.d.ts +5 -5
  3. package/dist/api/__tests__/test-utils.cjs +1 -1
  4. package/dist/api/__tests__/test-utils.d.cts +4 -4
  5. package/dist/api/__tests__/test-utils.d.ts +4 -4
  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 +7 -7
  9. package/dist/api/client.d.ts +7 -7
  10. package/dist/api/client.js +1 -1
  11. package/dist/api/index.cjs +1 -1
  12. package/dist/api/index.d.cts +4 -4
  13. package/dist/api/index.d.ts +4 -4
  14. package/dist/api/index.js +1 -1
  15. package/dist/api/types.d.cts +4 -4
  16. package/dist/api/types.d.ts +4 -4
  17. package/dist/chains/chains.cjs +1 -1
  18. package/dist/chains/chains.d.cts +2 -1
  19. package/dist/chains/chains.d.ts +2 -1
  20. package/dist/chains/chains.js +1 -1
  21. package/dist/chunk-2GXYCJD4.js +1 -0
  22. package/dist/{chunk-RN77IYDQ.js → chunk-2ITOLYW3.js} +1 -1
  23. package/dist/chunk-3VSFHDFH.cjs +1 -0
  24. package/dist/{chunk-D5YDWSO5.cjs → chunk-3VYGTPRF.cjs} +1 -1
  25. package/dist/chunk-5FH7WFWL.cjs +1 -0
  26. package/dist/{chunk-S3DMYMEQ.js → chunk-5URDSXVQ.js} +1 -1
  27. package/dist/{chunk-BFIHTTMM.cjs → chunk-6EZCCLTK.cjs} +1 -1
  28. package/dist/chunk-6FGJ3ICD.js +1 -0
  29. package/dist/{chunk-G5R6VQGJ.js → chunk-6XY4DLBW.js} +1 -1
  30. package/dist/chunk-BITOMWYZ.js +1 -0
  31. package/dist/{chunk-5YG5A77Q.js → chunk-CIKFO2S5.js} +1 -1
  32. package/dist/{chunk-TFMNBTFK.cjs → chunk-DCHEMXSV.cjs} +1 -1
  33. package/dist/{chunk-YLRD3ANZ.cjs → chunk-EBSUOTYD.cjs} +1 -1
  34. package/dist/chunk-EM3D5Q3A.js +1 -0
  35. package/dist/chunk-EXC7TCGL.js +1 -0
  36. package/dist/chunk-GEN63WDH.js +1 -0
  37. package/dist/{chunk-JLT4EA2Z.js → chunk-HCC5C4YI.js} +1 -1
  38. package/dist/chunk-IOSADDL5.js +1 -0
  39. package/dist/chunk-ITNNPNZL.cjs +1 -0
  40. package/dist/{chunk-R3EQXI46.js → chunk-IYRVMHRW.js} +1 -1
  41. package/dist/{chunk-NF7KU2ML.cjs → chunk-J35YEECK.cjs} +1 -1
  42. package/dist/chunk-K5TQ4QU3.cjs +1 -0
  43. package/dist/{chunk-SP2YD44M.js → chunk-KCOND2E6.js} +1 -1
  44. package/dist/chunk-KLL2BBSZ.cjs +1 -0
  45. package/dist/{chunk-JUKCHXJ6.cjs → chunk-L3HSG6Q5.cjs} +1 -1
  46. package/dist/{chunk-NCXMTHC4.js → chunk-LY5YPRHI.js} +1 -1
  47. package/dist/chunk-LZNQBJEK.cjs +1 -0
  48. package/dist/{chunk-3HLCTEWX.js → chunk-MBFWSNXX.js} +1 -1
  49. package/dist/{chunk-YQQWKSNT.cjs → chunk-MDJPC3BI.cjs} +1 -1
  50. package/dist/chunk-N57ARKT3.cjs +1 -0
  51. package/dist/{chunk-YFAJXQAM.cjs → chunk-NJEW3A4J.cjs} +1 -1
  52. package/dist/{chunk-F6PYIH4E.cjs → chunk-O5WMZIT3.cjs} +1 -1
  53. package/dist/{chunk-67Z4SJMH.js → chunk-OIYYEGNS.js} +1 -1
  54. package/dist/chunk-RBSMBO4T.js +1 -0
  55. package/dist/chunk-RD3ZYT3L.cjs +1 -0
  56. package/dist/{chunk-BW27ZG6O.cjs → chunk-RNAUBUFH.cjs} +1 -1
  57. package/dist/chunk-SE7543EV.cjs +1 -0
  58. package/dist/chunk-T3U46LK3.cjs +1 -0
  59. package/dist/{chunk-4ADZVYB5.cjs → chunk-TTNUB2AD.cjs} +1 -1
  60. package/dist/{chunk-S4O54O4C.cjs → chunk-U2AHGQVY.cjs} +1 -1
  61. package/dist/{chunk-WYMBO52A.js → chunk-W7LJS32A.js} +1 -1
  62. package/dist/chunk-X56VYCUR.js +1 -0
  63. package/dist/{chunk-MCBBBEJT.js → chunk-XTXZKBPM.js} +1 -1
  64. package/dist/chunk-YF5G4U6L.cjs +1 -0
  65. package/dist/chunk-YIO5XXQ4.js +1 -0
  66. package/dist/chunk-YZDV5F74.js +1 -0
  67. package/dist/chunk-ZB35EKCS.cjs +1 -0
  68. package/dist/{chunk-IFD3BVMM.js → chunk-ZIUQ3B7O.js} +1 -1
  69. package/dist/{chunk-HOWDLODW.cjs → chunk-ZS3XSKA4.cjs} +1 -1
  70. package/dist/chunk-ZUZCUZSL.js +1 -0
  71. package/dist/index.cjs +1 -1
  72. package/dist/index.d.cts +6 -6
  73. package/dist/index.d.ts +6 -6
  74. package/dist/index.js +1 -1
  75. package/dist/logger/index.cjs +1 -1
  76. package/dist/logger/index.js +1 -1
  77. package/dist/logger/init.cjs +1 -1
  78. package/dist/logger/init.js +1 -1
  79. package/dist/sdk.cjs +1 -1
  80. package/dist/sdk.d.cts +6 -6
  81. package/dist/sdk.d.ts +6 -6
  82. package/dist/sdk.js +1 -1
  83. package/dist/signers/device.d.cts +5 -5
  84. package/dist/signers/device.d.ts +5 -5
  85. package/dist/signers/evm-api-key.d.cts +5 -5
  86. package/dist/signers/evm-api-key.d.ts +5 -5
  87. package/dist/signers/evm-external-wallet.d.cts +5 -5
  88. package/dist/signers/evm-external-wallet.d.ts +5 -5
  89. package/dist/signers/external-wallet-signer.d.cts +4 -4
  90. package/dist/signers/external-wallet-signer.d.ts +4 -4
  91. package/dist/signers/index.cjs +1 -1
  92. package/dist/signers/index.d.cts +4 -4
  93. package/dist/signers/index.d.ts +4 -4
  94. package/dist/signers/index.js +1 -1
  95. package/dist/signers/non-custodial/index.cjs +1 -1
  96. package/dist/signers/non-custodial/index.d.cts +5 -5
  97. package/dist/signers/non-custodial/index.d.ts +5 -5
  98. package/dist/signers/non-custodial/index.js +1 -1
  99. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  100. package/dist/signers/non-custodial/ncs-evm-signer.d.cts +5 -5
  101. package/dist/signers/non-custodial/ncs-evm-signer.d.ts +5 -5
  102. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  103. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  104. package/dist/signers/non-custodial/ncs-signer.d.cts +5 -5
  105. package/dist/signers/non-custodial/ncs-signer.d.ts +5 -5
  106. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  107. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  108. package/dist/signers/non-custodial/ncs-solana-signer.d.cts +5 -5
  109. package/dist/signers/non-custodial/ncs-solana-signer.d.ts +5 -5
  110. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  111. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  112. package/dist/signers/non-custodial/ncs-stellar-signer.d.cts +5 -5
  113. package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +5 -5
  114. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  115. package/dist/signers/passkey.d.cts +5 -5
  116. package/dist/signers/passkey.d.ts +5 -5
  117. package/dist/signers/server/assemble-server-signer.cjs +1 -1
  118. package/dist/signers/server/assemble-server-signer.d.cts +4 -4
  119. package/dist/signers/server/assemble-server-signer.d.ts +4 -4
  120. package/dist/signers/server/assemble-server-signer.js +1 -1
  121. package/dist/signers/server/evm-server-signer.d.cts +5 -5
  122. package/dist/signers/server/evm-server-signer.d.ts +5 -5
  123. package/dist/signers/server/helpers/derive-server-signer.cjs +1 -1
  124. package/dist/signers/server/helpers/derive-server-signer.d.cts +4 -4
  125. package/dist/signers/server/helpers/derive-server-signer.d.ts +4 -4
  126. package/dist/signers/server/helpers/derive-server-signer.js +1 -1
  127. package/dist/signers/server/helpers/index.cjs +1 -1
  128. package/dist/signers/server/helpers/index.d.cts +4 -4
  129. package/dist/signers/server/helpers/index.d.ts +4 -4
  130. package/dist/signers/server/helpers/index.js +1 -1
  131. package/dist/signers/server/index.cjs +1 -1
  132. package/dist/signers/server/index.d.cts +4 -4
  133. package/dist/signers/server/index.d.ts +4 -4
  134. package/dist/signers/server/index.js +1 -1
  135. package/dist/signers/server/solana-server-signer.d.cts +5 -5
  136. package/dist/signers/server/solana-server-signer.d.ts +5 -5
  137. package/dist/signers/server/stellar-server-signer.cjs +1 -1
  138. package/dist/signers/server/stellar-server-signer.d.cts +6 -6
  139. package/dist/signers/server/stellar-server-signer.d.ts +6 -6
  140. package/dist/signers/server/stellar-server-signer.js +1 -1
  141. package/dist/signers/solana-api-key.d.cts +5 -5
  142. package/dist/signers/solana-api-key.d.ts +5 -5
  143. package/dist/signers/solana-external-wallet.cjs +1 -1
  144. package/dist/signers/solana-external-wallet.d.cts +5 -5
  145. package/dist/signers/solana-external-wallet.d.ts +5 -5
  146. package/dist/signers/solana-external-wallet.js +1 -1
  147. package/dist/signers/stellar-external-wallet.d.cts +5 -5
  148. package/dist/signers/stellar-external-wallet.d.ts +5 -5
  149. package/dist/signers/types.d.cts +2 -2
  150. package/dist/signers/types.d.ts +2 -2
  151. package/dist/{types-D-xASbms.d.cts → types-CpT91HUW.d.cts} +196 -194
  152. package/dist/{types-BDRS_MOb.d.ts → types-DVXPGSpw.d.ts} +196 -194
  153. package/dist/utils/constants.cjs +1 -1
  154. package/dist/utils/constants.js +1 -1
  155. package/dist/utils/device-signers/DeviceSignerKeyStorage.cjs +1 -1
  156. package/dist/utils/device-signers/DeviceSignerKeyStorage.d.cts +6 -0
  157. package/dist/utils/device-signers/DeviceSignerKeyStorage.d.ts +6 -0
  158. package/dist/utils/device-signers/DeviceSignerKeyStorage.js +1 -1
  159. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  160. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.d.cts +3 -0
  161. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.d.ts +3 -0
  162. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  163. package/dist/utils/device-signers/createDeviceSigner.cjs +1 -1
  164. package/dist/utils/device-signers/createDeviceSigner.d.cts +7 -6
  165. package/dist/utils/device-signers/createDeviceSigner.d.ts +7 -6
  166. package/dist/utils/device-signers/createDeviceSigner.js +1 -1
  167. package/dist/utils/device-signers/index.cjs +1 -1
  168. package/dist/utils/device-signers/index.d.cts +5 -5
  169. package/dist/utils/device-signers/index.d.ts +5 -5
  170. package/dist/utils/device-signers/index.js +1 -1
  171. package/dist/utils/errors.cjs +1 -1
  172. package/dist/utils/errors.d.cts +11 -2
  173. package/dist/utils/errors.d.ts +11 -2
  174. package/dist/utils/errors.js +1 -1
  175. package/dist/utils/signer-locator.d.cts +4 -4
  176. package/dist/utils/signer-locator.d.ts +4 -4
  177. package/dist/utils/signer-mapping.d.cts +5 -5
  178. package/dist/utils/signer-mapping.d.ts +5 -5
  179. package/dist/utils/signer-validation.cjs +1 -1
  180. package/dist/utils/signer-validation.d.cts +6 -4
  181. package/dist/utils/signer-validation.d.ts +6 -4
  182. package/dist/utils/signer-validation.js +1 -1
  183. package/dist/utils/stellar.cjs +1 -0
  184. package/dist/utils/stellar.d.cts +18 -0
  185. package/dist/utils/stellar.d.ts +18 -0
  186. package/dist/utils/stellar.js +1 -0
  187. package/dist/wallets/__tests__/setup.cjs +1 -1
  188. package/dist/wallets/__tests__/setup.js +1 -1
  189. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  190. package/dist/wallets/__tests__/test-helpers.d.cts +4 -4
  191. package/dist/wallets/__tests__/test-helpers.d.ts +4 -4
  192. package/dist/wallets/__tests__/test-helpers.js +1 -1
  193. package/dist/wallets/evm.cjs +1 -1
  194. package/dist/wallets/evm.d.cts +5 -5
  195. package/dist/wallets/evm.d.ts +5 -5
  196. package/dist/wallets/evm.js +1 -1
  197. package/dist/wallets/solana.cjs +1 -1
  198. package/dist/wallets/solana.d.cts +4 -4
  199. package/dist/wallets/solana.d.ts +4 -4
  200. package/dist/wallets/solana.js +1 -1
  201. package/dist/wallets/stellar.cjs +1 -1
  202. package/dist/wallets/stellar.d.cts +4 -4
  203. package/dist/wallets/stellar.d.ts +4 -4
  204. package/dist/wallets/stellar.js +1 -1
  205. package/dist/wallets/types.d.cts +1 -1
  206. package/dist/wallets/types.d.ts +1 -1
  207. package/dist/wallets/wallet-factory.cjs +1 -1
  208. package/dist/wallets/wallet-factory.d.cts +4 -4
  209. package/dist/wallets/wallet-factory.d.ts +4 -4
  210. package/dist/wallets/wallet-factory.js +1 -1
  211. package/dist/wallets/wallet.cjs +1 -1
  212. package/dist/wallets/wallet.d.cts +47 -14
  213. package/dist/wallets/wallet.d.ts +47 -14
  214. package/dist/wallets/wallet.js +1 -1
  215. package/package.json +4 -5
  216. package/dist/chunk-6MGMZ3SI.cjs +0 -1
  217. package/dist/chunk-6OXELDPD.js +0 -1
  218. package/dist/chunk-BEW7JDW6.cjs +0 -1
  219. package/dist/chunk-GDRKG42L.cjs +0 -1
  220. package/dist/chunk-ISXH7QXG.cjs +0 -1
  221. package/dist/chunk-NKR3UAMA.cjs +0 -1
  222. package/dist/chunk-NPCKXKQ7.js +0 -1
  223. package/dist/chunk-O4FVTK7X.cjs +0 -1
  224. package/dist/chunk-P6MB5P2F.js +0 -1
  225. package/dist/chunk-PHXT77LR.js +0 -1
  226. package/dist/chunk-PKYRYRX4.js +0 -1
  227. package/dist/chunk-PSXRNSOE.js +0 -1
  228. package/dist/chunk-RC6KDONJ.cjs +0 -1
  229. package/dist/chunk-RLAW2ERD.js +0 -1
  230. package/dist/chunk-S5KDZFZ7.cjs +0 -1
  231. package/dist/chunk-SPVAZXRY.js +0 -1
  232. package/dist/chunk-TYFWX53A.js +0 -1
  233. package/dist/chunk-U7QSF6P7.cjs +0 -1
  234. package/dist/chunk-WT5MDUZY.js +0 -1
  235. package/dist/chunk-WTVI4AL4.js +0 -1
  236. package/dist/chunk-ZACCKNGY.cjs +0 -1
  237. package/dist/chunk-ZKL4RO4I.cjs +0 -1
@@ -0,0 +1 @@
1
+ import{a as ae}from"./chunk-6FGJ3ICD.js";import{a as O}from"./chunk-GOXB2RBF.js";import{b as G,c as M}from"./chunk-N5WVT7QE.js";import{a as L}from"./chunk-XTXZKBPM.js";import{b as W}from"./chunk-RBSMBO4T.js";import{a as ne}from"./chunk-KCOND2E6.js";import{f as ie}from"./chunk-2GXYCJD4.js";import{B as te,d as j,e as _,j as J,n as U,q as B,r as V,s as z,t as Q,u as H,v as X,w as Y,x as Z,y as ee,z as re}from"./chunk-EXC7TCGL.js";import{a}from"./chunk-IYRVMHRW.js";import{d as q}from"./chunk-ZUZCUZSL.js";import{a as m,b as k,c as I,d as n,e as E,f,g as h}from"./chunk-J3R36SGJ.js";import{isValidAddress as se,WithLoggerContext as P}from"@crossmint/common-sdk-base";var v,y,u,T,$,b,F,R,N,A=class{constructor(e,r){E(this,v);E(this,y);E(this,u);E(this,T);E(this,$);E(this,b,!1);E(this,F,!1);E(this,R);E(this,N,null);let{chain:t,address:i,owner:d,options:p,alias:g,recovery:l,signers:s,signer:c}=e;f(this,u,r),this.chain=t,this.address=i,this.owner=d,f(this,y,p),this.alias=g,f(this,T,l),f(this,$,s!=null?s:[]),f(this,v,c),f(this,R,this.initDefaultSigner())}get signer(){return n(this,v)}initDeviceSigner(){return h(this,null,function*(){var i;let e=(i=n(this,y))==null?void 0:i.deviceSignerKeyStorage;if(e==null||this.chain==="solana")return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(d){a.error("wallet.initDeviceSigner.error",{error:d}),f(this,b,!0);return}let t=this.buildInternalSignerConfig(r);f(this,v,L(this.chain,t,e))})}initDefaultSigner(){return h(this,null,function*(){var r,t;if(n(this,v)!=null||(yield this.initDeviceSigner(),n(this,v)!=null||n(this,b)))return;let e=n(this,$).filter(i=>i.type!=="server"&&i.type!=="api-key");try{if(e.length===0){if(n(this,T).type!=="server"&&n(this,T).type!=="api-key"){let i=this.buildInternalSignerConfig(n(this,T));f(this,v,L(this.chain,i,(r=n(this,y))==null?void 0:r.deviceSignerKeyStorage))}}else if(e.length===1){let i=this.buildInternalSignerConfig(e[0]);f(this,v,L(this.chain,i,(t=n(this,y))==null?void 0:t.deviceSignerKeyStorage))}}catch(i){}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return n(e,T)}get apiClient(){return n(this,u)}get options(){return n(this,y)}get recovery(){return n(this,T)}balances(e){return h(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t;switch(this.chain){case"solana":t="sol";break;case"stellar":t="xlm";break;default:t="eth";break}let i=[t,"usdc",...e!=null?e:[]],d=yield n(this,u).getBalance(this.address,{chains:[r],tokens:i});if("error"in d)throw a.error("wallet.balances.error",{error:d}),new Error(`Failed to get balances for wallet: ${JSON.stringify(d.message)}`);return a.info("wallet.balances.success"),this.transformBalanceResponse(d,t,e)})}stagingFund(e,r){return h(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})}transformBalanceResponse(e,r,t){let i=s=>{var S,C,x,D,K;let c=(S=s.chains)==null?void 0:S[this.chain],o={};return this.chain==="solana"&&c!=null&&"mintHash"in c?o={mintHash:c.mintHash}:this.chain==="stellar"&&c!=null&&"contractId"in c?o={contractId:c.contractId}:c!=null&&"contractAddress"in c&&(o={contractAddress:c.contractAddress}),m({symbol:(C=s.symbol)!=null?C:"",name:(x=s.name)!=null?x:"",amount:(D=s.amount)!=null?D:"0",decimals:s.decimals,rawAmount:(K=s.rawAmount)!=null?K:"0"},o)},d=e.find(s=>s.symbol===r),p=e.find(s=>s.symbol==="usdc"),g=e.filter(s=>{var c;return s.symbol!==r&&s.symbol!=="usdc"&&(t==null||t.includes((c=s.symbol)!=null?c:""))}),l=s=>{let c={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o={};return this.chain==="solana"?o={mintHash:void 0}:this.chain==="stellar"?o={contractId:void 0}:o={contractAddress:void 0},m(m({},c),o)};return{nativeToken:d!=null?i(d):l(r),usdc:p!=null?i(p):l("usdc"),tokens:g.map(i)}}nfts(e){return h(this,null,function*(){return yield n(this,u).getNfts(k(m({},e),{chain:this.chain,address:this.address}))})}transactions(){return h(this,null,function*(){let e=yield n(this,u).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return h(this,null,function*(){let r=yield n(this,u).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return h(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e==null?void 0:e.tokens,status:e==null?void 0:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,i){return h(this,null,function*(){let d=this.resolveChainForEnvironment(),p=ce(e),g=de(r,d),l=Number(t);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new z(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);a.info("wallet.send.start",m({recipient:p,token:g,amount:t},(i==null?void 0:i.transactionType)!=null?{transactionType:i.transactionType}:{})),yield this.preAuthIfNeeded();let s=this.requireSigner(),c;(i==null?void 0:i.signer)==null?c=s.locator():typeof i.signer=="string"?c=i.signer:c=`server:${W(i.signer,this.chain,n(this,u).projectId,n(this,u).environment).derivedAddress}`;let o=m({recipient:p,amount:t,signer:c},(i==null?void 0:i.transactionType)!=null?{transactionType:i.transactionType}:{}),S=yield n(this,u).send(this.walletLocator,g,o);if("message"in S)throw a.error("wallet.send.error",{error:S}),new Q(`Failed to send token: ${JSON.stringify(S.message)}`);if((i==null?void 0:i.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:S.id}),{hash:void 0,explorerLink:void 0,transactionId:S.id};let C=yield this.approveTransactionAndWait(S.id);return a.info("wallet.send.success",{transactionId:S.id,hash:C.hash}),C})}approveTransaction(e){return h(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 h(this,null,function*(){if(this.requireSigner(),a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),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 h(this,null,function*(){var p,g;a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?`server:${W(e,this.chain,n(this,u).projectId,n(this,u).environment).derivedAddress}`:e,i=this.signer,d=this.buildInternalSignerConfig(n(this,T));f(this,v,L(this.chain,d,(p=n(this,y))==null?void 0:p.deviceSignerKeyStorage));try{let l=typeof t=="string"||t.type==="passkey"&&t.id==null?t:t.type==="device"&&"publicKey"in t&&t.publicKey!=null?{type:"device",publicKey:t.publicKey,name:t.name}:O(t),s=yield n(this,u).registerSigner(this.walletLocator,{signer:l,chain:this.chain==="solana"||this.chain==="stellar"?void 0:this.chain});if("error"in s)throw a.error("wallet.addSigner.error",{error:s}),new Error(`Failed to register signer: ${JSON.stringify(s.message)}`);let c=G(s,this.chain);if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in s)||s.transaction==null)throw a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");let o=s.transaction.id;if(c==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);return r!=null&&r.prepareOnly?(a.info("wallet.addSigner.prepared",{transactionId:o}),k(m({},c),{transactionId:o})):(yield this.approveTransactionAndWait(o),a.info("wallet.addSigner.success",{transactionId:o}),k(m({},c),{status:"success"}))}else{if(!("chains"in s))throw a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");let o=(g=s.chains)==null?void 0:g[this.chain];if(c==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);if(r!=null&&r.prepareOnly){let S=(o==null?void 0:o.status)!=="success"?o==null?void 0:o.id:void 0;return a.info("wallet.addSigner.prepared",{signatureId:S}),k(m({},c),{signatureId:S})}if((o==null?void 0:o.status)==="awaiting-approval")yield this.approveSignatureAndWait(o.id),a.info("wallet.addSigner.success",{signatureId:o.id});else if((o==null?void 0:o.status)==="pending")yield this.waitForSignature(o.id),a.info("wallet.addSigner.success",{signatureId:o.id});else{if((o==null?void 0:o.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);a.info("wallet.addSigner.success")}return k(m({},c),{status:"success"})}}finally{f(this,v,i)}})}useSigner(e){return h(this,null,function*(){var i;a.info("wallet.useSigner.start"),this.validateSignerInput(e),e.type==="device"?yield this.resolveDeviceSignerAvailability(e):yield this.resolveNonDeviceSigner(e);let r=this.buildInternalSignerConfig(e),t=O(e);f(this,v,L(this.chain,r,(i=n(this,y))==null?void 0:i.deviceSignerKeyStorage)),a.info("wallet.useSigner.success",{signerLocator:t})})}resolveNonDeviceSigner(e){return h(this,null,function*(){if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e)){f(this,b,!1);return}throw new Error("No passkey signer is registered on this wallet.")}let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r)){f(this,b,!1);return}if(this.isRecoverySigner(e)){f(this,b,!1);return}throw new Error(`Signer "${r}" is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return h(this,null,function*(){let t=(yield this.signers()).filter(i=>i.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){if(e.type==="server"){let{derivedAddress:r}=W(e,this.chain,n(this,u).projectId,n(this,u).environment);return`server:${r}`}return O(e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return h(this,null,function*(){return(yield this.signers()).some(t=>t.locator===e)})}needsRecovery(){return n(this,b)}recover(){return h(this,null,function*(){var d,p;if(a.info("wallet.recover.start"),n(this,v)==null&&(yield this.initDeviceSigner()),((d=n(this,v))==null?void 0:d.type)!=="device"){a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"});return}if(n(this,F)){a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}let e=n(this,v).locator();if(yield this.signerIsRegistered(e)){a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),f(this,b,!1),f(this,F,!0);return}let t=(p=n(this,y))==null?void 0:p.deviceSignerKeyStorage;if(t==null)throw new Error("Device signer key storage is required to recover a device signer");let i=yield ae(t,this.address);try{yield this.addSigner(i)}catch(g){throw a.error("wallet.recover.device.error",{error:g}),yield t.deleteKey(this.address),g}f(this,v,L(this.chain,{type:"device",locator:i.locator,address:this.address},t)),a.info("wallet.recover.device.success",{signerLocator:i.locator}),f(this,b,!1),f(this,F,!0)})}signers(){return h(this,null,function*(){var d,p;a.info("wallet.signers.start");let e=yield n(this,u).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new _(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new j(`Wallet type ${e.type} not supported`);let r=(p=(d=e==null?void 0:e.config)==null?void 0:d.delegatedSigners)!=null?p:[];if(this.chain==="solana"||this.chain==="stellar"){let g=r.map(l=>M(l,"success"));return a.info("wallet.signers.success",{count:g.length}),g}let i=(yield Promise.all(r.map(g=>h(this,null,function*(){if(g.locator.startsWith("device:"))return M(g,"success");try{let l=yield n(this,u).getSigner(this.walletLocator,g.locator);return"error"in l?null:G(l,this.chain)}catch(l){return null}})))).filter(g=>g!=null);return a.info("wallet.signers.success",{count:i.length}),i})}get walletLocator(){if(n(this,u).isServerSide)return this.address;{let e;switch(this.chain){case"stellar":e="me:stellar:smart";break;case"solana":e="me:solana:smart";break;default:e="me:evm:smart";break}let r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}requireSigner(){if(n(this,v)==null)throw new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available.");return n(this,v)}preAuthIfNeeded(){return h(this,null,function*(){yield n(this,R),n(this,N)==null&&f(this,N,this.recover());try{yield n(this,N)}finally{f(this,N,null)}let e=this.requireSigner();e instanceof ne&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=n(this,T);if(r==null||r.type!==e.type||e.type==="device")return!1;if(e.type==="passkey")return!0;if(e.type==="server"&&r.type==="server"){let t=W(e,this.chain,n(this,u).projectId,n(this,u).environment).derivedAddress,i="address"in r?r.address:null;return i==null?!1:t===i}return O(e)===O(r)}validateSignerInput(e){switch(e.type){case"email":if(!("email"in e)||e.email==null)throw new Error("Email signer requires an email address");break;case"phone":if(!("phone"in e)||e.phone==null)throw new Error("Phone signer requires a phone number");break;case"external-wallet":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");break;case"passkey":case"device":case"api-key":break;default:break}}resolveDeviceSignerAvailability(e){return h(this,null,function*(){var p;let r=(p=n(this,y))==null?void 0:p.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let t=yield r.getKey(this.address);if(t!=null){e.locator=`device:${t}`;return}let d=(yield this.signers()).filter(g=>g.locator.startsWith("device:"));for(let g of d){let l=g.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=g.locator;return}}f(this,b,!0),f(this,F,!1)})}buildInternalSignerConfig(e){var r,t,i,d,p,g;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:n(this,u).crossmint,clientTEEConnection:(r=n(this,y))==null?void 0:r.clientTEEConnection,onAuthRequired:(i=(t=n(this,y))==null?void 0:t.callbacks)==null?void 0:i.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:n(this,u).crossmint,clientTEEConnection:(d=n(this,y))==null?void 0:d.clientTEEConnection,onAuthRequired:(g=(p=n(this,y))==null?void 0:p.callbacks)==null?void 0:g.onAuthRequired};case"passkey":{let l="id"in e&&e.id?e.id:"";return{type:"passkey",id:l,locator:`passkey:${l}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:e.onCreatePasskey,onSignWithPasskey:e.onSignWithPasskey}}case"device":return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:this.address};case"external-wallet":return k(m({},e),{locator:`external-wallet:${e.address}`});case"api-key":return{type:"api-key",locator:"api-key",address:this.address};case"server":{let{derivedKeyBytes:l,derivedAddress:s}=W(e,this.chain,n(this,u).projectId,n(this,u).environment);return{type:"server",derivedKeyBytes:l,locator:`server:${s}`,address:s}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=ie(this.chain,n(this,u).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return h(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return h(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 h(this,null,function*(){var l,s;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=this.requireSigner(),i=yield n(this,u).getSignature(this.walletLocator,e);if("error"in i)throw new B(JSON.stringify(i));if(t.type==="api-key")return i;if((r==null?void 0:r.approval)!=null){let c=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,c)}let d=(l=i.approvals)==null?void 0:l.pending;if(d==null)return i;let p=[...(s=r==null?void 0:r.additionalSigners)!=null?s:[],t],g=yield Promise.all(d.map(c=>h(this,null,function*(){let o=p.find(C=>C.locator()===c.signer.locator);if(o==null)throw new J(`Signer ${c.signer.locator} not found in pending approvals`);let S=yield o.signMessage(c.message);return k(m({},S),{signer:o.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return h(this,null,function*(){var l,s,c,o,S;let t=yield n(this,u).getTransaction(this.walletLocator,e);if("error"in t)throw new H(JSON.stringify(t));yield(c=(s=(l=n(this,y))==null?void 0:l.callbacks)==null?void 0:s.onTransactionStart)==null?void 0:c.call(s);let i=this.requireSigner();if(i.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let C=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,C)}let d=(o=t.approvals)==null?void 0:o.pending;if(d==null)return t;let p=[...(S=r==null?void 0:r.additionalSigners)!=null?S:[],i],g=yield Promise.all(d.map(C=>h(this,null,function*(){let x=p.find(le=>le.locator()===C.signer.locator);if(x==null)throw new J(`Signer ${C.signer.locator} not found in pending approvals`);let D=x.type==="device",K=t.chainType==="solana"&&"transaction"in t.onChain&&!D?t.onChain.transaction:C.message,oe=yield x.signTransaction(K);return k(m({},oe),{signer:x.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return h(this,null,function*(){a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield n(this,u).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new re(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return h(this,null,function*(){let t=yield n(this,u).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new V(JSON.stringify(t));return t})}waitForSignature(e){return h(this,null,function*(){let r=null;do if(yield new Promise(t=>setTimeout(t,q)),r=yield n(this,u).getSignature(this.walletLocator,e),"error"in r)throw new B(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new U("Signature signing failed");if(!r.outputSignature)throw new B("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(p){return h(this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:i=2e3,initialBackoffMs:d=q}={}){var c;a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let g=Date.now(),l;do{if(Date.now()-g>r)throw new X("Transaction confirmation timeout");if(l=yield n(this,u).getTransaction(this.walletLocator,e),l.error)throw new H(JSON.stringify(l));yield this.sleep(d),d=Math.min(d*t,i)}while(l.status==="pending");if(l.status==="failed")throw new Y(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new Z("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let s=l.onChain.txId;if(s==null)throw new ee("Transaction hash not found on transaction response");return{hash:s,explorerLink:(c=l.onChain.explorerLink)!=null?c:"",transactionId:l.id}})}sleep(e){return h(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};v=new WeakMap,y=new WeakMap,u=new WeakMap,T=new WeakMap,$=new WeakMap,b=new WeakMap,F=new WeakMap,R=new WeakMap,N=new WeakMap,I([P({logger:a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),I([P({logger:a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),I([P({logger:a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),I([P({logger:a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),I([P({logger:a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),I([P({logger:a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),I([P({logger:a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),I([P({logger:a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function ce(w){if(typeof w=="string"){if(!se(w))throw new te(`Invalid recipient address: "${w}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return w}if("email"in w)return`email:${w.email}`;if("x"in w)return`x:${w.x}`;if("twitter"in w)return`twitter:${w.twitter}`;if("phone"in w)return`phoneNumber:${w.phone}`;if("userId"in w)return`userId:${w.userId}`;throw new Error("Invalid recipient locator")}function de(w,e){return se(w)?`${e}:${w}`:`${e}:${w.toLowerCase()}`}export{A as a};
@@ -1 +1 @@
1
- import{a as r}from"./chunk-WTVI4AL4.js";import{b as T}from"./chunk-PKYRYRX4.js";import{a as g}from"./chunk-WYMBO52A.js";import{r as f}from"./chunk-PSXRNSOE.js";import{a}from"./chunk-R3EQXI46.js";import{c as u,g as c}from"./chunk-J3R36SGJ.js";import m from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as C}from"@crossmint/common-sdk-base";var o=class o extends r{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:r.getOptions(n),alias:n.alias,recovery:r.getRecovery(n),signer:n.signer},r.getApiClient(n))}static from(n){if(!y(n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return c(this,null,function*(){var d,p;a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return a.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let i={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(l=>new g({type:"external-wallet",address:l.publicKey.toString(),locator:`external-wallet:${l.publicKey.toString()}`,onSign:h=>(h.sign([l]),Promise.resolve(h))}))},t=yield this.approveTransactionAndWait(e.id,i);return a.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:t.hash}),t})}createTransaction(n){return c(this,null,function*(){var t;let e;((t=n.options)==null?void 0:t.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${T(n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=m.encode(n.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in i)throw new f(JSON.stringify(i));return i})}};u([C({logger:a,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;export{S as a};
1
+ import{a as r}from"./chunk-GEN63WDH.js";import{b as T}from"./chunk-RBSMBO4T.js";import{a as g}from"./chunk-W7LJS32A.js";import{t as f}from"./chunk-EXC7TCGL.js";import{a}from"./chunk-IYRVMHRW.js";import{c as u,g as c}from"./chunk-J3R36SGJ.js";import m from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as C}from"@crossmint/common-sdk-base";var o=class o extends r{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:r.getOptions(n),alias:n.alias,recovery:r.getRecovery(n),signer:n.signer},r.getApiClient(n))}static from(n){if(!y(n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return c(this,null,function*(){var d,p;a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return a.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let i={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(l=>new g({type:"external-wallet",address:l.publicKey.toString(),locator:`external-wallet:${l.publicKey.toString()}`,onSign:h=>(h.sign([l]),Promise.resolve(h))}))},t=yield this.approveTransactionAndWait(e.id,i);return a.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:t.hash}),t})}createTransaction(n){return c(this,null,function*(){var t;let e;((t=n.options)==null?void 0:t.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${T(n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=m.encode(n.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in i)throw new f(JSON.stringify(i));return i})}};u([C({logger:a,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;export{S as a};
@@ -0,0 +1 @@
1
+ var s=class{constructor(r){this.apiKey=r}};export{s as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkU2AHGQVYcjs = require('./chunk-U2AHGQVY.cjs');var _chunkN57ARKT3cjs = require('./chunk-N57ARKT3.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkN57ARKT3cjs.c,version:_chunkN57ARKT3cjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkU2AHGQVYcjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let a=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in a?_chunkU2AHGQVYcjs.a.error("wallets.api.createWallet.error",{error:a.error,chainType:e.chainType}):"address"in a&&_chunkU2AHGQVYcjs.a.info("wallets.api.createWallet.success",{address:a.address,chainType:e.chainType}),a})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkU2AHGQVYcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkU2AHGQVYcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkU2AHGQVYcjs.a.info("wallets.api.getWallet.success",r),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),s.status!=null&&r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signers/${s}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkU2AHGQVYcjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?_chunkU2AHGQVYcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkU2AHGQVYcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = c;
@@ -1 +1 @@
1
- import{b as n,c as i}from"./chunk-TYFWX53A.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
1
+ import{b as n,c as i}from"./chunk-ZUZCUZSL.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYFAJXQAMcjs = require('./chunk-YFAJXQAM.cjs');var _chunkS4O54O4Ccjs = require('./chunk-S4O54O4C.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkYFAJXQAMcjs.a{constructor(e){super(e)}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkS4O54O4Ccjs.a.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:_chunkYFAJXQAMcjs.b});if(_chunkS4O54O4Ccjs.a.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"}}};exports.a = c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNJEW3A4Jcjs = require('./chunk-NJEW3A4J.cjs');var _chunkU2AHGQVYcjs = require('./chunk-U2AHGQVY.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkNJEW3A4Jcjs.a{constructor(e){super(e)}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkU2AHGQVYcjs.a.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:_chunkNJEW3A4Jcjs.b});if(_chunkU2AHGQVYcjs.a.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"}}};exports.a = c;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _commonsdkauth = require('@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(_commonsdkauth.isEmailValid.call(void 0, 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 (0, _chunkT3U46LK3cjs.g)(m(i,s,e))}}}exports.a = l; exports.b = d;
@@ -1 +1 @@
1
- import{a as g}from"./chunk-O6VBO7KG.js";import{a as l}from"./chunk-WCGUGIGJ.js";import{a as o}from"./chunk-R3EQXI46.js";import{c as m,g as a}from"./chunk-J3R36SGJ.js";import{validateAPIKey as p,WithLoggerContext as w}from"@crossmint/common-sdk-base";var f=class{constructor(r){this.config=r;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=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 a(this,null,function*(){try{if(this.config.clientTEEConnection==null){let r=p(this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new g({environment:r.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return a(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 a(this,null,function*(){o.info("TEE connection not initialized, initializing now");let r=p(this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new g({environment:r.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");o.info("TEE connection initialized successfully")})}handleAuthRequired(){return a(this,null,function*(){var u;let r=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 */ }`);o.info("get-status: sending request");let t=Date.now(),n=yield r.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),e=Date.now()-t;if((n==null?void 0:n.status)!=="success")throw o.error("get-status: failed",{status:n==null?void 0:n.status,error:n==null?void 0:n.error,durationMs:e}),new Error(n==null?void 0:n.error);if(o.info("get-status: response received",{signerStatus:n.signerStatus,durationMs:e}),n.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:h,reject:c}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:h,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),i=>this.verifyOtp(i),()=>a(this,null,function*(){o.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(),i=>this.verifyOtp(i),()=>{var i;return(i=this._authPromise)==null?void 0:i.reject(new l)})),c(new l)}))}catch(i){o.error("handleAuthRequired error",{error:i}),c(i)}try{yield s}catch(i){throw o.error("handleAuthRequired promise error",{error:i}),i}})}ensureAuthenticated(){return a(this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let r=this.config.crossmint.jwt;if(r==null)throw new Error("JWT is required");return r}createAuthPromise(){let r,t;return{promise:new Promise((e,s)=>{r=e,t=s}),resolve:r,reject:t}}sendMessageWithOtp(){return a(this,null,function*(){var h,c;let r=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let n=Date.now(),e=yield r.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(h=this.config.crossmint.jwt)!=null?h:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),s=Date.now()-n;if(o.info("start-onboarding: response received",{status:e==null?void 0:e.status,durationMs:s}),(e==null?void 0:e.status)==="success"&&e.signerStatus==="ready"){this._needsAuth=!1;return}(e==null?void 0:e.status)==="error"&&(o.error("start-onboarding: failed",{error:e.error}),(c=this._authPromise)==null||c.reject(new Error(e.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(r){return a(this,null,function*(){var s,h,c,u;let t;try{let i=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let E=Date.now();t=yield i.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:r}}},options:d}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(i){throw o.error("complete-onboarding: error",{error:i}),this._needsAuth=!0,(h=this._authPromise)==null||h.reject(i),i}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(),i=>this.verifyOtp(i),()=>{var i;return(i=this._authPromise)==null?void 0:i.reject(new l)})),(c=this._authPromise)==null||c.resolve();return}o.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let n=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",e=new Error(n);throw(u=this._authPromise)==null||u.reject(e),e})}_exportPrivateKey(r){return a(this,null,function*(){yield this.handleAuthRequired();let t=this.getJwtOrThrow(),{scheme:n,encoding:e}=this.getChainKeyParams(),s=yield r.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:t,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:e}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};m([w({logger:o,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};export{f as a,d as b};
1
+ import{a as g}from"./chunk-O6VBO7KG.js";import{a as l}from"./chunk-WCGUGIGJ.js";import{a as o}from"./chunk-IYRVMHRW.js";import{c as m,g as a}from"./chunk-J3R36SGJ.js";import{validateAPIKey as p,WithLoggerContext as w}from"@crossmint/common-sdk-base";var f=class{constructor(r){this.config=r;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=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 a(this,null,function*(){try{if(this.config.clientTEEConnection==null){let r=p(this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new g({environment:r.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return a(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 a(this,null,function*(){o.info("TEE connection not initialized, initializing now");let r=p(this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new g({environment:r.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");o.info("TEE connection initialized successfully")})}handleAuthRequired(){return a(this,null,function*(){var u;let r=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 */ }`);o.info("get-status: sending request");let t=Date.now(),n=yield r.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),e=Date.now()-t;if((n==null?void 0:n.status)!=="success")throw o.error("get-status: failed",{status:n==null?void 0:n.status,error:n==null?void 0:n.error,durationMs:e}),new Error(n==null?void 0:n.error);if(o.info("get-status: response received",{signerStatus:n.signerStatus,durationMs:e}),n.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:h,reject:c}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:h,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),i=>this.verifyOtp(i),()=>a(this,null,function*(){o.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(),i=>this.verifyOtp(i),()=>{var i;return(i=this._authPromise)==null?void 0:i.reject(new l)})),c(new l)}))}catch(i){o.error("handleAuthRequired error",{error:i}),c(i)}try{yield s}catch(i){throw o.error("handleAuthRequired promise error",{error:i}),i}})}ensureAuthenticated(){return a(this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let r=this.config.crossmint.jwt;if(r==null)throw new Error("JWT is required");return r}createAuthPromise(){let r,t;return{promise:new Promise((e,s)=>{r=e,t=s}),resolve:r,reject:t}}sendMessageWithOtp(){return a(this,null,function*(){var h,c;let r=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let n=Date.now(),e=yield r.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(h=this.config.crossmint.jwt)!=null?h:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),s=Date.now()-n;if(o.info("start-onboarding: response received",{status:e==null?void 0:e.status,durationMs:s}),(e==null?void 0:e.status)==="success"&&e.signerStatus==="ready"){this._needsAuth=!1;return}(e==null?void 0:e.status)==="error"&&(o.error("start-onboarding: failed",{error:e.error}),(c=this._authPromise)==null||c.reject(new Error(e.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(r){return a(this,null,function*(){var s,h,c,u;let t;try{let i=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let E=Date.now();t=yield i.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:r}}},options:d}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(i){throw o.error("complete-onboarding: error",{error:i}),this._needsAuth=!0,(h=this._authPromise)==null||h.reject(i),i}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(),i=>this.verifyOtp(i),()=>{var i;return(i=this._authPromise)==null?void 0:i.reject(new l)})),(c=this._authPromise)==null||c.resolve();return}o.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let n=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",e=new Error(n);throw(u=this._authPromise)==null||u.reject(e),e})}_exportPrivateKey(r){return a(this,null,function*(){yield this.handleAuthRequired();let t=this.getJwtOrThrow(),{scheme:n,encoding:e}=this.getChainKeyParams(),s=yield r.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:t,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:e}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};m([w({logger:o,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};export{f as a,d as b};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTTNUB2ADcjs = require('./chunk-TTNUB2AD.cjs');var _chunkRNAUBUFHcjs = require('./chunk-RNAUBUFH.cjs');var _chunkJ35YEECKcjs = require('./chunk-J35YEECK.cjs');var _chunkO5WMZIT3cjs = require('./chunk-O5WMZIT3.cjs');var _chunkSPTXAOFRcjs = require('./chunk-SPTXAOFR.cjs');var _chunkNJWSHT2Hcjs = require('./chunk-NJWSHT2H.cjs');var _chunkJJMKQ5PKcjs = require('./chunk-JJMKQ5PK.cjs');var _chunkA33BEWR7cjs = require('./chunk-A33BEWR7.cjs');var _chunkTTSJFEM5cjs = require('./chunk-TTSJFEM5.cjs');var _chunkRXRRXB74cjs = require('./chunk-RXRRXB74.cjs');var _chunk6EZCCLTKcjs = require('./chunk-6EZCCLTK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');function M(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new (0, _chunkO5WMZIT3cjs.a)(e):r==="stellar"?new (0, _chunkRNAUBUFHcjs.a)(e):new (0, _chunkJ35YEECKcjs.a)(e);case"api-key":return r==="solana"?new (0, _chunkRXRRXB74cjs.a)(e):new (0, _chunkJJMKQ5PKcjs.a)(e);case"external-wallet":return r==="solana"?new (0, _chunk6EZCCLTKcjs.a)(e):r==="stellar"?new (0, _chunkSPTXAOFRcjs.a)(e):new (0, _chunkA33BEWR7cjs.a)(e);case"server":return _chunkTTNUB2ADcjs.a.call(void 0, r,e);case"passkey":return new (0, _chunkTTSJFEM5cjs.a)(e);case"device":if(n==null)throw new (0, _chunkT3U46LK3cjs.g)("Device signer key storage is required for device signers");return new (0, _chunkNJWSHT2Hcjs.a)(e,n)}}exports.a = M;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkO4FVTK7Xcjs = require('./chunk-O4FVTK7X.cjs');var _chunkS4O54O4Ccjs = require('./chunk-S4O54O4C.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var v=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],H=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT,_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.MODE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.PLUME,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function j(t){switch(t){case _commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA:return _chains.baseSepolia;case _commonsdkbase.BlockchainIncludingTestnet.BASE:return _chains.base;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY:return _chains.polygonAmoy;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON:return _chains.polygon;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA:return _chains.optimismSepolia;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM:return _chains.optimism;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA:return _chains.arbitrumSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM:return _chains.arbitrum;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA:return _chains.arbitrumNova;case _commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA:return _chains.modeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.MODE:return _chains.mode;case _commonsdkbase.BlockchainIncludingTestnet.BSC:return _chains.bsc;case _commonsdkbase.BlockchainIncludingTestnet.SHAPE:return _chains.shape;case _commonsdkbase.BlockchainIncludingTestnet.ZORA:return _chains.zora;case _commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA:return _chains.zoraSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA:return _chains.sepolia;case _commonsdkbase.BlockchainIncludingTestnet.FLOW:return _chains.flowMainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET:return _chains.flowTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET:return _chains.plumeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME:return _chains.plume;case _commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET:return _chunkHRUMWG2Fcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO:return _chunkUE3WVHTMcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET:return _chunk5X4EOJFGcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT:case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.APECHAIN:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1:case _commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.CURTIS:case _commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN:case _commonsdkbase.BlockchainIncludingTestnet.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 x(t){return v.includes(t)}function D(t){return H.includes(t)}var Y={[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT]:_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.MODE]:_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.PLUME]:_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_commonsdkbase.BlockchainIncludingTestnet.SCROLL]:_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1]:_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.STORY]:_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN]:_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET};function b(t){return Y[t]}function J(t,a){if(t==="solana"||t==="stellar")return t;let r=t,T=a===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(T&&x(r))throw new (0, _chunkO4FVTK7Xcjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&D(r)){let n=b(r);if(n!=null)return _chunkS4O54O4Ccjs.a.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;_chunkS4O54O4Ccjs.a.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}exports.a = j; exports.b = x; exports.c = D; exports.d = b; exports.e = J;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkU2AHGQVYcjs = require('./chunk-U2AHGQVY.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var b=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],w=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT,_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.MODE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.PLUME,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function Q(t){switch(t){case _commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA:return _chains.baseSepolia;case _commonsdkbase.BlockchainIncludingTestnet.BASE:return _chains.base;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY:return _chains.polygonAmoy;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON:return _chains.polygon;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA:return _chains.optimismSepolia;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM:return _chains.optimism;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA:return _chains.arbitrumSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM:return _chains.arbitrum;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA:return _chains.arbitrumNova;case _commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA:return _chains.modeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.MODE:return _chains.mode;case _commonsdkbase.BlockchainIncludingTestnet.BSC:return _chains.bsc;case _commonsdkbase.BlockchainIncludingTestnet.SHAPE:return _chains.shape;case _commonsdkbase.BlockchainIncludingTestnet.ZORA:return _chains.zora;case _commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA:return _chains.zoraSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA:return _chains.sepolia;case _commonsdkbase.BlockchainIncludingTestnet.FLOW:return _chains.flowMainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET:return _chains.flowTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET:return _chains.plumeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME:return _chains.plume;case _commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET:return _chunkHRUMWG2Fcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO:return _chunkUE3WVHTMcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET:return _chunk5X4EOJFGcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT:case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.APECHAIN:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1:case _commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.CURTIS:case _commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN:case _commonsdkbase.BlockchainIncludingTestnet.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 b.includes(t)}function C(t){return w.includes(t)}var D={[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT]:_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.MODE]:_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.PLUME]:_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_commonsdkbase.BlockchainIncludingTestnet.SCROLL]:_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1]:_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.STORY]:_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN]:_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET};function Y(t){return D[t]}function g(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function X(t,a){if(!g(t))throw new (0, _chunkT3U46LK3cjs.c)(`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===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(T&&I(r))throw new (0, _chunkT3U46LK3cjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=Y(r);if(n!=null)return _chunkU2AHGQVYcjs.a.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;_chunkU2AHGQVYcjs.a.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}exports.a = Q; exports.b = I; exports.c = C; exports.d = Y; exports.e = g; exports.f = X;
@@ -1 +1 @@
1
- import{a as o}from"./chunk-PSXRNSOE.js";import{a as n}from"./chunk-R3EQXI46.js";import{b as p,c as l}from"./chunk-TYFWX53A.js";import{g as t}from"./chunk-J3R36SGJ.js";import{APIKeyEnvironmentPrefix as h,APIKeyUsageOrigin as d,CrossmintApiClient as g}from"@crossmint/common-sdk-base";var c=class extends g{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:l,version:p}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return t(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;n.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let a=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in a?n.error("wallets.api.createWallet.error",{error:a.error,chainType:e.chainType}):"address"in a&&n.info("wallets.api.createWallet.success",{address:a.address,chainType:e.chainType}),a})}getWallet(e){return t(this,null,function*(){n.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?n.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&n.info("wallets.api.getWallet.success",r),r})}createTransaction(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return t(this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return t(this,null,function*(){if(this.environment===h.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}getSigner(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signers/${s}`,{headers:this.headers})).json()})}send(e,s,r){return t(this,null,function*(){n.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?n.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&n.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===d.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};export{c as a};
1
+ import{a as o}from"./chunk-EXC7TCGL.js";import{a as n}from"./chunk-IYRVMHRW.js";import{b as p,c as l}from"./chunk-ZUZCUZSL.js";import{g as t}from"./chunk-J3R36SGJ.js";import{APIKeyEnvironmentPrefix as h,APIKeyUsageOrigin as d,CrossmintApiClient as g}from"@crossmint/common-sdk-base";var c=class extends g{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:l,version:p}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return t(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;n.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let a=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in a?n.error("wallets.api.createWallet.error",{error:a.error,chainType:e.chainType}):"address"in a&&n.info("wallets.api.createWallet.success",{address:a.address,chainType:e.chainType}),a})}getWallet(e){return t(this,null,function*(){n.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?n.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&n.info("wallets.api.getWallet.success",r),r})}createTransaction(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return t(this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),s.status!=null&&r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return t(this,null,function*(){if(this.environment===h.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}getSigner(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signers/${s}`,{headers:this.headers})).json()})}send(e,s,r){return t(this,null,function*(){n.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?n.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&n.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===d.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};export{c as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _clientsignerscryptography = require('@crossmint/client-signers-cryptography');function v(t,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield t.generateKey({address:r}),e=_clientsignerscryptography.decodeBase64.call(void 0, i);if(e.length!==65||e[0]!==4)throw new Error("Invalid uncompressed P-256 public key: expected 65 bytes starting with 0x04");let o=e.slice(1,33),s=e.slice(33,65),y=`0x${_clientsignerscryptography.encodeHex.call(void 0, o)}`,g=`0x${_clientsignerscryptography.encodeHex.call(void 0, s)}`,a=t.getDeviceName();return{type:"device",publicKey:{x:y,y:g},locator:`device:${i}`,name:a}})}exports.a = v;
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-SP2YD44M.js";import{a as r}from"./chunk-R3EQXI46.js";import{g as t}from"./chunk-J3R36SGJ.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-KCOND2E6.js";import{a as r}from"./chunk-IYRVMHRW.js";import{g as t}from"./chunk-J3R36SGJ.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}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkBEW7JDW6cjs = require('./chunk-BEW7JDW6.cjs');var _chunk6MGMZ3SIcjs = require('./chunk-6MGMZ3SI.cjs');var _chunkBFIHTTMMcjs = require('./chunk-BFIHTTMM.cjs');var _chunkO4FVTK7Xcjs = require('./chunk-O4FVTK7X.cjs');var _chunkS4O54O4Ccjs = require('./chunk-S4O54O4C.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunkBEW7JDW6cjs.a{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:_chunkBEW7JDW6cjs.a.getOptions(n),alias:n.alias,recovery:_chunkBEW7JDW6cjs.a.getRecovery(n),signer:n.signer},_chunkBEW7JDW6cjs.a.getApiClient(n))}static from(n){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d,p;_chunkS4O54O4Ccjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return _chunkS4O54O4Ccjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let i={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(l=>new (0, _chunkBFIHTTMMcjs.a)({type:"external-wallet",address:l.publicKey.toString(),locator:`external-wallet:${l.publicKey.toString()}`,onSign:h=>(h.sign([l]),Promise.resolve(h))}))},t=yield this.approveTransactionAndWait(e.id,i);return _chunkS4O54O4Ccjs.a.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:t.hash}),t})}createTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;let e;((t=n.options)==null?void 0:t.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${_chunk6MGMZ3SIcjs.b.call(void 0, n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=_bs582.default.encode(n.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in i)throw new (0, _chunkO4FVTK7Xcjs.r)(JSON.stringify(i));return i})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkS4O54O4Ccjs.a,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;exports.a = S;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkSE7543EVcjs = require('./chunk-SE7543EV.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunk6EZCCLTKcjs = require('./chunk-6EZCCLTK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkU2AHGQVYcjs = require('./chunk-U2AHGQVY.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunkSE7543EVcjs.a{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:_chunkSE7543EVcjs.a.getOptions(n),alias:n.alias,recovery:_chunkSE7543EVcjs.a.getRecovery(n),signer:n.signer},_chunkSE7543EVcjs.a.getApiClient(n))}static from(n){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d,p;_chunkU2AHGQVYcjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return _chunkU2AHGQVYcjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let i={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(l=>new (0, _chunk6EZCCLTKcjs.a)({type:"external-wallet",address:l.publicKey.toString(),locator:`external-wallet:${l.publicKey.toString()}`,onSign:h=>(h.sign([l]),Promise.resolve(h))}))},t=yield this.approveTransactionAndWait(e.id,i);return _chunkU2AHGQVYcjs.a.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:t.hash}),t})}createTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;let e;((t=n.options)==null?void 0:t.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${_chunk3VSFHDFHcjs.b.call(void 0, n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=_bs582.default.encode(n.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in i)throw new (0, _chunkT3U46LK3cjs.t)(JSON.stringify(i));return i})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;exports.a = S;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.0.0-beta.4";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 _chunkJBP52JOHcjs = require('./chunk-JBP52JOH.cjs');var _chunk5QIW67NUcjs = require('./chunk-5QIW67NU.cjs');var _chunkS4O54O4Ccjs = require('./chunk-S4O54O4C.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var f=class{constructor(r){this.config=r;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let r=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:r.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkS4O54O4Ccjs.a.info("TEE connection not initialized, initializing now");let r=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:r.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkS4O54O4Ccjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var u;let r=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 */ }`);_chunkS4O54O4Ccjs.a.info("get-status: sending request");let t=Date.now(),n=yield r.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),e=Date.now()-t;if((n==null?void 0:n.status)!=="success")throw _chunkS4O54O4Ccjs.a.error("get-status: failed",{status:n==null?void 0:n.status,error:n==null?void 0:n.error,durationMs:e}),new Error(n==null?void 0:n.error);if(_chunkS4O54O4Ccjs.a.info("get-status: response received",{signerStatus:n.signerStatus,durationMs:e}),n.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkS4O54O4Ccjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:h,reject:c}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:h,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),i=>this.verifyOtp(i),()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkS4O54O4Ccjs.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(),i=>this.verifyOtp(i),()=>{var i;return(i=this._authPromise)==null?void 0:i.reject(new _chunk5QIW67NUcjs.a)})),c(new _chunk5QIW67NUcjs.a)}))}catch(i){_chunkS4O54O4Ccjs.a.error("handleAuthRequired error",{error:i}),c(i)}try{yield s}catch(i){throw _chunkS4O54O4Ccjs.a.error("handleAuthRequired promise error",{error:i}),i}})}ensureAuthenticated(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let r=this.config.crossmint.jwt;if(r==null)throw new Error("JWT is required");return r}createAuthPromise(){let r,t;return{promise:new Promise((e,s)=>{r=e,t=s}),resolve:r,reject:t}}sendMessageWithOtp(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var h,c;let r=yield this.getTEEConnection(),t=this.getAuthId();_chunkS4O54O4Ccjs.a.info("start-onboarding: sending request");let n=Date.now(),e=yield r.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(h=this.config.crossmint.jwt)!=null?h:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),s=Date.now()-n;if(_chunkS4O54O4Ccjs.a.info("start-onboarding: response received",{status:e==null?void 0:e.status,durationMs:s}),(e==null?void 0:e.status)==="success"&&e.signerStatus==="ready"){this._needsAuth=!1;return}(e==null?void 0:e.status)==="error"&&(_chunkS4O54O4Ccjs.a.error("start-onboarding: failed",{error:e.error}),(c=this._authPromise)==null||c.reject(new Error(e.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,h,c,u;let t;try{let i=yield this.getTEEConnection();_chunkS4O54O4Ccjs.a.info("complete-onboarding: sending request");let E=Date.now();t=yield i.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:r}}},options:d}),_chunkS4O54O4Ccjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(i){throw _chunkS4O54O4Ccjs.a.error("complete-onboarding: error",{error:i}),this._needsAuth=!0,(h=this._authPromise)==null||h.reject(i),i}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(),i=>this.verifyOtp(i),()=>{var i;return(i=this._authPromise)==null?void 0:i.reject(new _chunk5QIW67NUcjs.a)})),(c=this._authPromise)==null||c.resolve();return}_chunkS4O54O4Ccjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let n=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",e=new Error(n);throw(u=this._authPromise)==null||u.reject(e),e})}_exportPrivateKey(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired();let t=this.getJwtOrThrow(),{scheme:n,encoding:e}=this.getChainKeyParams(),s=yield r.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:t,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:e}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkS4O54O4Ccjs.a,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};exports.a = f; exports.b = d;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJBP52JOHcjs = require('./chunk-JBP52JOH.cjs');var _chunk5QIW67NUcjs = require('./chunk-5QIW67NU.cjs');var _chunkU2AHGQVYcjs = require('./chunk-U2AHGQVY.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var f=class{constructor(r){this.config=r;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let r=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:r.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkU2AHGQVYcjs.a.info("TEE connection not initialized, initializing now");let r=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:r.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkU2AHGQVYcjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var u;let r=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 */ }`);_chunkU2AHGQVYcjs.a.info("get-status: sending request");let t=Date.now(),n=yield r.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),e=Date.now()-t;if((n==null?void 0:n.status)!=="success")throw _chunkU2AHGQVYcjs.a.error("get-status: failed",{status:n==null?void 0:n.status,error:n==null?void 0:n.error,durationMs:e}),new Error(n==null?void 0:n.error);if(_chunkU2AHGQVYcjs.a.info("get-status: response received",{signerStatus:n.signerStatus,durationMs:e}),n.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkU2AHGQVYcjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:h,reject:c}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:h,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),i=>this.verifyOtp(i),()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkU2AHGQVYcjs.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(),i=>this.verifyOtp(i),()=>{var i;return(i=this._authPromise)==null?void 0:i.reject(new _chunk5QIW67NUcjs.a)})),c(new _chunk5QIW67NUcjs.a)}))}catch(i){_chunkU2AHGQVYcjs.a.error("handleAuthRequired error",{error:i}),c(i)}try{yield s}catch(i){throw _chunkU2AHGQVYcjs.a.error("handleAuthRequired promise error",{error:i}),i}})}ensureAuthenticated(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let r=this.config.crossmint.jwt;if(r==null)throw new Error("JWT is required");return r}createAuthPromise(){let r,t;return{promise:new Promise((e,s)=>{r=e,t=s}),resolve:r,reject:t}}sendMessageWithOtp(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var h,c;let r=yield this.getTEEConnection(),t=this.getAuthId();_chunkU2AHGQVYcjs.a.info("start-onboarding: sending request");let n=Date.now(),e=yield r.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(h=this.config.crossmint.jwt)!=null?h:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),s=Date.now()-n;if(_chunkU2AHGQVYcjs.a.info("start-onboarding: response received",{status:e==null?void 0:e.status,durationMs:s}),(e==null?void 0:e.status)==="success"&&e.signerStatus==="ready"){this._needsAuth=!1;return}(e==null?void 0:e.status)==="error"&&(_chunkU2AHGQVYcjs.a.error("start-onboarding: failed",{error:e.error}),(c=this._authPromise)==null||c.reject(new Error(e.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,h,c,u;let t;try{let i=yield this.getTEEConnection();_chunkU2AHGQVYcjs.a.info("complete-onboarding: sending request");let E=Date.now();t=yield i.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:r}}},options:d}),_chunkU2AHGQVYcjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(i){throw _chunkU2AHGQVYcjs.a.error("complete-onboarding: error",{error:i}),this._needsAuth=!0,(h=this._authPromise)==null||h.reject(i),i}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(),i=>this.verifyOtp(i),()=>{var i;return(i=this._authPromise)==null?void 0:i.reject(new _chunk5QIW67NUcjs.a)})),(c=this._authPromise)==null||c.resolve();return}_chunkU2AHGQVYcjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let n=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",e=new Error(n);throw(u=this._authPromise)==null||u.reject(e),e})}_exportPrivateKey(r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired();let t=this.getJwtOrThrow(),{scheme:n,encoding:e}=this.getChainKeyParams(),s=yield r.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:t,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:e}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};exports.a = f; exports.b = d;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkYFAJXQAMcjs = require('./chunk-YFAJXQAM.cjs');var _chunkS4O54O4Ccjs = require('./chunk-S4O54O4C.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunkYFAJXQAMcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.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();_chunkS4O54O4Ccjs.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:_chunkYFAJXQAMcjs.b});if(_chunkS4O54O4Ccjs.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 _chunkNJEW3A4Jcjs = require('./chunk-NJEW3A4J.cjs');var _chunkU2AHGQVYcjs = require('./chunk-U2AHGQVY.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunkNJEW3A4Jcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.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();_chunkU2AHGQVYcjs.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:_chunkNJEW3A4Jcjs.b});if(_chunkU2AHGQVYcjs.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 s,b as o}from"./chunk-SP2YD44M.js";import{a as r}from"./chunk-R3EQXI46.js";import{g as t}from"./chunk-J3R36SGJ.js";var a=class g extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();r.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:o});if(r.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"}}};export{a};
1
+ import{a as s,b as o}from"./chunk-KCOND2E6.js";import{a as r}from"./chunk-IYRVMHRW.js";import{g as t}from"./chunk-J3R36SGJ.js";var a=class g extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();r.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:o});if(r.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"}}};export{a};
@@ -0,0 +1 @@
1
+ import{a as d}from"./chunk-OQZTL6ZG.js";import{a as o,b as s}from"./chunk-EM3D5Q3A.js";import{a as n}from"./chunk-XNZLCUTY.js";import{privateKeyToAccount as y}from"viem/accounts";import{bytesToHex as m}from"@noble/hashes/utils";import{Keypair as f}from"@solana/web3.js";function v(r,e){switch(d(e)){case"evm":return y(`0x${m(r)}`).address;case"solana":return f.fromSeed(r).publicKey.toBase58();case"stellar":return o(s(r).publicKey)}}function b(r,e,i,a){if(typeof window!="undefined")throw new Error("Server signers can only be used from server-side code.");let p=typeof e=="string"?e:String(e),t=n(r.secret,i,a,p),c=v(t,e);return{derivedKeyBytes:t,derivedAddress:c}}export{v as a,b};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkZB35EKCScjs = require('./chunk-ZB35EKCS.cjs');var _chunkLZNQBJEKcjs = require('./chunk-LZNQBJEK.cjs');var _chunkITNNPNZLcjs = require('./chunk-ITNNPNZL.cjs');var _chunkU2AHGQVYcjs = require('./chunk-U2AHGQVY.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkU2AHGQVYcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkITNNPNZLcjs.a)(e);this.walletFactory=new (0, _chunkZB35EKCScjs.a)(t),_chunkU2AHGQVYcjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunk2GKPWQBQcjs.g.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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunkLZNQBJEKcjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunk2GKPWQBQcjs.g.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 _chunkYFAJXQAMcjs = require('./chunk-YFAJXQAM.cjs');var _chunkS4O54O4Ccjs = require('./chunk-S4O54O4C.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var a=class g extends _chunkYFAJXQAMcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkS4O54O4Ccjs.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:_chunkYFAJXQAMcjs.b});if(_chunkS4O54O4Ccjs.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 _chunkNJEW3A4Jcjs = require('./chunk-NJEW3A4J.cjs');var _chunkU2AHGQVYcjs = require('./chunk-U2AHGQVY.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var a=class g extends _chunkNJEW3A4Jcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkU2AHGQVYcjs.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:_chunkNJEW3A4Jcjs.b});if(_chunkU2AHGQVYcjs.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;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkLZNQBJEKcjs = require('./chunk-LZNQBJEK.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunk576HP23Hcjs = require('./chunk-576HP23H.cjs');var _chunkKLL2BBSZcjs = require('./chunk-KLL2BBSZ.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkNJEW3A4Jcjs = require('./chunk-NJEW3A4J.cjs');var _chunkL3HSG6Q5cjs = require('./chunk-L3HSG6Q5.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkU2AHGQVYcjs = require('./chunk-U2AHGQVY.cjs');var _chunkN57ARKT3cjs = require('./chunk-N57ARKT3.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var v,y,u,T,$,b,F,R,N,A= exports.a =class{constructor(e,r){_chunk2GKPWQBQcjs.e.call(void 0, this,v);_chunk2GKPWQBQcjs.e.call(void 0, this,y);_chunk2GKPWQBQcjs.e.call(void 0, this,u);_chunk2GKPWQBQcjs.e.call(void 0, this,T);_chunk2GKPWQBQcjs.e.call(void 0, this,$);_chunk2GKPWQBQcjs.e.call(void 0, this,b,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,F,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,R);_chunk2GKPWQBQcjs.e.call(void 0, this,N,null);let{chain:t,address:i,owner:d,options:p,alias:g,recovery:l,signers:s,signer:c}=e;_chunk2GKPWQBQcjs.f.call(void 0, this,u,r),this.chain=t,this.address=i,this.owner=d,_chunk2GKPWQBQcjs.f.call(void 0, this,y,p),this.alias=g,_chunk2GKPWQBQcjs.f.call(void 0, this,T,l),_chunk2GKPWQBQcjs.f.call(void 0, this,$,s!=null?s:[]),_chunk2GKPWQBQcjs.f.call(void 0, this,v,c),_chunk2GKPWQBQcjs.f.call(void 0, this,R,this.initDefaultSigner())}get signer(){return _chunk2GKPWQBQcjs.d.call(void 0, this,v)}initDeviceSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;let e=(i=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:i.deviceSignerKeyStorage;if(e==null||this.chain==="solana")return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(d){_chunkU2AHGQVYcjs.a.error("wallet.initDeviceSigner.error",{error:d}),_chunk2GKPWQBQcjs.f.call(void 0, this,b,!0);return}let t=this.buildInternalSignerConfig(r);_chunk2GKPWQBQcjs.f.call(void 0, this,v,_chunkKLL2BBSZcjs.a.call(void 0, this.chain,t,e))})}initDefaultSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var r,t;if(_chunk2GKPWQBQcjs.d.call(void 0, this,v)!=null||(yield this.initDeviceSigner(),_chunk2GKPWQBQcjs.d.call(void 0, this,v)!=null||_chunk2GKPWQBQcjs.d.call(void 0, this,b)))return;let e=_chunk2GKPWQBQcjs.d.call(void 0, this,$).filter(i=>i.type!=="server"&&i.type!=="api-key");try{if(e.length===0){if(_chunk2GKPWQBQcjs.d.call(void 0, this,T).type!=="server"&&_chunk2GKPWQBQcjs.d.call(void 0, this,T).type!=="api-key"){let i=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,T));_chunk2GKPWQBQcjs.f.call(void 0, this,v,_chunkKLL2BBSZcjs.a.call(void 0, this.chain,i,(r=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:r.deviceSignerKeyStorage))}}else if(e.length===1){let i=this.buildInternalSignerConfig(e[0]);_chunk2GKPWQBQcjs.f.call(void 0, this,v,_chunkKLL2BBSZcjs.a.call(void 0, this.chain,i,(t=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:t.deviceSignerKeyStorage))}}catch(i){}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,T)}get apiClient(){return _chunk2GKPWQBQcjs.d.call(void 0, this,u)}get options(){return _chunk2GKPWQBQcjs.d.call(void 0, this,y)}get recovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,T)}balances(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkU2AHGQVYcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t;switch(this.chain){case"solana":t="sol";break;case"stellar":t="xlm";break;default:t="eth";break}let i=[t,"usdc",...e!=null?e:[]],d=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).getBalance(this.address,{chains:[r],tokens:i});if("error"in d)throw _chunkU2AHGQVYcjs.a.error("wallet.balances.error",{error:d}),new Error(`Failed to get balances for wallet: ${JSON.stringify(d.message)}`);return _chunkU2AHGQVYcjs.a.info("wallet.balances.success"),this.transformBalanceResponse(d,t,e)})}stagingFund(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkU2AHGQVYcjs.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 _chunkU2AHGQVYcjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunkU2AHGQVYcjs.a.info("wallet.stagingFund.success"),t})}transformBalanceResponse(e,r,t){let i=s=>{var S,C,x,D,K;let c=(S=s.chains)==null?void 0:S[this.chain],o={};return this.chain==="solana"&&c!=null&&"mintHash"in c?o={mintHash:c.mintHash}:this.chain==="stellar"&&c!=null&&"contractId"in c?o={contractId:c.contractId}:c!=null&&"contractAddress"in c&&(o={contractAddress:c.contractAddress}),_chunk2GKPWQBQcjs.a.call(void 0, {symbol:(C=s.symbol)!=null?C:"",name:(x=s.name)!=null?x:"",amount:(D=s.amount)!=null?D:"0",decimals:s.decimals,rawAmount:(K=s.rawAmount)!=null?K:"0"},o)},d=e.find(s=>s.symbol===r),p=e.find(s=>s.symbol==="usdc"),g=e.filter(s=>{var c;return s.symbol!==r&&s.symbol!=="usdc"&&(t==null||t.includes((c=s.symbol)!=null?c:""))}),l=s=>{let c={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o={};return this.chain==="solana"?o={mintHash:void 0}:this.chain==="stellar"?o={contractId:void 0}:o={contractAddress:void 0},_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},c),o)};return{nativeToken:d!=null?i(d):l(r),usdc:p!=null?i(p):l("usdc"),tokens:g.map(i)}}nfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).getNfts(_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{chain:this.chain,address:this.address}))})}transactions(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e==null?void 0:e.tokens,status:e==null?void 0:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,i){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let d=this.resolveChainForEnvironment(),p=ce(e),g=de(r,d),l=Number(t);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new (0, _chunkT3U46LK3cjs.s)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);_chunkU2AHGQVYcjs.a.info("wallet.send.start",_chunk2GKPWQBQcjs.a.call(void 0, {recipient:p,token:g,amount:t},(i==null?void 0:i.transactionType)!=null?{transactionType:i.transactionType}:{})),yield this.preAuthIfNeeded();let s=this.requireSigner(),c;(i==null?void 0:i.signer)==null?c=s.locator():typeof i.signer=="string"?c=i.signer:c=`server:${_chunk3VSFHDFHcjs.b.call(void 0, i.signer,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,u).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,u).environment).derivedAddress}`;let o=_chunk2GKPWQBQcjs.a.call(void 0, {recipient:p,amount:t,signer:c},(i==null?void 0:i.transactionType)!=null?{transactionType:i.transactionType}:{}),S=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).send(this.walletLocator,g,o);if("message"in S)throw _chunkU2AHGQVYcjs.a.error("wallet.send.error",{error:S}),new (0, _chunkT3U46LK3cjs.t)(`Failed to send token: ${JSON.stringify(S.message)}`);if((i==null?void 0:i.prepareOnly)===!0)return _chunkU2AHGQVYcjs.a.info("wallet.send.prepared",{transactionId:S.id}),{hash:void 0,explorerLink:void 0,transactionId:S.id};let C=yield this.approveTransactionAndWait(S.id);return _chunkU2AHGQVYcjs.a.info("wallet.send.success",{transactionId:S.id,hash:C.hash}),C})}approveTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.requireSigner(),_chunkU2AHGQVYcjs.a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return _chunkU2AHGQVYcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkU2AHGQVYcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkU2AHGQVYcjs.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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var p,g;_chunkU2AHGQVYcjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?`server:${_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,u).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,u).environment).derivedAddress}`:e,i=this.signer,d=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,T));_chunk2GKPWQBQcjs.f.call(void 0, this,v,_chunkKLL2BBSZcjs.a.call(void 0, this.chain,d,(p=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:p.deviceSignerKeyStorage));try{let l=typeof t=="string"||t.type==="passkey"&&t.id==null?t:t.type==="device"&&"publicKey"in t&&t.publicKey!=null?{type:"device",publicKey:t.publicKey,name:t.name}:_chunkNX256LAHcjs.a.call(void 0, t),s=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).registerSigner(this.walletLocator,{signer:l,chain:this.chain==="solana"||this.chain==="stellar"?void 0:this.chain});if("error"in s)throw _chunkU2AHGQVYcjs.a.error("wallet.addSigner.error",{error:s}),new Error(`Failed to register signer: ${JSON.stringify(s.message)}`);let c=_chunk576HP23Hcjs.b.call(void 0, s,this.chain);if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in s)||s.transaction==null)throw _chunkU2AHGQVYcjs.a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");let o=s.transaction.id;if(c==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);return r!=null&&r.prepareOnly?(_chunkU2AHGQVYcjs.a.info("wallet.addSigner.prepared",{transactionId:o}),_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},c),{transactionId:o})):(yield this.approveTransactionAndWait(o),_chunkU2AHGQVYcjs.a.info("wallet.addSigner.success",{transactionId:o}),_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},c),{status:"success"}))}else{if(!("chains"in s))throw _chunkU2AHGQVYcjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");let o=(g=s.chains)==null?void 0:g[this.chain];if(c==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);if(r!=null&&r.prepareOnly){let S=(o==null?void 0:o.status)!=="success"?o==null?void 0:o.id:void 0;return _chunkU2AHGQVYcjs.a.info("wallet.addSigner.prepared",{signatureId:S}),_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},c),{signatureId:S})}if((o==null?void 0:o.status)==="awaiting-approval")yield this.approveSignatureAndWait(o.id),_chunkU2AHGQVYcjs.a.info("wallet.addSigner.success",{signatureId:o.id});else if((o==null?void 0:o.status)==="pending")yield this.waitForSignature(o.id),_chunkU2AHGQVYcjs.a.info("wallet.addSigner.success",{signatureId:o.id});else{if((o==null?void 0:o.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);_chunkU2AHGQVYcjs.a.info("wallet.addSigner.success")}return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},c),{status:"success"})}}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,v,i)}})}useSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkU2AHGQVYcjs.a.info("wallet.useSigner.start"),this.validateSignerInput(e),e.type==="device"?yield this.resolveDeviceSignerAvailability(e):yield this.resolveNonDeviceSigner(e);let r=this.buildInternalSignerConfig(e),t=_chunkNX256LAHcjs.a.call(void 0, e);_chunk2GKPWQBQcjs.f.call(void 0, this,v,_chunkKLL2BBSZcjs.a.call(void 0, this.chain,r,(i=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:i.deviceSignerKeyStorage)),_chunkU2AHGQVYcjs.a.info("wallet.useSigner.success",{signerLocator:t})})}resolveNonDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e)){_chunk2GKPWQBQcjs.f.call(void 0, this,b,!1);return}throw new Error("No passkey signer is registered on this wallet.")}let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r)){_chunk2GKPWQBQcjs.f.call(void 0, this,b,!1);return}if(this.isRecoverySigner(e)){_chunk2GKPWQBQcjs.f.call(void 0, this,b,!1);return}throw new Error(`Signer "${r}" is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=(yield this.signers()).filter(i=>i.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){if(e.type==="server"){let{derivedAddress:r}=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,u).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,u).environment);return`server:${r}`}return _chunkNX256LAHcjs.a.call(void 0, e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.signers()).some(t=>t.locator===e)})}needsRecovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,b)}recover(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d,p;if(_chunkU2AHGQVYcjs.a.info("wallet.recover.start"),_chunk2GKPWQBQcjs.d.call(void 0, this,v)==null&&(yield this.initDeviceSigner()),((d=_chunk2GKPWQBQcjs.d.call(void 0, this,v))==null?void 0:d.type)!=="device"){_chunkU2AHGQVYcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"});return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,F)){_chunkU2AHGQVYcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}let e=_chunk2GKPWQBQcjs.d.call(void 0, this,v).locator();if(yield this.signerIsRegistered(e)){_chunkU2AHGQVYcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),_chunk2GKPWQBQcjs.f.call(void 0, this,b,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,F,!0);return}let t=(p=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:p.deviceSignerKeyStorage;if(t==null)throw new Error("Device signer key storage is required to recover a device signer");let i=yield _chunkLZNQBJEKcjs.a.call(void 0, t,this.address);try{yield this.addSigner(i)}catch(g){throw _chunkU2AHGQVYcjs.a.error("wallet.recover.device.error",{error:g}),yield t.deleteKey(this.address),g}_chunk2GKPWQBQcjs.f.call(void 0, this,v,_chunkKLL2BBSZcjs.a.call(void 0, this.chain,{type:"device",locator:i.locator,address:this.address},t)),_chunkU2AHGQVYcjs.a.info("wallet.recover.device.success",{signerLocator:i.locator}),_chunk2GKPWQBQcjs.f.call(void 0, this,b,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,F,!0)})}signers(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d,p;_chunkU2AHGQVYcjs.a.info("wallet.signers.start");let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).getWallet(this.walletLocator);if("error"in e)throw _chunkU2AHGQVYcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkT3U46LK3cjs.e)(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw _chunkU2AHGQVYcjs.a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new (0, _chunkT3U46LK3cjs.d)(`Wallet type ${e.type} not supported`);let r=(p=(d=e==null?void 0:e.config)==null?void 0:d.delegatedSigners)!=null?p:[];if(this.chain==="solana"||this.chain==="stellar"){let g=r.map(l=>_chunk576HP23Hcjs.c.call(void 0, l,"success"));return _chunkU2AHGQVYcjs.a.info("wallet.signers.success",{count:g.length}),g}let i=(yield Promise.all(r.map(g=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(g.locator.startsWith("device:"))return _chunk576HP23Hcjs.c.call(void 0, g,"success");try{let l=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).getSigner(this.walletLocator,g.locator);return"error"in l?null:_chunk576HP23Hcjs.b.call(void 0, l,this.chain)}catch(l){return null}})))).filter(g=>g!=null);return _chunkU2AHGQVYcjs.a.info("wallet.signers.success",{count:i.length}),i})}get walletLocator(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,u).isServerSide)return this.address;{let e;switch(this.chain){case"stellar":e="me:stellar:smart";break;case"solana":e="me:solana:smart";break;default:e="me:evm:smart";break}let r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}requireSigner(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,v)==null)throw new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available.");return _chunk2GKPWQBQcjs.d.call(void 0, this,v)}preAuthIfNeeded(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,R),_chunk2GKPWQBQcjs.d.call(void 0, this,N)==null&&_chunk2GKPWQBQcjs.f.call(void 0, this,N,this.recover());try{yield _chunk2GKPWQBQcjs.d.call(void 0, this,N)}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,N,null)}let e=this.requireSigner();e instanceof _chunkNJEW3A4Jcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=_chunk2GKPWQBQcjs.d.call(void 0, this,T);if(r==null||r.type!==e.type||e.type==="device")return!1;if(e.type==="passkey")return!0;if(e.type==="server"&&r.type==="server"){let t=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,u).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,u).environment).derivedAddress,i="address"in r?r.address:null;return i==null?!1:t===i}return _chunkNX256LAHcjs.a.call(void 0, e)===_chunkNX256LAHcjs.a.call(void 0, r)}validateSignerInput(e){switch(e.type){case"email":if(!("email"in e)||e.email==null)throw new Error("Email signer requires an email address");break;case"phone":if(!("phone"in e)||e.phone==null)throw new Error("Phone signer requires a phone number");break;case"external-wallet":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");break;case"passkey":case"device":case"api-key":break;default:break}}resolveDeviceSignerAvailability(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var p;let r=(p=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:p.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let t=yield r.getKey(this.address);if(t!=null){e.locator=`device:${t}`;return}let d=(yield this.signers()).filter(g=>g.locator.startsWith("device:"));for(let g of d){let l=g.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=g.locator;return}}_chunk2GKPWQBQcjs.f.call(void 0, this,b,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,F,!1)})}buildInternalSignerConfig(e){var r,t,i,d,p,g;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,u).crossmint,clientTEEConnection:(r=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:r.clientTEEConnection,onAuthRequired:(i=(t=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:t.callbacks)==null?void 0:i.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,u).crossmint,clientTEEConnection:(d=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:d.clientTEEConnection,onAuthRequired:(g=(p=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:p.callbacks)==null?void 0:g.onAuthRequired};case"passkey":{let l="id"in e&&e.id?e.id:"";return{type:"passkey",id:l,locator:`passkey:${l}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:e.onCreatePasskey,onSignWithPasskey:e.onSignWithPasskey}}case"device":return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:this.address};case"external-wallet":return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{locator:`external-wallet:${e.address}`});case"api-key":return{type:"api-key",locator:"api-key",address:this.address};case"server":{let{derivedKeyBytes:l,derivedAddress:s}=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,u).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,u).environment);return{type:"server",derivedKeyBytes:l,locator:`server:${s}`,address:s}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=_chunkL3HSG6Q5cjs.f.call(void 0, this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,u).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,s;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=this.requireSigner(),i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).getSignature(this.walletLocator,e);if("error"in i)throw new (0, _chunkT3U46LK3cjs.q)(JSON.stringify(i));if(t.type==="api-key")return i;if((r==null?void 0:r.approval)!=null){let c=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,c)}let d=(l=i.approvals)==null?void 0:l.pending;if(d==null)return i;let p=[...(s=r==null?void 0:r.additionalSigners)!=null?s:[],t],g=yield Promise.all(d.map(c=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let o=p.find(C=>C.locator()===c.signer.locator);if(o==null)throw new (0, _chunkT3U46LK3cjs.j)(`Signer ${c.signer.locator} not found in pending approvals`);let S=yield o.signMessage(c.message);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},S),{signer:o.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,s,c,o,S;let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).getTransaction(this.walletLocator,e);if("error"in t)throw new (0, _chunkT3U46LK3cjs.u)(JSON.stringify(t));yield(c=(s=(l=_chunk2GKPWQBQcjs.d.call(void 0, this,y))==null?void 0:l.callbacks)==null?void 0:s.onTransactionStart)==null?void 0:c.call(s);let i=this.requireSigner();if(i.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let C=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,C)}let d=(o=t.approvals)==null?void 0:o.pending;if(d==null)return t;let p=[...(S=r==null?void 0:r.additionalSigners)!=null?S:[],i],g=yield Promise.all(d.map(C=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let x=p.find(le=>le.locator()===C.signer.locator);if(x==null)throw new (0, _chunkT3U46LK3cjs.j)(`Signer ${C.signer.locator} not found in pending approvals`);let D=x.type==="device",K=t.chainType==="solana"&&"transaction"in t.onChain&&!D?t.onChain.transaction:C.message,oe=yield x.signTransaction(K);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},oe),{signer:x.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkU2AHGQVYcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new (0, _chunkT3U46LK3cjs.z)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new (0, _chunkT3U46LK3cjs.r)(JSON.stringify(t));return t})}waitForSignature(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;do if(yield new Promise(t=>setTimeout(t,_chunkN57ARKT3cjs.d)),r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).getSignature(this.walletLocator,e),"error"in r)throw new (0, _chunkT3U46LK3cjs.q)(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new (0, _chunkT3U46LK3cjs.n)("Signature signing failed");if(!r.outputSignature)throw new (0, _chunkT3U46LK3cjs.q)("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(p){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:i=2e3,initialBackoffMs:d=_chunkN57ARKT3cjs.d}={}){var c;_chunkU2AHGQVYcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let g=Date.now(),l;do{if(Date.now()-g>r)throw new (0, _chunkT3U46LK3cjs.v)("Transaction confirmation timeout");if(l=yield _chunk2GKPWQBQcjs.d.call(void 0, this,u).getTransaction(this.walletLocator,e),l.error)throw new (0, _chunkT3U46LK3cjs.u)(JSON.stringify(l));yield this.sleep(d),d=Math.min(d*t,i)}while(l.status==="pending");if(l.status==="failed")throw new (0, _chunkT3U46LK3cjs.w)(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new (0, _chunkT3U46LK3cjs.x)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let s=l.onChain.txId;if(s==null)throw new (0, _chunkT3U46LK3cjs.y)("Transaction hash not found on transaction response");return{hash:s,explorerLink:(c=l.onChain.explorerLink)!=null?c:"",transactionId:l.id}})}sleep(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};v=new WeakMap,y=new WeakMap,u=new WeakMap,T=new WeakMap,$=new WeakMap,b=new WeakMap,F=new WeakMap,R=new WeakMap,N=new WeakMap,_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function ce(w){if(typeof w=="string"){if(!_commonsdkbase.isValidAddress.call(void 0, w))throw new (0, _chunkT3U46LK3cjs.B)(`Invalid recipient address: "${w}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return w}if("email"in w)return`email:${w.email}`;if("x"in w)return`x:${w.x}`;if("twitter"in w)return`twitter:${w.twitter}`;if("phone"in w)return`phoneNumber:${w.phone}`;if("userId"in w)return`userId:${w.userId}`;throw new Error("Invalid recipient locator")}function de(w,e){return _commonsdkbase.isValidAddress.call(void 0, w)?`${e}:${w}`:`${e}:${w.toLowerCase()}`}exports.a = A;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.API_KEY_INVALID,r)}},c= exports.b =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.ENVIRONMENT_INVALID,r)}},p= exports.c =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_CREATION_FAILED,r)}},A= exports.d =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_TYPE_INVALID,r)}},I= exports.e =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_NOT_AVAILABLE,r)}},i= exports.f =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_NOT_AVAILABLE,r)}},x= exports.g =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_CREATION_FAILED,r)}},g= exports.h =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.WALLET_TYPE_INVALID,r)}},u= exports.i =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNER_INVALID,r)}},N= exports.j =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNER_INVALID,r)}},E= exports.k =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.MESSAGE_INVALID,r)}},L= exports.l =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.MESSAGE_INVALID,r)}},_= exports.m =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},T= exports.n =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},l= exports.o =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},a= exports.p =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_SIGNATURE,r)}},d= exports.q =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_SIGNATURE,r)}},D= exports.r =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.SIGNING_FAILED,r)}},S= exports.s =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_TRANSACTION,r)}},O= exports.t =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_TRANSACTION,r)}},R= exports.u =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.NO_TRANSACTION,r)}},C= exports.v =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},G= exports.w =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},F= exports.x =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},V= exports.y =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},W= exports.z =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},P= exports.A =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.TRANSACTION_FAILED,r)}},m= exports.B =class extends _commonsdkbase.CrossmintSDKError{constructor(s,r){super(s,_commonsdkbase.WalletErrorCode.RECIPIENT_ADDRESS_INVALID,r)}};exports.a = o; exports.b = c; exports.c = p; exports.d = A; exports.e = I; exports.f = i; exports.g = x; exports.h = g; exports.i = u; exports.j = N; exports.k = E; exports.l = L; exports.m = _; exports.n = T; exports.o = l; exports.p = a; exports.q = d; exports.r = D; exports.s = S; exports.t = O; exports.u = R; exports.v = C; exports.w = G; exports.x = F; exports.y = V; exports.z = W; exports.A = P; exports.B = m;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkW5EH3HYFcjs = require('./chunk-W5EH3HYF.cjs');var _chunk7VUOD7EIcjs = require('./chunk-7VUOD7EI.cjs');var _chunkRC6KDONJcjs = require('./chunk-RC6KDONJ.cjs');function l(a,e){switch(_chunkENU3EKBGcjs.a.call(void 0, a)){case"evm":return new (0, _chunkW5EH3HYFcjs.a)(e);case"solana":return new (0, _chunk7VUOD7EIcjs.a)(e);case"stellar":return new (0, _chunkRC6KDONJcjs.a)(e)}}exports.a = l;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkW5EH3HYFcjs = require('./chunk-W5EH3HYF.cjs');var _chunk7VUOD7EIcjs = require('./chunk-7VUOD7EI.cjs');var _chunkYF5G4U6Lcjs = require('./chunk-YF5G4U6L.cjs');function l(a,e){switch(_chunkENU3EKBGcjs.a.call(void 0, a)){case"evm":return new (0, _chunkW5EH3HYFcjs.a)(e);case"solana":return new (0, _chunk7VUOD7EIcjs.a)(e);case"stellar":return new (0, _chunkYF5G4U6Lcjs.a)(e)}}exports.a = l;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkU7QSF6P7cjs = require('./chunk-U7QSF6P7.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkU7QSF6P7cjs.c,packageVersion:_chunkU7QSF6P7cjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkN57ARKT3cjs = require('./chunk-N57ARKT3.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkN57ARKT3cjs.c,packageVersion:_chunkN57ARKT3cjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
@@ -1 +1 @@
1
- import{a as s}from"./chunk-2YLRFJ66.js";import{x as a}from"./chunk-PSXRNSOE.js";import{g as e}from"./chunk-J3R36SGJ.js";import{PublicKey as h,VersionedTransaction as f}from"@solana/web3.js";import o from"bs58";var l=class extends s{constructor(n){super(n),this.onSign=n.onSign}signMessage(){return e(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for solana external wallet signer"))})}signTransaction(n){return e(this,null,function*(){if(this.onSign==null)throw new Error("[SolanaExternalWalletSigner] No onSign callback provided. Pass an onSign callback when configuring the external wallet signer.");let c=o.decode(n),g=f.deserialize(c),t=yield this.onSign(g),d=new h(this._address),i=t.message.staticAccountKeys.findIndex(m=>m.equals(d));if(i===-1)throw new a("Wallet public key not found in transaction signers");let r=t.signatures[i];if(r==null)throw new a("No valid signature found in the transaction");let u=new Uint8Array(Object.values(r));return{signature:o.encode(u)}})}};export{l as a};
1
+ import{a as s}from"./chunk-2YLRFJ66.js";import{z as a}from"./chunk-EXC7TCGL.js";import{g as e}from"./chunk-J3R36SGJ.js";import{PublicKey as h,VersionedTransaction as f}from"@solana/web3.js";import o from"bs58";var l=class extends s{constructor(n){super(n),this.onSign=n.onSign}signMessage(){return e(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for solana external wallet signer"))})}signTransaction(n){return e(this,null,function*(){if(this.onSign==null)throw new Error("[SolanaExternalWalletSigner] No onSign callback provided. Pass an onSign callback when configuring the external wallet signer.");let c=o.decode(n),g=f.deserialize(c),t=yield this.onSign(g),d=new h(this._address),i=t.message.staticAccountKeys.findIndex(m=>m.equals(d));if(i===-1)throw new a("Wallet public key not found in transaction signers");let r=t.signatures[i];if(r==null)throw new a("No valid signature found in the transaction");let u=new Uint8Array(Object.values(r));return{signature:o.encode(u)}})}};export{l as a};
@@ -0,0 +1 @@
1
+ import{a as v}from"./chunk-IOSADDL5.js";import{a as l}from"./chunk-IYRVMHRW.js";import{c as d,g as n}from"./chunk-J3R36SGJ.js";import{getEnvironmentForKey as E,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as w}from"ox";var b={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},P=6e4,K="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;let r=E(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=b[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 ${P}ms`))},P);function p(y){let m=y.data;m==null||m.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),m.type==="error"&&m.code===K?s({fatal:!0}):m.type==="error"?o(new Error(m.error)):s({value:m.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 w.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 w.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}};d([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
@@ -1 +1 @@
1
- import{a as S}from"./chunk-G5R6VQGJ.js";import{a as i}from"./chunk-RN77IYDQ.js";import{a as t}from"./chunk-3HLCTEWX.js";import{a as l}from"./chunk-67Z4SJMH.js";import{a as C}from"./chunk-EE4ITUGS.js";import{a as u}from"./chunk-LB4V5KKI.js";import{a as p}from"./chunk-SH7KRBXV.js";import{a as s}from"./chunk-XS5B3TUE.js";import{a as m}from"./chunk-EIHK5TYE.js";import{a as g}from"./chunk-WBIKVPHW.js";import{a as o}from"./chunk-WYMBO52A.js";import{f as a}from"./chunk-PSXRNSOE.js";function V(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new t(e):r==="stellar"?new l(e):new i(e);case"api-key":return r==="solana"?new g(e):new p(e);case"external-wallet":return r==="solana"?new o(e):r==="stellar"?new C(e):new s(e);case"server":return S(r,e);case"passkey":return new m(e);case"device":if(n==null)throw new a("Device signer key storage is required for device signers");return new u(e,n)}}export{V as a};
1
+ import{a as S}from"./chunk-6XY4DLBW.js";import{a as l}from"./chunk-OIYYEGNS.js";import{a as i}from"./chunk-2ITOLYW3.js";import{a as t}from"./chunk-MBFWSNXX.js";import{a as C}from"./chunk-EE4ITUGS.js";import{a as u}from"./chunk-LB4V5KKI.js";import{a as p}from"./chunk-SH7KRBXV.js";import{a as s}from"./chunk-XS5B3TUE.js";import{a as m}from"./chunk-EIHK5TYE.js";import{a as g}from"./chunk-WBIKVPHW.js";import{a as o}from"./chunk-W7LJS32A.js";import{g as a}from"./chunk-EXC7TCGL.js";function V(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new t(e):r==="stellar"?new l(e):new i(e);case"api-key":return r==="solana"?new g(e):new p(e);case"external-wallet":return r==="solana"?new o(e):r==="stellar"?new C(e):new s(e);case"server":return S(r,e);case"passkey":return new m(e);case"device":if(n==null)throw new a("Device signer key storage is required for device signers");return new u(e,n)}}export{V as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5FH7WFWLcjs = require('./chunk-5FH7WFWL.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var a=class{constructor(e){this.type="server";let r=_chunk5FH7WFWLcjs.b.call(void 0, e.derivedKeyBytes);this._address=_chunk5FH7WFWLcjs.a.call(void 0, r.publicKey),this._locator=e.locator,this.secretKey=r.secretKey}address(){return this._address}locator(){return this._locator}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(!/^[A-Za-z0-9+/]*={0,2}$/.test(e))throw new Error("StellarServerSigner.signMessage: expected a base64-encoded string");let r=Buffer.from(e,"base64"),o=_chunk5FH7WFWLcjs.c.call(void 0, r,this.secretKey);return{signature:Buffer.from(o).toString("base64")}})}signTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.signMessage(e)})}};exports.a = a;
@@ -0,0 +1 @@
1
+ import{g as a}from"./chunk-EXC7TCGL.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};
@@ -0,0 +1 @@
1
+ import{a as S,b as w}from"./chunk-YIO5XXQ4.js";import{a as x}from"./chunk-GEN63WDH.js";import{a as b}from"./chunk-6FGJ3ICD.js";import{a as u}from"./chunk-GOXB2RBF.js";import{b as C}from"./chunk-RBSMBO4T.js";import{f as m}from"./chunk-2GXYCJD4.js";import{e as P,g as s}from"./chunk-EXC7TCGL.js";import{a as c}from"./chunk-IYRVMHRW.js";import{a as d,b as y,c as f,g as p}from"./chunk-J3R36SGJ.js";import{WithLoggerContext as R}from"@crossmint/common-sdk-base";import{WebAuthnP256 as $}from"ox";var D="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",h=class{constructor(t){this.apiClient=t}getWallet(t,e){return p(this,null,function*(){let n,a;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new s("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new s("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");n=t,a=e}else{if(this.apiClient.isServerSide)throw new s("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");a=t,n=this.getWalletLocator(a)}let r=y(d({},a),{chain:m(a.chain,this.apiClient.environment)});c.info("walletFactory.getWallet.start");let i=yield this.apiClient.getWallet(n);if("error"in i)throw c.warn("walletFactory.getWallet.notFound",{error:i.error}),new P(JSON.stringify(i));return c.info("walletFactory.getWallet.success",{address:i.address}),yield this.createWalletInstance(i,r)})}createWallet(t){return p(this,null,function*(){var o,l,g,v,W,A,k,F;let e=y(d({},t),{chain:m(t.chain,this.apiClient.environment)});if(yield(g=(l=(o=e.options)==null?void 0:o.callbacks)==null?void 0:l.onWalletCreationStart)==null?void 0:g.call(l),c.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw c.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new s("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let n=((v=e.options)==null?void 0:v.deviceSignerKeyStorage)!=null?this.ensureDeviceSignerInSigners(e):(W=e.signers)!=null?W:[],a=yield this.registerSigners(n,e.chain,(A=e.options)==null?void 0:A.deviceSignerKeyStorage),r;if(e.recovery.type==="passkey"&&e.recovery.id==null)r=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:E}=C(e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);r={type:"server",address:E}}else r=e.recovery;let i=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:d(d({adminSigner:r},e.plugins?{plugins:e.plugins}:{}),a!=null?{delegatedSigners:a}:{}),owner:(k=e.owner)!=null?k:void 0,alias:(F=e.alias)!=null?F:void 0});if("error"in i)throw c.error("walletFactory.createWallet.error",{error:i.error}),new s(JSON.stringify(i));return c.info("walletFactory.createWallet.success",{address:i.address}),yield this.createWalletInstance(i,e)})}createWalletInstance(t,e){var i,o;this.validateExistingWalletConfig(t,e);let n=e,a=t.config.adminSigner,r=((i=n.recovery)==null?void 0:i.type)==="server"?n.recovery:a;return new x({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:r,signers:(o=t.config.delegatedSigners)!=null?o:[]},this.apiClient)}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return p(this,null,function*(){var a;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(a=t.name)!=null?a:`Crossmint Wallet ${Date.now()}`,n=t.onCreatePasskey?yield t.onCreatePasskey(e):yield $.createCredential({name:e});return{type:"passkey",id:n.id,name:e,publicKey:{x:n.publicKey.x.toString(),y:n.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(t){var a,r;if(t.chain==="solana")return(a=t.signers)!=null?a:[];let e=(r=t.signers)!=null?r:[];return e.some(i=>i.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&S(e.owner)!==S(t.owner))throw new s("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&t.chainType!=="solana"||e.chain!=="solana"&&t.chainType==="solana"||e.chain==="stellar"&&t.chainType!=="stellar"||e.chain!=="stellar"&&t.chainType==="stellar")throw new s(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let n=e;if(n.recovery!=null||n.signers!=null){let a=t.config,r=a==null?void 0:a.adminSigner;if(n.recovery!=null&&r!=null){if(n.recovery.type!==r.type)throw new s("The wallet recovery signer type does not match the existing wallet's recovery signer type");w(n.recovery,r)}let i=n.signers;i!=null&&this.validateSigners(t,i,e.chain)}}validateSigners(t,e,n){let a=t.config,r=a==null?void 0:a.delegatedSigners;if(e.length!==0){if(r==null||r.length===0)throw new s(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${D}`);for(let i of e){let o=r.find(l=>{if(this.isMatchingPasskeySigner(i,l,a)||l.type==="device"&&i.type==="device")return!0;if(i.type==="server"){let{derivedAddress:g}=C(i,n,this.apiClient.projectId,this.apiClient.environment);return l.locator===`server:${g}`}return l.locator===u(i)});if(o==null){let l=r.map(g=>g.locator).join(", ");throw new s(`Signer '${i.type}' does not exist in wallet "${t.address}". Available signers: ${l}. ${D}`)}w(i,o)}}}isMatchingPasskeySigner(t,e,n){var r,i;let a=((i=(r=n.delegatedSigners)==null?void 0:r.filter(o=>o.type==="passkey").length)!=null?i:0)+(n.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&a===1)return e.type==="passkey";if(t.id==null&&a>1)throw new s("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,n){return p(this,null,function*(){var a;return yield Promise.all((a=t==null?void 0:t.map(r=>p(this,null,function*(){if(r.type==="passkey")return r.id==null?{signer:yield this.createPasskeySigner(r)}:{signer:r};if(r.type==="device"){if(r.publicKey!=null)return{signer:{type:"device",publicKey:r.publicKey,name:r.name}};if(r.locator!=null)return{signer:r.locator};if(n==null)throw new s("Device signer key storage is required for device signers");let i=yield b(n);return{signer:{type:"device",publicKey:i.publicKey,name:i.name}}}if(r.type==="server"&&e!=null){let{derivedAddress:i}=C(r,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${i}`}}return{signer:u(r)}})))!=null?a:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};f([R({logger:c,methodName:"walletFactory.getWallet",buildContext(t,e){return typeof e[0]=="string"?{walletLocator:e[0],args:e[1]}:{args:e[0]}}})],h.prototype,"getWallet",1),f([R({logger:c,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],h.prototype,"createWallet",1);export{h as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkK5TQ4QU3cjs = require('./chunk-K5TQ4QU3.cjs');var _chunkSE7543EVcjs = require('./chunk-SE7543EV.cjs');var _chunkLZNQBJEKcjs = require('./chunk-LZNQBJEK.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkL3HSG6Q5cjs = require('./chunk-L3HSG6Q5.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkU2AHGQVYcjs = require('./chunk-U2AHGQVY.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var D="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",h= exports.a =class{constructor(t){this.apiClient=t}getWallet(t,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n,a;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunkT3U46LK3cjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunkT3U46LK3cjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");n=t,a=e}else{if(this.apiClient.isServerSide)throw new (0, _chunkT3U46LK3cjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");a=t,n=this.getWalletLocator(a)}let r=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},a),{chain:_chunkL3HSG6Q5cjs.f.call(void 0, a.chain,this.apiClient.environment)});_chunkU2AHGQVYcjs.a.info("walletFactory.getWallet.start");let i=yield this.apiClient.getWallet(n);if("error"in i)throw _chunkU2AHGQVYcjs.a.warn("walletFactory.getWallet.notFound",{error:i.error}),new (0, _chunkT3U46LK3cjs.e)(JSON.stringify(i));return _chunkU2AHGQVYcjs.a.info("walletFactory.getWallet.success",{address:i.address}),yield this.createWalletInstance(i,r)})}createWallet(t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o,l,g,v,W,A,k,F;let e=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{chain:_chunkL3HSG6Q5cjs.f.call(void 0, t.chain,this.apiClient.environment)});if(yield(g=(l=(o=e.options)==null?void 0:o.callbacks)==null?void 0:l.onWalletCreationStart)==null?void 0:g.call(l),_chunkU2AHGQVYcjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunkU2AHGQVYcjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunkT3U46LK3cjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let n=((v=e.options)==null?void 0:v.deviceSignerKeyStorage)!=null?this.ensureDeviceSignerInSigners(e):(W=e.signers)!=null?W:[],a=yield this.registerSigners(n,e.chain,(A=e.options)==null?void 0:A.deviceSignerKeyStorage),r;if(e.recovery.type==="passkey"&&e.recovery.id==null)r=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:E}=_chunk3VSFHDFHcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);r={type:"server",address:E}}else r=e.recovery;let i=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {adminSigner:r},e.plugins?{plugins:e.plugins}:{}),a!=null?{delegatedSigners:a}:{}),owner:(k=e.owner)!=null?k:void 0,alias:(F=e.alias)!=null?F:void 0});if("error"in i)throw _chunkU2AHGQVYcjs.a.error("walletFactory.createWallet.error",{error:i.error}),new (0, _chunkT3U46LK3cjs.g)(JSON.stringify(i));return _chunkU2AHGQVYcjs.a.info("walletFactory.createWallet.success",{address:i.address}),yield this.createWalletInstance(i,e)})}createWalletInstance(t,e){var i,o;this.validateExistingWalletConfig(t,e);let n=e,a=t.config.adminSigner,r=((i=n.recovery)==null?void 0:i.type)==="server"?n.recovery:a;return new (0, _chunkSE7543EVcjs.a)({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:r,signers:(o=t.config.delegatedSigners)!=null?o:[]},this.apiClient)}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(a=t.name)!=null?a:`Crossmint Wallet ${Date.now()}`,n=t.onCreatePasskey?yield t.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:n.id,name:e,publicKey:{x:n.publicKey.x.toString(),y:n.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(t){var a,r;if(t.chain==="solana")return(a=t.signers)!=null?a:[];let e=(r=t.signers)!=null?r:[];return e.some(i=>i.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&_chunkK5TQ4QU3cjs.a.call(void 0, e.owner)!==_chunkK5TQ4QU3cjs.a.call(void 0, t.owner))throw new (0, _chunkT3U46LK3cjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&t.chainType!=="solana"||e.chain!=="solana"&&t.chainType==="solana"||e.chain==="stellar"&&t.chainType!=="stellar"||e.chain!=="stellar"&&t.chainType==="stellar")throw new (0, _chunkT3U46LK3cjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let n=e;if(n.recovery!=null||n.signers!=null){let a=t.config,r=a==null?void 0:a.adminSigner;if(n.recovery!=null&&r!=null){if(n.recovery.type!==r.type)throw new (0, _chunkT3U46LK3cjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkK5TQ4QU3cjs.b.call(void 0, n.recovery,r)}let i=n.signers;i!=null&&this.validateSigners(t,i,e.chain)}}validateSigners(t,e,n){let a=t.config,r=a==null?void 0:a.delegatedSigners;if(e.length!==0){if(r==null||r.length===0)throw new (0, _chunkT3U46LK3cjs.g)(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${D}`);for(let i of e){let o=r.find(l=>{if(this.isMatchingPasskeySigner(i,l,a)||l.type==="device"&&i.type==="device")return!0;if(i.type==="server"){let{derivedAddress:g}=_chunk3VSFHDFHcjs.b.call(void 0, i,n,this.apiClient.projectId,this.apiClient.environment);return l.locator===`server:${g}`}return l.locator===_chunkNX256LAHcjs.a.call(void 0, i)});if(o==null){let l=r.map(g=>g.locator).join(", ");throw new (0, _chunkT3U46LK3cjs.g)(`Signer '${i.type}' does not exist in wallet "${t.address}". Available signers: ${l}. ${D}`)}_chunkK5TQ4QU3cjs.b.call(void 0, i,o)}}}isMatchingPasskeySigner(t,e,n){var r,i;let a=((i=(r=n.delegatedSigners)==null?void 0:r.filter(o=>o.type==="passkey").length)!=null?i:0)+(n.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&a===1)return e.type==="passkey";if(t.id==null&&a>1)throw new (0, _chunkT3U46LK3cjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a;return yield Promise.all((a=t==null?void 0:t.map(r=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(r.type==="passkey")return r.id==null?{signer:yield this.createPasskeySigner(r)}:{signer:r};if(r.type==="device"){if(r.publicKey!=null)return{signer:{type:"device",publicKey:r.publicKey,name:r.name}};if(r.locator!=null)return{signer:r.locator};if(n==null)throw new (0, _chunkT3U46LK3cjs.g)("Device signer key storage is required for device signers");let i=yield _chunkLZNQBJEKcjs.a.call(void 0, n);return{signer:{type:"device",publicKey:i.publicKey,name:i.name}}}if(r.type==="server"&&e!=null){let{derivedAddress:i}=_chunk3VSFHDFHcjs.b.call(void 0, r,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${i}`}}return{signer:_chunkNX256LAHcjs.a.call(void 0, r)}})))!=null?a:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"walletFactory.getWallet",buildContext(t,e){return typeof e[0]=="string"?{walletLocator:e[0],args:e[1]}:{args:e[0]}}})],h.prototype,"getWallet",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkU2AHGQVYcjs.a,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],h.prototype,"createWallet",1);exports.a = h;