@crossmint/wallets-sdk 1.4.0 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/dist/api/__tests__/constants.d.cts +1 -1
  2. package/dist/api/__tests__/constants.d.ts +1 -1
  3. package/dist/api/__tests__/test-utils.cjs +1 -1
  4. package/dist/api/__tests__/test-utils.d.cts +1 -1
  5. package/dist/api/__tests__/test-utils.d.ts +1 -1
  6. package/dist/api/__tests__/test-utils.js +1 -1
  7. package/dist/api/client.cjs +1 -1
  8. package/dist/api/client.d.cts +1 -1
  9. package/dist/api/client.d.ts +1 -1
  10. package/dist/api/client.js +1 -1
  11. package/dist/api/index.cjs +1 -1
  12. package/dist/api/index.d.cts +1 -1
  13. package/dist/api/index.d.ts +1 -1
  14. package/dist/api/index.js +1 -1
  15. package/dist/api/types.d.cts +1 -1
  16. package/dist/api/types.d.ts +1 -1
  17. package/dist/chains/chains.cjs +1 -1
  18. package/dist/chains/chains.d.cts +1 -1
  19. package/dist/chains/chains.d.ts +1 -1
  20. package/dist/chains/chains.js +1 -1
  21. package/dist/chunk-2323NR6Y.js +1 -0
  22. package/dist/{chunk-XEL7JKRY.js → chunk-3LXCIVWG.js} +1 -1
  23. package/dist/{chunk-6HOOT6LH.js → chunk-5DINTXSM.js} +1 -1
  24. package/dist/{chunk-EIRVLXOC.js → chunk-63CDDON3.js} +1 -1
  25. package/dist/{chunk-BAUUDBGT.js → chunk-6G4BWXEJ.js} +1 -1
  26. package/dist/{chunk-XCIS2OND.js → chunk-6TNAINPL.js} +1 -1
  27. package/dist/{chunk-J4XCFNQH.js → chunk-7DFXMYKM.js} +1 -1
  28. package/dist/{chunk-JFG54X5X.cjs → chunk-7M7XEKZE.cjs} +1 -1
  29. package/dist/chunk-AGN3B4GS.cjs +1 -0
  30. package/dist/{chunk-SI4L3UZ4.cjs → chunk-AJVO7VQY.cjs} +1 -1
  31. package/dist/{chunk-4GHTG2VD.js → chunk-BUC3VNP4.js} +1 -1
  32. package/dist/{chunk-UBDPBFAR.js → chunk-CHX7PG2J.js} +1 -1
  33. package/dist/chunk-EHMQ5WD7.cjs +1 -0
  34. package/dist/{chunk-ZH3WV7OE.js → chunk-EZOZZFCU.js} +1 -1
  35. package/dist/chunk-FLYEGDDE.js +3 -0
  36. package/dist/{chunk-BTMBO7VM.cjs → chunk-HF4IRNP6.cjs} +2 -2
  37. package/dist/{chunk-RWQ6ZQST.js → chunk-HVBMGZ2A.js} +1 -1
  38. package/dist/{chunk-F2HEHICC.cjs → chunk-N3P3SQ33.cjs} +1 -1
  39. package/dist/{chunk-A3J3367O.cjs → chunk-N7GVWKC7.cjs} +1 -1
  40. package/dist/{chunk-RLBY6JO3.cjs → chunk-OIEGMYEU.cjs} +1 -1
  41. package/dist/{chunk-PG7BGWKX.js → chunk-OWGOD5IM.js} +1 -1
  42. package/dist/{chunk-WUNTNM5R.cjs → chunk-OY2LMC4Y.cjs} +1 -1
  43. package/dist/{chunk-BI3AUJVK.cjs → chunk-PIJQUMGJ.cjs} +1 -1
  44. package/dist/chunk-PYIURK5B.js +1 -0
  45. package/dist/chunk-QJ54STYO.js +1 -0
  46. package/dist/chunk-RMXZH6CG.js +1 -0
  47. package/dist/chunk-SDVBLX5J.cjs +1 -0
  48. package/dist/{chunk-4GEG5JA6.js → chunk-SGGIB3UV.js} +1 -1
  49. package/dist/{chunk-4LXI2OQW.cjs → chunk-TENHJ7EH.cjs} +1 -1
  50. package/dist/{chunk-X7E2YEIV.cjs → chunk-TQCD2GOR.cjs} +1 -1
  51. package/dist/{chunk-KW2623VI.cjs → chunk-X6TSCK75.cjs} +1 -1
  52. package/dist/{chunk-CFB27BFV.cjs → chunk-XDHGCS4W.cjs} +1 -1
  53. package/dist/{chunk-AET7QPSV.cjs → chunk-YWTJTAIU.cjs} +1 -1
  54. package/dist/{chunk-52I473WC.cjs → chunk-ZAAS2UOD.cjs} +1 -1
  55. package/dist/index.cjs +1 -1
  56. package/dist/index.d.cts +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.js +1 -1
  59. package/dist/logger/index.cjs +1 -1
  60. package/dist/logger/index.js +1 -1
  61. package/dist/logger/init.cjs +1 -1
  62. package/dist/logger/init.js +1 -1
  63. package/dist/sdk.cjs +1 -1
  64. package/dist/sdk.d.cts +1 -1
  65. package/dist/sdk.d.ts +1 -1
  66. package/dist/sdk.js +1 -1
  67. package/dist/signers/device.d.cts +1 -1
  68. package/dist/signers/device.d.ts +1 -1
  69. package/dist/signers/evm-api-key.d.cts +1 -1
  70. package/dist/signers/evm-api-key.d.ts +1 -1
  71. package/dist/signers/evm-external-wallet.d.cts +1 -1
  72. package/dist/signers/evm-external-wallet.d.ts +1 -1
  73. package/dist/signers/external-wallet-signer.d.cts +1 -1
  74. package/dist/signers/external-wallet-signer.d.ts +1 -1
  75. package/dist/signers/index.cjs +1 -1
  76. package/dist/signers/index.d.cts +1 -1
  77. package/dist/signers/index.d.ts +1 -1
  78. package/dist/signers/index.js +1 -1
  79. package/dist/signers/non-custodial/index.cjs +1 -1
  80. package/dist/signers/non-custodial/index.d.cts +1 -1
  81. package/dist/signers/non-custodial/index.d.ts +1 -1
  82. package/dist/signers/non-custodial/index.js +1 -1
  83. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  84. package/dist/signers/non-custodial/ncs-evm-signer.d.cts +1 -1
  85. package/dist/signers/non-custodial/ncs-evm-signer.d.ts +1 -1
  86. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  87. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  88. package/dist/signers/non-custodial/ncs-signer.d.cts +1 -1
  89. package/dist/signers/non-custodial/ncs-signer.d.ts +1 -1
  90. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  91. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  92. package/dist/signers/non-custodial/ncs-solana-signer.d.cts +1 -1
  93. package/dist/signers/non-custodial/ncs-solana-signer.d.ts +1 -1
  94. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  95. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  96. package/dist/signers/non-custodial/ncs-stellar-signer.d.cts +1 -1
  97. package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +1 -1
  98. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  99. package/dist/signers/passkey.d.cts +1 -1
  100. package/dist/signers/passkey.d.ts +1 -1
  101. package/dist/signers/server/assemble-server-signer.d.cts +1 -1
  102. package/dist/signers/server/assemble-server-signer.d.ts +1 -1
  103. package/dist/signers/server/evm-server-signer.d.cts +1 -1
  104. package/dist/signers/server/evm-server-signer.d.ts +1 -1
  105. package/dist/signers/server/helpers/derive-server-signer.d.cts +1 -1
  106. package/dist/signers/server/helpers/derive-server-signer.d.ts +1 -1
  107. package/dist/signers/server/helpers/index.d.cts +1 -1
  108. package/dist/signers/server/helpers/index.d.ts +1 -1
  109. package/dist/signers/server/index.d.cts +1 -1
  110. package/dist/signers/server/index.d.ts +1 -1
  111. package/dist/signers/server/solana-server-signer.d.cts +1 -1
  112. package/dist/signers/server/solana-server-signer.d.ts +1 -1
  113. package/dist/signers/server/stellar-server-signer.d.cts +1 -1
  114. package/dist/signers/server/stellar-server-signer.d.ts +1 -1
  115. package/dist/signers/solana-api-key.d.cts +1 -1
  116. package/dist/signers/solana-api-key.d.ts +1 -1
  117. package/dist/signers/solana-external-wallet.d.cts +1 -1
  118. package/dist/signers/solana-external-wallet.d.ts +1 -1
  119. package/dist/signers/stellar-external-wallet.d.cts +1 -1
  120. package/dist/signers/stellar-external-wallet.d.ts +1 -1
  121. package/dist/signers/types.cjs +1 -1
  122. package/dist/signers/types.d.cts +1 -1
  123. package/dist/signers/types.d.ts +1 -1
  124. package/dist/signers/types.js +1 -1
  125. package/dist/{types-CRMCeDuN.d.ts → types-Br5La8FI.d.ts} +5 -1
  126. package/dist/{types-5kZcVs3E.d.cts → types-Cc0Mr7mS.d.cts} +5 -1
  127. package/dist/utils/constants.cjs +1 -1
  128. package/dist/utils/constants.js +1 -1
  129. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  130. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  131. package/dist/utils/device-signers/createDeviceSigner.d.cts +1 -1
  132. package/dist/utils/device-signers/createDeviceSigner.d.ts +1 -1
  133. package/dist/utils/device-signers/index.cjs +1 -1
  134. package/dist/utils/device-signers/index.d.cts +1 -1
  135. package/dist/utils/device-signers/index.d.ts +1 -1
  136. package/dist/utils/device-signers/index.js +1 -1
  137. package/dist/utils/signer-locator.d.cts +1 -1
  138. package/dist/utils/signer-locator.d.ts +1 -1
  139. package/dist/utils/signer-mapping.d.cts +1 -1
  140. package/dist/utils/signer-mapping.d.ts +1 -1
  141. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  142. package/dist/wallets/__tests__/test-helpers.d.cts +1 -1
  143. package/dist/wallets/__tests__/test-helpers.d.ts +1 -1
  144. package/dist/wallets/__tests__/test-helpers.js +1 -1
  145. package/dist/wallets/evm.cjs +1 -1
  146. package/dist/wallets/evm.d.cts +1 -1
  147. package/dist/wallets/evm.d.ts +1 -1
  148. package/dist/wallets/evm.js +1 -1
  149. package/dist/wallets/solana.cjs +1 -1
  150. package/dist/wallets/solana.d.cts +1 -1
  151. package/dist/wallets/solana.d.ts +1 -1
  152. package/dist/wallets/solana.js +1 -1
  153. package/dist/wallets/stellar.cjs +1 -1
  154. package/dist/wallets/stellar.d.cts +1 -1
  155. package/dist/wallets/stellar.d.ts +1 -1
  156. package/dist/wallets/stellar.js +1 -1
  157. package/dist/wallets/types.d.cts +1 -1
  158. package/dist/wallets/types.d.ts +1 -1
  159. package/dist/wallets/wallet-factory.cjs +1 -1
  160. package/dist/wallets/wallet-factory.d.cts +1 -1
  161. package/dist/wallets/wallet-factory.d.ts +1 -1
  162. package/dist/wallets/wallet-factory.js +1 -1
  163. package/dist/wallets/wallet.cjs +1 -1
  164. package/dist/wallets/wallet.d.cts +1 -1
  165. package/dist/wallets/wallet.d.ts +1 -1
  166. package/dist/wallets/wallet.js +1 -1
  167. package/package.json +2 -2
  168. package/dist/chunk-6RX65NOA.js +0 -1
  169. package/dist/chunk-AAUS7KTR.cjs +0 -1
  170. package/dist/chunk-AS2YN2YC.cjs +0 -1
  171. package/dist/chunk-FXCUVWXJ.js +0 -1
  172. package/dist/chunk-QQ46JY33.js +0 -1
  173. package/dist/chunk-XX6FO5QS.js +0 -1
  174. package/dist/chunk-YSB7XIS7.js +0 -3
  175. package/dist/chunk-YYFLQQPV.cjs +0 -1
@@ -0,0 +1,3 @@
1
+ import{a as pe}from"./chunk-N4IWDL6M.js";import{a as N}from"./chunk-GOXB2RBF.js";import{b as j,c as z}from"./chunk-KZMDZJGM.js";import{a as q}from"./chunk-63CDDON3.js";import{c as he}from"./chunk-F5NTM2RX.js";import{a as ue}from"./chunk-QJ54STYO.js";import{a as ge,b as Y,c as W}from"./chunk-PYIURK5B.js";import{f as de}from"./chunk-RMXZH6CG.js";import{A as oe,B as le,D as ce,d as Q,e as X,j as _,k as Z,l as V,p as ee,s as G,t as re,u as ie,v as te,w as M,x as ne,y as se,z as ae}from"./chunk-5OYPWGMX.js";import{a}from"./chunk-CHX7PG2J.js";import{d as U}from"./chunk-2323NR6Y.js";import{a as b,b as O,c as k,d as n,e as T,f as c,g as d}from"./chunk-J3R36SGJ.js";import{isValidAddress as Se,WithLoggerContext as P}from"@crossmint/common-sdk-base";var p,A,f,v,R,w,I,x,L,$,K,D,B,E=class{constructor(e,r){T(this,p);T(this,A);T(this,f);T(this,v);T(this,R);T(this,w,!1);T(this,I,!1);T(this,x,null);T(this,L,null);T(this,$,[]);T(this,K);T(this,D,null);T(this,B,!1);let{chain:i,address:t,owner:o,options:h,alias:s,recovery:l,apiRecoveryServerSignerAddress:g,apiDelegatedServerSignerAddresses:u,signers:S,signer:y}=e;c(this,f,r),this.chain=i,this.address=t,this.owner=o,c(this,A,h),this.alias=s,c(this,v,l),g!=null?c(this,L,g):l.type==="server"&&W(l)&&c(this,L,l.address),c(this,$,u!=null?u:[]),c(this,R,S!=null?S:[]),c(this,p,y),c(this,K,this.initDefaultSigner())}get signer(){return n(this,p)}waitForInit(){return d(this,null,function*(){yield n(this,K)})}initDeviceSigner(){return d(this,null,function*(){var t;let e=(t=n(this,A))==null?void 0:t.deviceSignerKeyStorage;if(e==null||n(this,B))return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(o){a.error("wallet.initDeviceSigner.error",{error:o}),c(this,w,!0);return}if(n(this,w))return;let i=this.buildInternalSignerConfig(r);c(this,p,yield this.assembleFullSigner(i,e)),this.isApprovedSignerStatus(n(this,p).status)||(a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:n(this,p).locator(),status:n(this,p).status}),c(this,w,!0),c(this,I,!1))})}initDefaultSigner(){return d(this,null,function*(){if(n(this,p)!=null||(yield this.initDeviceSigner(),n(this,p)!=null||n(this,w)))return;let e=n(this,R).length===0?n(this,v):n(this,R).length===1?n(this,R)[0]:null;if(e==null||!this.isAutoAssemblableSignerConfig(e))return;let r=e===n(this,v);try{let i=this.buildInternalSignerConfig(e);c(this,p,yield this.assembleFullSigner(i,void 0,{isAdminSigner:r}))}catch(i){a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:n(this,v).type,signerCount:n(this,R).length,error:i})}})}assembleRecoverySignerFallback(){return d(this,null,function*(){if(this.isAutoAssemblableSignerConfig(n(this,v)))try{let e=this.buildInternalSignerConfig(n(this,v));c(this,p,yield this.assembleFullSigner(e,void 0,{isAdminSigner:!0}))}catch(e){a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:n(this,v).type,error:e})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return n(e,v)}static getInitialSigners(e){return n(e,R)}static getApiRecoveryServerSignerAddress(e){var r;return(r=n(e,L))!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return n(e,$)}get apiClient(){return n(this,f)}get options(){return n(this,A)}deriveServerSignerCandidates(e){return he(e,this.chain,n(this,f).projectId,n(this,f).environment)}matchResolvedServerSigner(e){if(n(this,x)==null)return null;let{primary:r,legacy:i}=this.deriveServerSignerCandidates(e),t=n(this,x).derivedAddress;return t===r.derivedAddress||i!=null&&t===i.derivedAddress?n(this,x):null}resolveServerSignerDerivation(e){let r=this.matchResolvedServerSigner(e);if(r!=null)return r;let{primary:i,legacy:t}=this.deriveServerSignerCandidates(e);return t!=null&&(t.derivedAddress===n(this,L)||n(this,R).some(o=>o.type==="server"&&W(o)&&o.address===t.derivedAddress)||n(this,$).includes(t.derivedAddress))?t:i}resolveServerSignerApiLocator(e){return`server:${this.resolveServerSignerDerivation(e).derivedAddress}`}get recovery(){return n(this,v)}balances(e){return d(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),i;switch(this.chain){case"solana":i="sol";break;case"stellar":i="xlm";break;default:i="eth";break}let t=[i,"usdc",...e!=null?e:[]],o=yield n(this,f).getBalance(this.address,{chains:[r],tokens:t});if("error"in o)throw a.error("wallet.balances.error",{error:o}),new Error(`Failed to get balances for wallet: ${JSON.stringify(o.message)}`);return a.info("wallet.balances.success"),this.transformBalanceResponse(o,i,e)})}stagingFund(e,r){return d(this,null,function*(){a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let i=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in i)throw a.error("wallet.stagingFund.error",{error:i}),new Error(`Failed to fund wallet: ${JSON.stringify(i.message)}`);return a.info("wallet.stagingFund.success"),i})}transformBalanceResponse(e,r,i){let t=g=>{var y,C,F,H,J;let u=(y=g.chains)==null?void 0:y[this.chain],S={};return this.chain==="solana"&&u!=null&&"mintHash"in u?S={mintHash:u.mintHash}:this.chain==="stellar"&&u!=null&&"contractId"in u?S={contractId:u.contractId}:u!=null&&"contractAddress"in u&&(S={contractAddress:u.contractAddress}),b({symbol:(C=g.symbol)!=null?C:"",name:(F=g.name)!=null?F:"",amount:(H=g.amount)!=null?H:"0",decimals:g.decimals,rawAmount:(J=g.rawAmount)!=null?J:"0"},S)},o=e.find(g=>g.symbol===r),h=e.find(g=>g.symbol==="usdc"),s=e.filter(g=>{var u;return g.symbol!==r&&g.symbol!=="usdc"&&(i==null||i.includes((u=g.symbol)!=null?u:""))}),l=g=>{let u={symbol:g,name:g,amount:"0",decimals:0,rawAmount:"0"},S={};return this.chain==="solana"?S={mintHash:void 0}:this.chain==="stellar"?S={contractId:void 0}:S={contractAddress:void 0},b(b({},u),S)};return{nativeToken:o!=null?t(o):l(r),usdc:h!=null?t(h):l("usdc"),tokens:s.map(t)}}nfts(e){return d(this,null,function*(){return yield n(this,f).getNfts(O(b({},e),{chain:this.chain,address:this.address}))})}transactions(){return d(this,null,function*(){let e=yield n(this,f).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return d(this,null,function*(){let r=yield n(this,f).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return d(this,null,function*(){let r=this.resolveChainForEnvironment(),i=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in i)throw new Error(`Failed to get transfers: ${JSON.stringify(i.message)}`);return i})}send(e,r,i,t){return d(this,null,function*(){let o=this.resolveChainForEnvironment(),h=we(e),s=ye(r,o),l=Number(i);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new ie(`Invalid transfer amount: "${i}". Amount must be a positive number greater than zero.`);a.info("wallet.send.start",b({recipient:h,token:s,amount:i},(t==null?void 0:t.transactionType)!=null?{transactionType:t.transactionType}:{})),yield this.preAuthIfNeeded();let g=this.requireSigner(),u;(t==null?void 0:t.signer)==null?u=g.locator():typeof t.signer=="string"?u=t.signer:u=this.resolveServerSignerApiLocator(t.signer);let S=b({recipient:h,amount:i,signer:u},(t==null?void 0:t.transactionType)!=null?{transactionType:t.transactionType}:{}),y=yield n(this,f).send(this.walletLocator,s,S);if("message"in y)throw a.error("wallet.send.error",{error:y}),new te(`Failed to send token: ${JSON.stringify(y.message)}`);if((t==null?void 0:t.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:y.id}),{hash:void 0,explorerLink:void 0,transactionId:y.id};let C=yield this.approveTransactionAndWait(y.id);return a.info("wallet.send.success",{transactionId:y.id,hash:C.hash}),C})}approveTransaction(e){return d(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 d(this,null,function*(){if(a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return d(this,null,function*(){a.info("wallet.addSigner.start");let i=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return this.withRecoverySigner(()=>d(this,null,function*(){var u,S;let t=typeof i=="string"?i:N(i),o=yield this.getSignerState(t);if(o.signer!=null){if(this.isApprovedSignerStatus(o.signer.status))return a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(o.signer,null,r);if(o.pendingOperation!=null)return a.info("wallet.addSigner.resuming",{operationType:o.pendingOperation.type,operationId:o.pendingOperation.id}),this.completeSignerRegistration(o.signer,o.pendingOperation,r)}let h=typeof i=="string"||i.type==="passkey"?i:i.type==="device"&&"publicKey"in i&&i.publicKey!=null?{type:"device",publicKey:i.publicKey,name:i.name}:N(i),s=yield n(this,f).registerSigner(this.walletLocator,b({signer:h,chain:this.getSignerRegistrationChain()},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}));if("error"in s)throw a.error("wallet.addSigner.error",{error:s}),s.code===Z?new V(s.message):new _(`Failed to register signer: ${JSON.stringify(s.message)}`);let l=j(s,this.chain);if(l==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let g=null;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");g={type:"transaction",id:s.transaction.id}}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");if(((S=(u=s.chains)==null?void 0:u[this.chain])==null?void 0:S.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);g=z(s,this.chain)}return this.completeSignerRegistration(l,g,r)}))})}completeSignerRegistration(e,r,i){return d(this,null,function*(){if(i!=null&&i.prepareOnly){if(r==null)return b({},e);switch(r.type){case"transaction":{let t={transactionId:r.id};return a.info("wallet.addSigner.prepared",t),b(b({},e),t)}case"signature":{let t={signatureId:r.id};return a.info("wallet.addSigner.prepared",t),b(b({},e),t)}default:{let t=r.type;throw new Error(`Unknown pending operation type: ${t}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let t=r.type;throw new Error(`Unknown pending operation type: ${t}`)}}else a.info("wallet.addSigner.success");return O(b({},e),{status:"success"})})}removeSigner(e,r){return d(this,null,function*(){let i=this.resolveSignerLocator(e);return a.info("wallet.removeSigner.start",{signerLocator:i}),this.withRecoverySigner(()=>d(this,null,function*(){let t=yield n(this,f).removeSigner(this.walletLocator,i,{chain:this.getSignerRegistrationChain()});if("error"in t)throw a.error("wallet.removeSigner.error",{error:t}),new Error(`Failed to remove signer: ${JSON.stringify(t)}`);let o=t.id;return r!=null&&r.prepareOnly?(a.info("wallet.removeSigner.prepared",{transactionId:o}),{transactionId:o,status:void 0}):(yield this.approveTransactionAndWait(o),a.info("wallet.removeSigner.success",{transactionId:o}),{transactionId:o,status:"success"})}))})}useSigner(e){return d(this,null,function*(){a.info("wallet.useSigner.start"),e.type==="server"&&c(this,x,null),this.validateSignerInput(e);let r=!1;e.type==="device"?yield this.resolveDeviceSignerAvailability(e):r=yield this.resolveNonDeviceSigner(e);let i=this.buildInternalSignerConfig(e),t=N(e);c(this,p,yield this.assembleFullSigner(i,void 0,{isAdminSigner:r})),a.info("wallet.useSigner.success",{signerLocator:t})})}resolveNonDeviceSigner(e){return d(this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return c(this,w,!1),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return c(this,w,!1),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return c(this,w,!1),!1;if(this.isRecoverySigner(e))return c(this,w,!1),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return d(this,null,function*(){let{primary:r,legacy:i}=this.deriveServerSignerCandidates(e),t=yield this.signers();if(t.some(h=>h.locator===`server:${r.derivedAddress}`))return c(this,x,r),c(this,w,!1),!1;if(i!=null&&t.some(h=>h.locator===`server:${i.derivedAddress}`))return c(this,x,i),c(this,w,!1),!1;if(this.isRecoverySigner(e))return n(this,L)!=null&&i!=null&&i.derivedAddress===n(this,L)?c(this,x,i):c(this,x,r),c(this,w,!1),!0;let o=i!=null?`"server:${r.derivedAddress}" or "server:${i.derivedAddress}"`:`"server:${r.derivedAddress}"`;throw new Error(`Signer ${o} is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return d(this,null,function*(){let i=(yield this.signers()).filter(t=>t.type==="passkey");if(i.length===0)return!1;if(i.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=i[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):N(e)}getSignerRegistrationChain(){if(!(this.chain==="solana"||this.chain==="stellar"))return this.chain}withRecoverySigner(e){return d(this,null,function*(){var t;let r=this.signer;if(W(n(this,v)))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(n(this,v)!=null&&n(this,v).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(n(this,v)))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let i=this.buildInternalSignerConfig(n(this,v));c(this,p,q(this.chain,i,(t=n(this,A))==null?void 0:t.deviceSignerKeyStorage));try{return yield e()}finally{c(this,p,r)}})}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return d(this,null,function*(){return(yield this.signers()).some(i=>i.locator===e)})}isSignerApproved(e){return d(this,null,function*(){var i;let r=yield this.getSignerState(e);return this.isApprovedSignerStatus((i=r.signer)==null?void 0:i.status)})}isApprovedSignerStatus(e){return e==="success"||e==="active"}needsRecovery(){return n(this,w)}recover(){return d(this,null,function*(){var o,h;if(a.info("wallet.recover.start"),n(this,I)){a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(n(this,B)){a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),c(this,w,!1),c(this,I,!0);return}let e=()=>{c(this,w,!1),c(this,I,!0)};if(((o=n(this,p))==null?void 0:o.type)==="device"&&(yield this.checkAndResumeDeviceSigner(n(this,p)))){e();return}if(n(this,p)!=null&&n(this,p).type!=="device"){a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),c(this,w,!1);return}let r=(h=n(this,A))==null?void 0:h.deviceSignerKeyStorage;if(r==null){if(!n(this,w))return;throw new Error("Device signer key storage is required to recover a device signer")}let i=yield this.findLocalDeviceSigner(r);if(i!=null&&(yield this.checkAndResumeDeviceSigner(i))){c(this,p,i),e();let s=i.locator().replace("device:","");try{yield r.mapAddressToKey(this.address,s)}catch(l){a.warn("wallet.recover.mapAddressToKey.error",{error:l})}return}let t=yield pe(r,this.address);try{yield this.addSigner(t)}catch(s){let l=s instanceof Error&&s.message.toLowerCase().includes("delegated signer")&&s.message.toLowerCase().includes("already")&&s.message.toLowerCase().includes("approved");if(s instanceof V){a.info("wallet.recover.device.unsupportedFallback",{signerLocator:t.locator}),yield r.deleteKey(this.address),c(this,B,!0),c(this,w,!1),c(this,I,!0),yield this.assembleRecoverySignerFallback();return}else if(l)a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:t.locator});else throw s instanceof ge||s instanceof Error&&s.name==="AuthRejectedError"?(a.info("wallet.recover.device.authRejected",{signerLocator:t.locator}),s):s instanceof Y||s instanceof Error&&s.name==="OtpValidationError"?(a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:t.locator,code:s instanceof Y?s.code:void 0}),s):(a.error("wallet.recover.device.error",{error:s}),yield r.deleteKey(this.address),s)}c(this,p,yield this.assembleFullSigner({type:"device",locator:t.locator,address:this.address},r)),n(this,p).type==="device"&&(n(this,p).status="success"),a.info("wallet.recover.device.success",{signerLocator:t.locator}),e()})}checkAndResumeDeviceSigner(e){return d(this,null,function*(){var i;if(this.isApprovedSignerStatus(e.status))return a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let r=yield this.getSignerState(e.locator());return e.status=(i=r.signer)==null?void 0:i.status,r.pendingOperation!=null?(yield this.resumePendingDeviceSignerApproval(e,r.pendingOperation),!0):this.isApprovedSignerStatus(e.status)?(a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})}resumePendingDeviceSignerApproval(e,r){return d(this,null,function*(){var o;let i=n(this,p);if(W(n(this,v)))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(n(this,v)!=null&&n(this,v).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(n(this,v)))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let t=this.buildInternalSignerConfig(n(this,v));c(this,p,q(this.chain,t,(o=n(this,A))==null?void 0:o.deviceSignerKeyStorage));try{r.type==="signature"?yield this.approveSignatureAndWait(r.id):yield this.approveTransactionAndWait(r.id)}catch(h){throw c(this,p,e),h}finally{n(this,p)!==e&&c(this,p,i)}e.status="success",a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0})})}findLocalDeviceSigner(e){return d(this,null,function*(){let i=(yield this.signers()).filter(t=>t.locator.startsWith("device:"));for(let t of i){let o=t.locator.replace("device:","");try{if(yield e.hasKey(o)){let s=q(this.chain,{type:"device",locator:t.locator,address:this.address},e);return a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),s}}catch(h){a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:t.locator,error:h})}}return null})}signers(){return d(this,null,function*(){var o,h;a.info("wallet.signers.start");let e=yield n(this,f).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new X(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 Q(`Wallet type ${e.type} not supported`);let r=(h=(o=e==null?void 0:e.config)==null?void 0:o.delegatedSigners)!=null?h:[],t=(yield Promise.all(r.map(s=>d(this,null,function*(){try{return(yield this.getSignerState(s.locator)).signer}catch(l){return null}})))).filter(s=>s!=null);return a.info("wallet.signers.success",{count:t.length}),t})}get walletLocator(){if(n(this,f).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,p)==null)throw n(this,R).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):n(this,v).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
2
+ Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`):n(this,v).type==="external-wallet"||!this.isAutoAssemblableSignerConfig(n(this,v))?new Error(`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
3
+ Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`):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,p)}preAuthIfNeeded(){return d(this,null,function*(){yield n(this,K),n(this,D)==null&&c(this,D,this.recover());try{yield n(this,D)}finally{c(this,D,null)}let e=this.requireSigner();e instanceof ue&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=n(this,v);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 i=s=>{if(W(s))return[s.address];let{primary:l,legacy:g}=this.deriveServerSignerCandidates(s),u=[l.derivedAddress];return g!=null&&u.push(g.derivedAddress),u},t=i(e),o=i(r);if(!t.some(s=>o.includes(s)))return!1}else if(N(e)!==N(r))return!1;return c(this,v,e),!0}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 d(this,null,function*(){var h;let r=(h=n(this,A))==null?void 0:h.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let i=yield r.getKey(this.address);if(i!=null){e.locator=`device:${i}`;return}let o=(yield this.signers()).filter(s=>s.locator.startsWith("device:"));for(let s of o){let l=s.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=s.locator;return}}c(this,w,!0),c(this,I,!1)})}assembleFullSigner(o){return d(this,arguments,function*(e,r=(t=>(t=n(this,A))==null?void 0:t.deviceSignerKeyStorage)(),i){var s;let h=q(this.chain,e,r);if(i!=null&&i.isAdminSigner)h.status="active";else{let l=yield this.getSignerState(h.locator());h.status=(s=l.signer)==null?void 0:s.status}return h})}getSignerState(e){return d(this,null,function*(){let r=null;try{r=yield n(this,f).getSigner(this.walletLocator,e)}catch(t){return{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return{response:null,signer:null,pendingOperation:null};let i=j(r,this.chain);return{response:r,signer:i,pendingOperation:z(r,this.chain)}})}buildInternalSignerConfig(e){var r,i,t,o,h,s;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:n(this,f).crossmint,clientTEEConnection:(r=n(this,A))==null?void 0:r.clientTEEConnection,onAuthRequired:(t=(i=n(this,A))==null?void 0:i.callbacks)==null?void 0:t.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:n(this,f).crossmint,clientTEEConnection:(o=n(this,A))==null?void 0:o.clientTEEConnection,onAuthRequired:(s=(h=n(this,A))==null?void 0:h.callbacks)==null?void 0:s.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 O(b({},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:g}=this.resolveServerSignerDerivation(e);return{type:"server",derivedKeyBytes:l,locator:`server:${g}`,address:g}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}isAutoAssemblableSignerConfig(e){var r;switch(e.type){case"email":case"phone":case"passkey":case"api-key":return!0;case"device":return((r=n(this,A))==null?void 0:r.deviceSignerKeyStorage)!=null;case"server":return!W(e);case"external-wallet":return"onSign"in e&&typeof e.onSign=="function";default:return!1}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=de(this.chain,n(this,f).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return d(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return d(this,null,function*(){let i=yield this.approveSignatureInternal(e,r);return!("error"in i)&&i.status==="success"&&i.outputSignature!=null?{signature:i.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return d(this,null,function*(){var l,g;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let i=this.requireSigner(),t=yield n(this,f).getSignature(this.walletLocator,e);if("error"in t)throw new G(JSON.stringify(t));if(i.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let u=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,u)}let o=(l=t.approvals)==null?void 0:l.pending;if(o==null||o.length===0)return t;let h=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],i],s=yield Promise.all(o.map(u=>d(this,null,function*(){let S=h.find(C=>C.locator()===u.signer.locator);if(S==null)throw new _(`Signer ${u.signer.locator} not found in pending approvals`);let y=yield S.signMessage(u.message);return O(b({},y),{signer:S.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,s)})}approveTransactionInternal(e,r){return d(this,null,function*(){var l,g,u,S,y;let i=yield n(this,f).getTransaction(this.walletLocator,e);if("error"in i)throw new M(JSON.stringify(i));yield(u=(g=(l=n(this,A))==null?void 0:l.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:u.call(g);let t=this.requireSigner();if(t.type==="api-key")return i;if((r==null?void 0:r.approval)!=null){let C=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,C)}let o=(S=i.approvals)==null?void 0:S.pending;if(o==null||o.length===0)return i;let h=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],t],s=yield Promise.all(o.map(C=>d(this,null,function*(){let F=h.find(fe=>fe.locator()===C.signer.locator);if(F==null)throw new _(`Signer ${C.signer.locator} not found in pending approvals`);let H=F.type==="device",J=i.chainType==="solana"&&"transaction"in i.onChain&&!H?i.onChain.transaction:C.message,ve=yield F.signTransaction(J);return O(b({},ve),{signer:F.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,s)})}executeApproveTransactionWithErrorHandling(e,r){return d(this,null,function*(){a.info("wallet.approve: submitting approval to API",{transactionId:e});let i=yield n(this,f).approveTransaction(this.walletLocator,e,{approvals:r});if(i.error)throw new le(JSON.stringify(i));return i})}executeApproveSignatureWithErrorHandling(e,r){return d(this,null,function*(){let i=yield n(this,f).approveSignature(this.walletLocator,e,{approvals:r});if(i.error)throw new re(JSON.stringify(i));return i})}waitForSignature(e){return d(this,null,function*(){let r=null;do if(yield new Promise(i=>setTimeout(i,U)),r=yield n(this,f).getSignature(this.walletLocator,e),"error"in r)throw new G(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new ee("Signature signing failed");if(!r.outputSignature)throw new G("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(h){return d(this,arguments,function*(e,r=6e4,{backoffMultiplier:i=1.1,maxBackoffMs:t=2e3,initialBackoffMs:o=U}={}){var S,y;a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let s=Date.now(),l;do{if(Date.now()-s>r)throw new ne("Transaction confirmation timeout");if(l=yield n(this,f).getTransaction(this.walletLocator,e),l.error)throw new M(JSON.stringify(l));yield this.sleep(o),o=Math.min(o*i,t)}while(l.status==="pending");if(l.status==="failed")throw new se(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new ae("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let g="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,u=(S=l.onChain.txId)!=null?S:g;if(u==null)throw new oe("Transaction hash not found on transaction response");return{hash:u,explorerLink:(y=l.onChain.explorerLink)!=null?y:"",transactionId:l.id}})}sleep(e){return d(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};p=new WeakMap,A=new WeakMap,f=new WeakMap,v=new WeakMap,R=new WeakMap,w=new WeakMap,I=new WeakMap,x=new WeakMap,L=new WeakMap,$=new WeakMap,K=new WeakMap,D=new WeakMap,B=new WeakMap,k([P({logger:a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"balances",1),k([P({logger:a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"stagingFund",1),k([P({logger:a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"send",1),k([P({logger:a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"approve",1),k([P({logger:a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"addSigner",1),k([P({logger:a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"removeSigner",1),k([P({logger:a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"useSigner",1),k([P({logger:a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"recover",1),k([P({logger:a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"signers",1);function we(m){if(typeof m=="string"){if(!Se(m))throw new ce(`Invalid recipient address: "${m}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return m}if("email"in m)return`email:${m.email}`;if("x"in m)return`x:${m.x}`;if("twitter"in m)return`twitter:${m.twitter}`;if("phone"in m)return`phoneNumber:${m.phone}`;if("userId"in m)return`userId:${m.userId}`;throw new Error("Invalid recipient locator")}function ye(m,e){return Se(m)?`${e}:${m}`:`${e}:${m.toLowerCase()}`}export{E as a};
@@ -1,3 +1,3 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunkKXKBZNETcjs = require('./chunk-KXKBZNET.cjs');var _chunkAET7QPSVcjs = require('./chunk-AET7QPSV.cjs');var _chunkI3RWATD5cjs = require('./chunk-I3RWATD5.cjs');var _chunkYYFLQQPVcjs = require('./chunk-YYFLQQPV.cjs');var _chunkAS2YN2YCcjs = require('./chunk-AS2YN2YC.cjs');var _chunkAAUS7KTRcjs = require('./chunk-AAUS7KTR.cjs');var _chunkOWQZPI3Ucjs = require('./chunk-OWQZPI3U.cjs');var _chunkCFB27BFVcjs = require('./chunk-CFB27BFV.cjs');var _chunkX7E2YEIVcjs = require('./chunk-X7E2YEIV.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var p,A,f,v,R,w,I,x,L,$,K,D,B,E= exports.a =class{constructor(e,r){_chunk2GKPWQBQcjs.e.call(void 0, this,p);_chunk2GKPWQBQcjs.e.call(void 0, this,A);_chunk2GKPWQBQcjs.e.call(void 0, this,f);_chunk2GKPWQBQcjs.e.call(void 0, this,v);_chunk2GKPWQBQcjs.e.call(void 0, this,R);_chunk2GKPWQBQcjs.e.call(void 0, this,w,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,I,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,x,null);_chunk2GKPWQBQcjs.e.call(void 0, this,L,null);_chunk2GKPWQBQcjs.e.call(void 0, this,$,[]);_chunk2GKPWQBQcjs.e.call(void 0, this,K);_chunk2GKPWQBQcjs.e.call(void 0, this,D,null);_chunk2GKPWQBQcjs.e.call(void 0, this,B,!1);let{chain:i,address:t,owner:a,options:h,alias:o,recovery:l,apiRecoveryServerSignerAddress:g,apiDelegatedServerSignerAddresses:u,signers:S,signer:y}=e;_chunk2GKPWQBQcjs.f.call(void 0, this,f,r),this.chain=i,this.address=t,this.owner=a,_chunk2GKPWQBQcjs.f.call(void 0, this,A,h),this.alias=o,_chunk2GKPWQBQcjs.f.call(void 0, this,v,l),g!=null?_chunk2GKPWQBQcjs.f.call(void 0, this,L,g):l.type==="server"&&_chunkAS2YN2YCcjs.b.call(void 0, l)&&_chunk2GKPWQBQcjs.f.call(void 0, this,L,l.address),_chunk2GKPWQBQcjs.f.call(void 0, this,$,u!=null?u:[]),_chunk2GKPWQBQcjs.f.call(void 0, this,R,S!=null?S:[]),_chunk2GKPWQBQcjs.f.call(void 0, this,p,y),_chunk2GKPWQBQcjs.f.call(void 0, this,K,this.initDefaultSigner())}get signer(){return _chunk2GKPWQBQcjs.d.call(void 0, this,p)}waitForInit(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,K)})}initDeviceSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;let e=(t=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:t.deviceSignerKeyStorage;if(e==null||_chunk2GKPWQBQcjs.d.call(void 0, this,B))return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(a){_chunkCFB27BFVcjs.a.error("wallet.initDeviceSigner.error",{error:a}),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!0);return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,w))return;let i=this.buildInternalSignerConfig(r);_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(i,e)),this.isApprovedSignerStatus(_chunk2GKPWQBQcjs.d.call(void 0, this,p).status)||(_chunkCFB27BFVcjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:_chunk2GKPWQBQcjs.d.call(void 0, this,p).locator(),status:_chunk2GKPWQBQcjs.d.call(void 0, this,p).status}),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,I,!1))})}initDefaultSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,p)!=null||(yield this.initDeviceSigner(),_chunk2GKPWQBQcjs.d.call(void 0, this,p)!=null||_chunk2GKPWQBQcjs.d.call(void 0, this,w)))return;let e=_chunk2GKPWQBQcjs.d.call(void 0, this,R).length===0?_chunk2GKPWQBQcjs.d.call(void 0, this,v):_chunk2GKPWQBQcjs.d.call(void 0, this,R).length===1?_chunk2GKPWQBQcjs.d.call(void 0, this,R)[0]:null;if(e==null||!this.isAutoAssemblableSignerConfig(e))return;let r=e===_chunk2GKPWQBQcjs.d.call(void 0, this,v);try{let i=this.buildInternalSignerConfig(e);_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(i,void 0,{isAdminSigner:r}))}catch(i){_chunkCFB27BFVcjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunk2GKPWQBQcjs.d.call(void 0, this,v).type,signerCount:_chunk2GKPWQBQcjs.d.call(void 0, this,R).length,error:i})}})}assembleRecoverySignerFallback(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v)))try{let e=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v));_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(e,void 0,{isAdminSigner:!0}))}catch(e){_chunkCFB27BFVcjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:_chunk2GKPWQBQcjs.d.call(void 0, this,v).type,error:e})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,v)}static getInitialSigners(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,R)}static getApiRecoveryServerSignerAddress(e){var r;return(r=_chunk2GKPWQBQcjs.d.call(void 0, e,L))!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,$)}get apiClient(){return _chunk2GKPWQBQcjs.d.call(void 0, this,f)}get options(){return _chunk2GKPWQBQcjs.d.call(void 0, this,A)}deriveServerSignerCandidates(e){return _chunkI3RWATD5cjs.c.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,f).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,f).environment)}matchResolvedServerSigner(e){if(_chunk2GKPWQBQcjs.d.call(void 0, this,x)==null)return null;let{primary:r,legacy:i}=this.deriveServerSignerCandidates(e),t=_chunk2GKPWQBQcjs.d.call(void 0, this,x).derivedAddress;return t===r.derivedAddress||i!=null&&t===i.derivedAddress?_chunk2GKPWQBQcjs.d.call(void 0, this,x):null}resolveServerSignerDerivation(e){let r=this.matchResolvedServerSigner(e);if(r!=null)return r;let{primary:i,legacy:t}=this.deriveServerSignerCandidates(e);return t!=null&&(t.derivedAddress===_chunk2GKPWQBQcjs.d.call(void 0, this,L)||_chunk2GKPWQBQcjs.d.call(void 0, this,R).some(a=>a.type==="server"&&_chunkAS2YN2YCcjs.b.call(void 0, a)&&a.address===t.derivedAddress)||_chunk2GKPWQBQcjs.d.call(void 0, this,$).includes(t.derivedAddress))?t:i}resolveServerSignerApiLocator(e){return`server:${this.resolveServerSignerDerivation(e).derivedAddress}`}get recovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,v)}balances(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkCFB27BFVcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),i;switch(this.chain){case"solana":i="sol";break;case"stellar":i="xlm";break;default:i="eth";break}let t=[i,"usdc",...e!=null?e:[]],a=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getBalance(this.address,{chains:[r],tokens:t});if("error"in a)throw _chunkCFB27BFVcjs.a.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return _chunkCFB27BFVcjs.a.info("wallet.balances.success"),this.transformBalanceResponse(a,i,e)})}stagingFund(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkCFB27BFVcjs.a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let i=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in i)throw _chunkCFB27BFVcjs.a.error("wallet.stagingFund.error",{error:i}),new Error(`Failed to fund wallet: ${JSON.stringify(i.message)}`);return _chunkCFB27BFVcjs.a.info("wallet.stagingFund.success"),i})}transformBalanceResponse(e,r,i){let t=g=>{var y,C,F,H,J;let u=(y=g.chains)==null?void 0:y[this.chain],S={};return this.chain==="solana"&&u!=null&&"mintHash"in u?S={mintHash:u.mintHash}:this.chain==="stellar"&&u!=null&&"contractId"in u?S={contractId:u.contractId}:u!=null&&"contractAddress"in u&&(S={contractAddress:u.contractAddress}),_chunk2GKPWQBQcjs.a.call(void 0, {symbol:(C=g.symbol)!=null?C:"",name:(F=g.name)!=null?F:"",amount:(H=g.amount)!=null?H:"0",decimals:g.decimals,rawAmount:(J=g.rawAmount)!=null?J:"0"},S)},a=e.find(g=>g.symbol===r),h=e.find(g=>g.symbol==="usdc"),o=e.filter(g=>{var u;return g.symbol!==r&&g.symbol!=="usdc"&&(i==null||i.includes((u=g.symbol)!=null?u:""))}),l=g=>{let u={symbol:g,name:g,amount:"0",decimals:0,rawAmount:"0"},S={};return this.chain==="solana"?S={mintHash:void 0}:this.chain==="stellar"?S={contractId:void 0}:S={contractAddress:void 0},_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},u),S)};return{nativeToken:a!=null?t(a):l(r),usdc:h!=null?t(h):l("usdc"),tokens:o.map(t)}}nfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).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,f).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,f).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(),i=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in i)throw new Error(`Failed to get transfers: ${JSON.stringify(i.message)}`);return i})}send(e,r,i,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let a=this.resolveChainForEnvironment(),h=fe(e),o=we(r,a),l=Number(i);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new (0, _chunkOWQZPI3Ucjs.u)(`Invalid transfer amount: "${i}". Amount must be a positive number greater than zero.`);_chunkCFB27BFVcjs.a.info("wallet.send.start",_chunk2GKPWQBQcjs.a.call(void 0, {recipient:h,token:o,amount:i},(t==null?void 0:t.transactionType)!=null?{transactionType:t.transactionType}:{})),yield this.preAuthIfNeeded();let g=this.requireSigner(),u;(t==null?void 0:t.signer)==null?u=g.locator():typeof t.signer=="string"?u=t.signer:u=this.resolveServerSignerApiLocator(t.signer);let S=_chunk2GKPWQBQcjs.a.call(void 0, {recipient:h,amount:i,signer:u},(t==null?void 0:t.transactionType)!=null?{transactionType:t.transactionType}:{}),y=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).send(this.walletLocator,o,S);if("message"in y)throw _chunkCFB27BFVcjs.a.error("wallet.send.error",{error:y}),new (0, _chunkOWQZPI3Ucjs.v)(`Failed to send token: ${JSON.stringify(y.message)}`);if((t==null?void 0:t.prepareOnly)===!0)return _chunkCFB27BFVcjs.a.info("wallet.send.prepared",{transactionId:y.id}),{hash:void 0,explorerLink:void 0,transactionId:y.id};let C=yield this.approveTransactionAndWait(y.id);return _chunkCFB27BFVcjs.a.info("wallet.send.success",{transactionId:y.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(_chunkCFB27BFVcjs.a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return _chunkCFB27BFVcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkCFB27BFVcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkCFB27BFVcjs.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*(){_chunkCFB27BFVcjs.a.info("wallet.addSigner.start");let i=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return this.withRecoverySigner(()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var u,S;let t=typeof i=="string"?i:_chunkNX256LAHcjs.a.call(void 0, i),a=yield this.getSignerState(t);if(a.signer!=null){if(this.isApprovedSignerStatus(a.signer.status))return _chunkCFB27BFVcjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(a.signer,null,r);if(a.pendingOperation!=null)return _chunkCFB27BFVcjs.a.info("wallet.addSigner.resuming",{operationType:a.pendingOperation.type,operationId:a.pendingOperation.id}),this.completeSignerRegistration(a.signer,a.pendingOperation,r)}let h=typeof i=="string"||i.type==="passkey"?i:i.type==="device"&&"publicKey"in i&&i.publicKey!=null?{type:"device",publicKey:i.publicKey,name:i.name}:_chunkNX256LAHcjs.a.call(void 0, i),o=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).registerSigner(this.walletLocator,_chunk2GKPWQBQcjs.a.call(void 0, {signer:h,chain:this.getSignerRegistrationChain()},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}));if("error"in o)throw _chunkCFB27BFVcjs.a.error("wallet.addSigner.error",{error:o}),o.code===_chunkOWQZPI3Ucjs.k?new (0, _chunkOWQZPI3Ucjs.l)(o.message):new (0, _chunkOWQZPI3Ucjs.j)(`Failed to register signer: ${JSON.stringify(o.message)}`);let l=_chunkKXKBZNETcjs.b.call(void 0, o,this.chain);if(l==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let g=null;if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in o)||o.transaction==null)throw _chunkCFB27BFVcjs.a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");g={type:"transaction",id:o.transaction.id}}else{if(!("chains"in o))throw _chunkCFB27BFVcjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((S=(u=o.chains)==null?void 0:u[this.chain])==null?void 0:S.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);g=_chunkKXKBZNETcjs.c.call(void 0, o,this.chain)}return this.completeSignerRegistration(l,g,r)}))})}completeSignerRegistration(e,r,i){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i!=null&&i.prepareOnly){if(r==null)return _chunk2GKPWQBQcjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let t={transactionId:r.id};return _chunkCFB27BFVcjs.a.info("wallet.addSigner.prepared",t),_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),t)}case"signature":{let t={signatureId:r.id};return _chunkCFB27BFVcjs.a.info("wallet.addSigner.prepared",t),_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),t)}default:{let t=r.type;throw new Error(`Unknown pending operation type: ${t}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),_chunkCFB27BFVcjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkCFB27BFVcjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let t=r.type;throw new Error(`Unknown pending operation type: ${t}`)}}else _chunkCFB27BFVcjs.a.info("wallet.addSigner.success");return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=this.resolveSignerLocator(e);return _chunkCFB27BFVcjs.a.info("wallet.removeSigner.start",{signerLocator:i}),this.withRecoverySigner(()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).removeSigner(this.walletLocator,i,{chain:this.getSignerRegistrationChain()});if("error"in t)throw _chunkCFB27BFVcjs.a.error("wallet.removeSigner.error",{error:t}),new Error(`Failed to remove signer: ${JSON.stringify(t)}`);let a=t.id;return r!=null&&r.prepareOnly?(_chunkCFB27BFVcjs.a.info("wallet.removeSigner.prepared",{transactionId:a}),{transactionId:a,status:void 0}):(yield this.approveTransactionAndWait(a),_chunkCFB27BFVcjs.a.info("wallet.removeSigner.success",{transactionId:a}),{transactionId:a,status:"success"})}))})}useSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkCFB27BFVcjs.a.info("wallet.useSigner.start"),e.type==="server"&&_chunk2GKPWQBQcjs.f.call(void 0, this,x,null),this.validateSignerInput(e);let r=!1;e.type==="device"?yield this.resolveDeviceSignerAvailability(e):r=yield this.resolveNonDeviceSigner(e);let i=this.buildInternalSignerConfig(e),t=_chunkNX256LAHcjs.a.call(void 0, e);_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(i,void 0,{isAdminSigner:r})),_chunkCFB27BFVcjs.a.info("wallet.useSigner.success",{signerLocator:t})})}resolveNonDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return _chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!1;if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let{primary:r,legacy:i}=this.deriveServerSignerCandidates(e),t=yield this.signers();if(t.some(h=>h.locator===`server:${r.derivedAddress}`))return _chunk2GKPWQBQcjs.f.call(void 0, this,x,r),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!1;if(i!=null&&t.some(h=>h.locator===`server:${i.derivedAddress}`))return _chunk2GKPWQBQcjs.f.call(void 0, this,x,i),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!1;if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.d.call(void 0, this,L)!=null&&i!=null&&i.derivedAddress===_chunk2GKPWQBQcjs.d.call(void 0, this,L)?_chunk2GKPWQBQcjs.f.call(void 0, this,x,i):_chunk2GKPWQBQcjs.f.call(void 0, this,x,r),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!0;let a=i!=null?`"server:${r.derivedAddress}" or "server:${i.derivedAddress}"`:`"server:${r.derivedAddress}"`;throw new Error(`Signer ${a} is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=(yield this.signers()).filter(t=>t.type==="passkey");if(i.length===0)return!1;if(i.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=i[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):_chunkNX256LAHcjs.a.call(void 0, e)}getSignerRegistrationChain(){if(!(this.chain==="solana"||this.chain==="stellar"))return this.chain}withRecoverySigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;let r=this.signer;if(_chunkAS2YN2YCcjs.b.call(void 0, _chunk2GKPWQBQcjs.d.call(void 0, this,v)))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(_chunk2GKPWQBQcjs.d.call(void 0, this,v)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,v).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v)))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let i=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v));_chunk2GKPWQBQcjs.f.call(void 0, this,p,_chunkAET7QPSVcjs.a.call(void 0, this.chain,i,(t=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:t.deviceSignerKeyStorage));try{return yield e()}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,p,r)}})}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.signers()).some(i=>i.locator===e)})}isSignerApproved(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;let r=yield this.getSignerState(e);return this.isApprovedSignerStatus((i=r.signer)==null?void 0:i.status)})}isApprovedSignerStatus(e){return e==="success"||e==="active"}needsRecovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,w)}recover(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a,h;if(_chunkCFB27BFVcjs.a.info("wallet.recover.start"),_chunk2GKPWQBQcjs.d.call(void 0, this,I)){_chunkCFB27BFVcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,B)){_chunkCFB27BFVcjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,I,!0);return}let e=()=>{_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,I,!0)};if(((a=_chunk2GKPWQBQcjs.d.call(void 0, this,p))==null?void 0:a.type)==="device"&&(yield this.checkAndResumeDeviceSigner(_chunk2GKPWQBQcjs.d.call(void 0, this,p)))){e();return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,p)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,p).type!=="device"){_chunkCFB27BFVcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1);return}let r=(h=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:h.deviceSignerKeyStorage;if(r==null){if(!_chunk2GKPWQBQcjs.d.call(void 0, this,w))return;throw new Error("Device signer key storage is required to recover a device signer")}let i=yield this.findLocalDeviceSigner(r);if(i!=null&&(yield this.checkAndResumeDeviceSigner(i))){_chunk2GKPWQBQcjs.f.call(void 0, this,p,i),e();let o=i.locator().replace("device:","");try{yield r.mapAddressToKey(this.address,o)}catch(l){_chunkCFB27BFVcjs.a.warn("wallet.recover.mapAddressToKey.error",{error:l})}return}let t=yield _chunkYHV3672Rcjs.a.call(void 0, r,this.address);try{yield this.addSigner(t)}catch(o){let l=o instanceof Error&&o.message.toLowerCase().includes("delegated signer")&&o.message.toLowerCase().includes("already")&&o.message.toLowerCase().includes("approved");if(o instanceof _chunkOWQZPI3Ucjs.l){_chunkCFB27BFVcjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:t.locator}),yield r.deleteKey(this.address),_chunk2GKPWQBQcjs.f.call(void 0, this,B,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,I,!0),yield this.assembleRecoverySignerFallback();return}else if(l)_chunkCFB27BFVcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:t.locator});else throw o instanceof _chunkAS2YN2YCcjs.a||o instanceof Error&&o.name==="AuthRejectedError"?(_chunkCFB27BFVcjs.a.info("wallet.recover.device.authRejected",{signerLocator:t.locator}),o):(_chunkCFB27BFVcjs.a.error("wallet.recover.device.error",{error:o}),yield r.deleteKey(this.address),o)}_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner({type:"device",locator:t.locator,address:this.address},r)),_chunk2GKPWQBQcjs.d.call(void 0, this,p).type==="device"&&(_chunk2GKPWQBQcjs.d.call(void 0, this,p).status="success"),_chunkCFB27BFVcjs.a.info("wallet.recover.device.success",{signerLocator:t.locator}),e()})}checkAndResumeDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;if(this.isApprovedSignerStatus(e.status))return _chunkCFB27BFVcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let r=yield this.getSignerState(e.locator());return e.status=(i=r.signer)==null?void 0:i.status,r.pendingOperation!=null?(yield this.resumePendingDeviceSignerApproval(e,r.pendingOperation),!0):this.isApprovedSignerStatus(e.status)?(_chunkCFB27BFVcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})}resumePendingDeviceSignerApproval(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a;let i=_chunk2GKPWQBQcjs.d.call(void 0, this,p);if(_chunkAS2YN2YCcjs.b.call(void 0, _chunk2GKPWQBQcjs.d.call(void 0, this,v)))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(_chunk2GKPWQBQcjs.d.call(void 0, this,v)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,v).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v)))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let t=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v));_chunk2GKPWQBQcjs.f.call(void 0, this,p,_chunkAET7QPSVcjs.a.call(void 0, this.chain,t,(a=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:a.deviceSignerKeyStorage));try{r.type==="signature"?yield this.approveSignatureAndWait(r.id):yield this.approveTransactionAndWait(r.id)}catch(h){throw _chunk2GKPWQBQcjs.f.call(void 0, this,p,e),h}finally{_chunk2GKPWQBQcjs.d.call(void 0, this,p)!==e&&_chunk2GKPWQBQcjs.f.call(void 0, this,p,i)}e.status="success",_chunkCFB27BFVcjs.a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0})})}findLocalDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=(yield this.signers()).filter(t=>t.locator.startsWith("device:"));for(let t of i){let a=t.locator.replace("device:","");try{if(yield e.hasKey(a)){let o=_chunkAET7QPSVcjs.a.call(void 0, this.chain,{type:"device",locator:t.locator,address:this.address},e);return _chunkCFB27BFVcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),o}}catch(h){_chunkCFB27BFVcjs.a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:t.locator,error:h})}}return null})}signers(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a,h;_chunkCFB27BFVcjs.a.info("wallet.signers.start");let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getWallet(this.walletLocator);if("error"in e)throw _chunkCFB27BFVcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkOWQZPI3Ucjs.e)(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw _chunkCFB27BFVcjs.a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new (0, _chunkOWQZPI3Ucjs.d)(`Wallet type ${e.type} not supported`);let r=(h=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?h:[],t=(yield Promise.all(r.map(o=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{return(yield this.getSignerState(o.locator)).signer}catch(l){return null}})))).filter(o=>o!=null);return _chunkCFB27BFVcjs.a.info("wallet.signers.success",{count:t.length}),t})}get walletLocator(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,f).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,p)==null)throw _chunk2GKPWQBQcjs.d.call(void 0, this,R).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):_chunk2GKPWQBQcjs.d.call(void 0, this,v).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunkKXKBZNETcjs = require('./chunk-KXKBZNET.cjs');var _chunkYWTJTAIUcjs = require('./chunk-YWTJTAIU.cjs');var _chunkI3RWATD5cjs = require('./chunk-I3RWATD5.cjs');var _chunkSDVBLX5Jcjs = require('./chunk-SDVBLX5J.cjs');var _chunkEHMQ5WD7cjs = require('./chunk-EHMQ5WD7.cjs');var _chunkAGN3B4GScjs = require('./chunk-AGN3B4GS.cjs');var _chunkOWQZPI3Ucjs = require('./chunk-OWQZPI3U.cjs');var _chunkXDHGCS4Wcjs = require('./chunk-XDHGCS4W.cjs');var _chunkTQCD2GORcjs = require('./chunk-TQCD2GOR.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var p,A,f,v,R,w,I,x,L,$,K,D,B,E= exports.a =class{constructor(e,r){_chunk2GKPWQBQcjs.e.call(void 0, this,p);_chunk2GKPWQBQcjs.e.call(void 0, this,A);_chunk2GKPWQBQcjs.e.call(void 0, this,f);_chunk2GKPWQBQcjs.e.call(void 0, this,v);_chunk2GKPWQBQcjs.e.call(void 0, this,R);_chunk2GKPWQBQcjs.e.call(void 0, this,w,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,I,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,x,null);_chunk2GKPWQBQcjs.e.call(void 0, this,L,null);_chunk2GKPWQBQcjs.e.call(void 0, this,$,[]);_chunk2GKPWQBQcjs.e.call(void 0, this,K);_chunk2GKPWQBQcjs.e.call(void 0, this,D,null);_chunk2GKPWQBQcjs.e.call(void 0, this,B,!1);let{chain:i,address:t,owner:o,options:h,alias:s,recovery:l,apiRecoveryServerSignerAddress:g,apiDelegatedServerSignerAddresses:u,signers:S,signer:y}=e;_chunk2GKPWQBQcjs.f.call(void 0, this,f,r),this.chain=i,this.address=t,this.owner=o,_chunk2GKPWQBQcjs.f.call(void 0, this,A,h),this.alias=s,_chunk2GKPWQBQcjs.f.call(void 0, this,v,l),g!=null?_chunk2GKPWQBQcjs.f.call(void 0, this,L,g):l.type==="server"&&_chunkEHMQ5WD7cjs.c.call(void 0, l)&&_chunk2GKPWQBQcjs.f.call(void 0, this,L,l.address),_chunk2GKPWQBQcjs.f.call(void 0, this,$,u!=null?u:[]),_chunk2GKPWQBQcjs.f.call(void 0, this,R,S!=null?S:[]),_chunk2GKPWQBQcjs.f.call(void 0, this,p,y),_chunk2GKPWQBQcjs.f.call(void 0, this,K,this.initDefaultSigner())}get signer(){return _chunk2GKPWQBQcjs.d.call(void 0, this,p)}waitForInit(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,K)})}initDeviceSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;let e=(t=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:t.deviceSignerKeyStorage;if(e==null||_chunk2GKPWQBQcjs.d.call(void 0, this,B))return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(o){_chunkXDHGCS4Wcjs.a.error("wallet.initDeviceSigner.error",{error:o}),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!0);return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,w))return;let i=this.buildInternalSignerConfig(r);_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(i,e)),this.isApprovedSignerStatus(_chunk2GKPWQBQcjs.d.call(void 0, this,p).status)||(_chunkXDHGCS4Wcjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:_chunk2GKPWQBQcjs.d.call(void 0, this,p).locator(),status:_chunk2GKPWQBQcjs.d.call(void 0, this,p).status}),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,I,!1))})}initDefaultSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,p)!=null||(yield this.initDeviceSigner(),_chunk2GKPWQBQcjs.d.call(void 0, this,p)!=null||_chunk2GKPWQBQcjs.d.call(void 0, this,w)))return;let e=_chunk2GKPWQBQcjs.d.call(void 0, this,R).length===0?_chunk2GKPWQBQcjs.d.call(void 0, this,v):_chunk2GKPWQBQcjs.d.call(void 0, this,R).length===1?_chunk2GKPWQBQcjs.d.call(void 0, this,R)[0]:null;if(e==null||!this.isAutoAssemblableSignerConfig(e))return;let r=e===_chunk2GKPWQBQcjs.d.call(void 0, this,v);try{let i=this.buildInternalSignerConfig(e);_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(i,void 0,{isAdminSigner:r}))}catch(i){_chunkXDHGCS4Wcjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunk2GKPWQBQcjs.d.call(void 0, this,v).type,signerCount:_chunk2GKPWQBQcjs.d.call(void 0, this,R).length,error:i})}})}assembleRecoverySignerFallback(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v)))try{let e=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v));_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(e,void 0,{isAdminSigner:!0}))}catch(e){_chunkXDHGCS4Wcjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:_chunk2GKPWQBQcjs.d.call(void 0, this,v).type,error:e})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,v)}static getInitialSigners(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,R)}static getApiRecoveryServerSignerAddress(e){var r;return(r=_chunk2GKPWQBQcjs.d.call(void 0, e,L))!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,$)}get apiClient(){return _chunk2GKPWQBQcjs.d.call(void 0, this,f)}get options(){return _chunk2GKPWQBQcjs.d.call(void 0, this,A)}deriveServerSignerCandidates(e){return _chunkI3RWATD5cjs.c.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,f).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,f).environment)}matchResolvedServerSigner(e){if(_chunk2GKPWQBQcjs.d.call(void 0, this,x)==null)return null;let{primary:r,legacy:i}=this.deriveServerSignerCandidates(e),t=_chunk2GKPWQBQcjs.d.call(void 0, this,x).derivedAddress;return t===r.derivedAddress||i!=null&&t===i.derivedAddress?_chunk2GKPWQBQcjs.d.call(void 0, this,x):null}resolveServerSignerDerivation(e){let r=this.matchResolvedServerSigner(e);if(r!=null)return r;let{primary:i,legacy:t}=this.deriveServerSignerCandidates(e);return t!=null&&(t.derivedAddress===_chunk2GKPWQBQcjs.d.call(void 0, this,L)||_chunk2GKPWQBQcjs.d.call(void 0, this,R).some(o=>o.type==="server"&&_chunkEHMQ5WD7cjs.c.call(void 0, o)&&o.address===t.derivedAddress)||_chunk2GKPWQBQcjs.d.call(void 0, this,$).includes(t.derivedAddress))?t:i}resolveServerSignerApiLocator(e){return`server:${this.resolveServerSignerDerivation(e).derivedAddress}`}get recovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,v)}balances(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkXDHGCS4Wcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),i;switch(this.chain){case"solana":i="sol";break;case"stellar":i="xlm";break;default:i="eth";break}let t=[i,"usdc",...e!=null?e:[]],o=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getBalance(this.address,{chains:[r],tokens:t});if("error"in o)throw _chunkXDHGCS4Wcjs.a.error("wallet.balances.error",{error:o}),new Error(`Failed to get balances for wallet: ${JSON.stringify(o.message)}`);return _chunkXDHGCS4Wcjs.a.info("wallet.balances.success"),this.transformBalanceResponse(o,i,e)})}stagingFund(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkXDHGCS4Wcjs.a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let i=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in i)throw _chunkXDHGCS4Wcjs.a.error("wallet.stagingFund.error",{error:i}),new Error(`Failed to fund wallet: ${JSON.stringify(i.message)}`);return _chunkXDHGCS4Wcjs.a.info("wallet.stagingFund.success"),i})}transformBalanceResponse(e,r,i){let t=g=>{var y,C,F,H,J;let u=(y=g.chains)==null?void 0:y[this.chain],S={};return this.chain==="solana"&&u!=null&&"mintHash"in u?S={mintHash:u.mintHash}:this.chain==="stellar"&&u!=null&&"contractId"in u?S={contractId:u.contractId}:u!=null&&"contractAddress"in u&&(S={contractAddress:u.contractAddress}),_chunk2GKPWQBQcjs.a.call(void 0, {symbol:(C=g.symbol)!=null?C:"",name:(F=g.name)!=null?F:"",amount:(H=g.amount)!=null?H:"0",decimals:g.decimals,rawAmount:(J=g.rawAmount)!=null?J:"0"},S)},o=e.find(g=>g.symbol===r),h=e.find(g=>g.symbol==="usdc"),s=e.filter(g=>{var u;return g.symbol!==r&&g.symbol!=="usdc"&&(i==null||i.includes((u=g.symbol)!=null?u:""))}),l=g=>{let u={symbol:g,name:g,amount:"0",decimals:0,rawAmount:"0"},S={};return this.chain==="solana"?S={mintHash:void 0}:this.chain==="stellar"?S={contractId:void 0}:S={contractAddress:void 0},_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},u),S)};return{nativeToken:o!=null?t(o):l(r),usdc:h!=null?t(h):l("usdc"),tokens:s.map(t)}}nfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).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,f).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,f).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(),i=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in i)throw new Error(`Failed to get transfers: ${JSON.stringify(i.message)}`);return i})}send(e,r,i,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let o=this.resolveChainForEnvironment(),h=we(e),s=ye(r,o),l=Number(i);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new (0, _chunkOWQZPI3Ucjs.u)(`Invalid transfer amount: "${i}". Amount must be a positive number greater than zero.`);_chunkXDHGCS4Wcjs.a.info("wallet.send.start",_chunk2GKPWQBQcjs.a.call(void 0, {recipient:h,token:s,amount:i},(t==null?void 0:t.transactionType)!=null?{transactionType:t.transactionType}:{})),yield this.preAuthIfNeeded();let g=this.requireSigner(),u;(t==null?void 0:t.signer)==null?u=g.locator():typeof t.signer=="string"?u=t.signer:u=this.resolveServerSignerApiLocator(t.signer);let S=_chunk2GKPWQBQcjs.a.call(void 0, {recipient:h,amount:i,signer:u},(t==null?void 0:t.transactionType)!=null?{transactionType:t.transactionType}:{}),y=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).send(this.walletLocator,s,S);if("message"in y)throw _chunkXDHGCS4Wcjs.a.error("wallet.send.error",{error:y}),new (0, _chunkOWQZPI3Ucjs.v)(`Failed to send token: ${JSON.stringify(y.message)}`);if((t==null?void 0:t.prepareOnly)===!0)return _chunkXDHGCS4Wcjs.a.info("wallet.send.prepared",{transactionId:y.id}),{hash:void 0,explorerLink:void 0,transactionId:y.id};let C=yield this.approveTransactionAndWait(y.id);return _chunkXDHGCS4Wcjs.a.info("wallet.send.success",{transactionId:y.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(_chunkXDHGCS4Wcjs.a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return _chunkXDHGCS4Wcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkXDHGCS4Wcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkXDHGCS4Wcjs.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*(){_chunkXDHGCS4Wcjs.a.info("wallet.addSigner.start");let i=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return this.withRecoverySigner(()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var u,S;let t=typeof i=="string"?i:_chunkNX256LAHcjs.a.call(void 0, i),o=yield this.getSignerState(t);if(o.signer!=null){if(this.isApprovedSignerStatus(o.signer.status))return _chunkXDHGCS4Wcjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(o.signer,null,r);if(o.pendingOperation!=null)return _chunkXDHGCS4Wcjs.a.info("wallet.addSigner.resuming",{operationType:o.pendingOperation.type,operationId:o.pendingOperation.id}),this.completeSignerRegistration(o.signer,o.pendingOperation,r)}let h=typeof i=="string"||i.type==="passkey"?i:i.type==="device"&&"publicKey"in i&&i.publicKey!=null?{type:"device",publicKey:i.publicKey,name:i.name}:_chunkNX256LAHcjs.a.call(void 0, i),s=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).registerSigner(this.walletLocator,_chunk2GKPWQBQcjs.a.call(void 0, {signer:h,chain:this.getSignerRegistrationChain()},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}));if("error"in s)throw _chunkXDHGCS4Wcjs.a.error("wallet.addSigner.error",{error:s}),s.code===_chunkOWQZPI3Ucjs.k?new (0, _chunkOWQZPI3Ucjs.l)(s.message):new (0, _chunkOWQZPI3Ucjs.j)(`Failed to register signer: ${JSON.stringify(s.message)}`);let l=_chunkKXKBZNETcjs.b.call(void 0, s,this.chain);if(l==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let g=null;if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in s)||s.transaction==null)throw _chunkXDHGCS4Wcjs.a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");g={type:"transaction",id:s.transaction.id}}else{if(!("chains"in s))throw _chunkXDHGCS4Wcjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((S=(u=s.chains)==null?void 0:u[this.chain])==null?void 0:S.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);g=_chunkKXKBZNETcjs.c.call(void 0, s,this.chain)}return this.completeSignerRegistration(l,g,r)}))})}completeSignerRegistration(e,r,i){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i!=null&&i.prepareOnly){if(r==null)return _chunk2GKPWQBQcjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let t={transactionId:r.id};return _chunkXDHGCS4Wcjs.a.info("wallet.addSigner.prepared",t),_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),t)}case"signature":{let t={signatureId:r.id};return _chunkXDHGCS4Wcjs.a.info("wallet.addSigner.prepared",t),_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),t)}default:{let t=r.type;throw new Error(`Unknown pending operation type: ${t}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),_chunkXDHGCS4Wcjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkXDHGCS4Wcjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let t=r.type;throw new Error(`Unknown pending operation type: ${t}`)}}else _chunkXDHGCS4Wcjs.a.info("wallet.addSigner.success");return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=this.resolveSignerLocator(e);return _chunkXDHGCS4Wcjs.a.info("wallet.removeSigner.start",{signerLocator:i}),this.withRecoverySigner(()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).removeSigner(this.walletLocator,i,{chain:this.getSignerRegistrationChain()});if("error"in t)throw _chunkXDHGCS4Wcjs.a.error("wallet.removeSigner.error",{error:t}),new Error(`Failed to remove signer: ${JSON.stringify(t)}`);let o=t.id;return r!=null&&r.prepareOnly?(_chunkXDHGCS4Wcjs.a.info("wallet.removeSigner.prepared",{transactionId:o}),{transactionId:o,status:void 0}):(yield this.approveTransactionAndWait(o),_chunkXDHGCS4Wcjs.a.info("wallet.removeSigner.success",{transactionId:o}),{transactionId:o,status:"success"})}))})}useSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkXDHGCS4Wcjs.a.info("wallet.useSigner.start"),e.type==="server"&&_chunk2GKPWQBQcjs.f.call(void 0, this,x,null),this.validateSignerInput(e);let r=!1;e.type==="device"?yield this.resolveDeviceSignerAvailability(e):r=yield this.resolveNonDeviceSigner(e);let i=this.buildInternalSignerConfig(e),t=_chunkNX256LAHcjs.a.call(void 0, e);_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(i,void 0,{isAdminSigner:r})),_chunkXDHGCS4Wcjs.a.info("wallet.useSigner.success",{signerLocator:t})})}resolveNonDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return _chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!1;if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let{primary:r,legacy:i}=this.deriveServerSignerCandidates(e),t=yield this.signers();if(t.some(h=>h.locator===`server:${r.derivedAddress}`))return _chunk2GKPWQBQcjs.f.call(void 0, this,x,r),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!1;if(i!=null&&t.some(h=>h.locator===`server:${i.derivedAddress}`))return _chunk2GKPWQBQcjs.f.call(void 0, this,x,i),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!1;if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.d.call(void 0, this,L)!=null&&i!=null&&i.derivedAddress===_chunk2GKPWQBQcjs.d.call(void 0, this,L)?_chunk2GKPWQBQcjs.f.call(void 0, this,x,i):_chunk2GKPWQBQcjs.f.call(void 0, this,x,r),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),!0;let o=i!=null?`"server:${r.derivedAddress}" or "server:${i.derivedAddress}"`:`"server:${r.derivedAddress}"`;throw new Error(`Signer ${o} is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=(yield this.signers()).filter(t=>t.type==="passkey");if(i.length===0)return!1;if(i.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=i[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):_chunkNX256LAHcjs.a.call(void 0, e)}getSignerRegistrationChain(){if(!(this.chain==="solana"||this.chain==="stellar"))return this.chain}withRecoverySigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;let r=this.signer;if(_chunkEHMQ5WD7cjs.c.call(void 0, _chunk2GKPWQBQcjs.d.call(void 0, this,v)))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(_chunk2GKPWQBQcjs.d.call(void 0, this,v)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,v).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v)))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let i=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v));_chunk2GKPWQBQcjs.f.call(void 0, this,p,_chunkYWTJTAIUcjs.a.call(void 0, this.chain,i,(t=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:t.deviceSignerKeyStorage));try{return yield e()}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,p,r)}})}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.signers()).some(i=>i.locator===e)})}isSignerApproved(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;let r=yield this.getSignerState(e);return this.isApprovedSignerStatus((i=r.signer)==null?void 0:i.status)})}isApprovedSignerStatus(e){return e==="success"||e==="active"}needsRecovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,w)}recover(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o,h;if(_chunkXDHGCS4Wcjs.a.info("wallet.recover.start"),_chunk2GKPWQBQcjs.d.call(void 0, this,I)){_chunkXDHGCS4Wcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,B)){_chunkXDHGCS4Wcjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,I,!0);return}let e=()=>{_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,I,!0)};if(((o=_chunk2GKPWQBQcjs.d.call(void 0, this,p))==null?void 0:o.type)==="device"&&(yield this.checkAndResumeDeviceSigner(_chunk2GKPWQBQcjs.d.call(void 0, this,p)))){e();return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,p)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,p).type!=="device"){_chunkXDHGCS4Wcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1);return}let r=(h=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:h.deviceSignerKeyStorage;if(r==null){if(!_chunk2GKPWQBQcjs.d.call(void 0, this,w))return;throw new Error("Device signer key storage is required to recover a device signer")}let i=yield this.findLocalDeviceSigner(r);if(i!=null&&(yield this.checkAndResumeDeviceSigner(i))){_chunk2GKPWQBQcjs.f.call(void 0, this,p,i),e();let s=i.locator().replace("device:","");try{yield r.mapAddressToKey(this.address,s)}catch(l){_chunkXDHGCS4Wcjs.a.warn("wallet.recover.mapAddressToKey.error",{error:l})}return}let t=yield _chunkYHV3672Rcjs.a.call(void 0, r,this.address);try{yield this.addSigner(t)}catch(s){let l=s instanceof Error&&s.message.toLowerCase().includes("delegated signer")&&s.message.toLowerCase().includes("already")&&s.message.toLowerCase().includes("approved");if(s instanceof _chunkOWQZPI3Ucjs.l){_chunkXDHGCS4Wcjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:t.locator}),yield r.deleteKey(this.address),_chunk2GKPWQBQcjs.f.call(void 0, this,B,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,w,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,I,!0),yield this.assembleRecoverySignerFallback();return}else if(l)_chunkXDHGCS4Wcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:t.locator});else throw s instanceof _chunkEHMQ5WD7cjs.a||s instanceof Error&&s.name==="AuthRejectedError"?(_chunkXDHGCS4Wcjs.a.info("wallet.recover.device.authRejected",{signerLocator:t.locator}),s):s instanceof _chunkEHMQ5WD7cjs.b||s instanceof Error&&s.name==="OtpValidationError"?(_chunkXDHGCS4Wcjs.a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:t.locator,code:s instanceof _chunkEHMQ5WD7cjs.b?s.code:void 0}),s):(_chunkXDHGCS4Wcjs.a.error("wallet.recover.device.error",{error:s}),yield r.deleteKey(this.address),s)}_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner({type:"device",locator:t.locator,address:this.address},r)),_chunk2GKPWQBQcjs.d.call(void 0, this,p).type==="device"&&(_chunk2GKPWQBQcjs.d.call(void 0, this,p).status="success"),_chunkXDHGCS4Wcjs.a.info("wallet.recover.device.success",{signerLocator:t.locator}),e()})}checkAndResumeDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;if(this.isApprovedSignerStatus(e.status))return _chunkXDHGCS4Wcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let r=yield this.getSignerState(e.locator());return e.status=(i=r.signer)==null?void 0:i.status,r.pendingOperation!=null?(yield this.resumePendingDeviceSignerApproval(e,r.pendingOperation),!0):this.isApprovedSignerStatus(e.status)?(_chunkXDHGCS4Wcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})}resumePendingDeviceSignerApproval(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o;let i=_chunk2GKPWQBQcjs.d.call(void 0, this,p);if(_chunkEHMQ5WD7cjs.c.call(void 0, _chunk2GKPWQBQcjs.d.call(void 0, this,v)))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(_chunk2GKPWQBQcjs.d.call(void 0, this,v)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,v).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v)))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let t=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v));_chunk2GKPWQBQcjs.f.call(void 0, this,p,_chunkYWTJTAIUcjs.a.call(void 0, this.chain,t,(o=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:o.deviceSignerKeyStorage));try{r.type==="signature"?yield this.approveSignatureAndWait(r.id):yield this.approveTransactionAndWait(r.id)}catch(h){throw _chunk2GKPWQBQcjs.f.call(void 0, this,p,e),h}finally{_chunk2GKPWQBQcjs.d.call(void 0, this,p)!==e&&_chunk2GKPWQBQcjs.f.call(void 0, this,p,i)}e.status="success",_chunkXDHGCS4Wcjs.a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0})})}findLocalDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=(yield this.signers()).filter(t=>t.locator.startsWith("device:"));for(let t of i){let o=t.locator.replace("device:","");try{if(yield e.hasKey(o)){let s=_chunkYWTJTAIUcjs.a.call(void 0, this.chain,{type:"device",locator:t.locator,address:this.address},e);return _chunkXDHGCS4Wcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),s}}catch(h){_chunkXDHGCS4Wcjs.a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:t.locator,error:h})}}return null})}signers(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o,h;_chunkXDHGCS4Wcjs.a.info("wallet.signers.start");let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getWallet(this.walletLocator);if("error"in e)throw _chunkXDHGCS4Wcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkOWQZPI3Ucjs.e)(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw _chunkXDHGCS4Wcjs.a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new (0, _chunkOWQZPI3Ucjs.d)(`Wallet type ${e.type} not supported`);let r=(h=(o=e==null?void 0:e.config)==null?void 0:o.delegatedSigners)!=null?h:[],t=(yield Promise.all(r.map(s=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{return(yield this.getSignerState(s.locator)).signer}catch(l){return null}})))).filter(s=>s!=null);return _chunkXDHGCS4Wcjs.a.info("wallet.signers.success",{count:t.length}),t})}get walletLocator(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,f).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,p)==null)throw _chunk2GKPWQBQcjs.d.call(void 0, this,R).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):_chunk2GKPWQBQcjs.d.call(void 0, this,v).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
2
2
  Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`):_chunk2GKPWQBQcjs.d.call(void 0, this,v).type==="external-wallet"||!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,v))?new Error(`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
3
- Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`):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,p)}preAuthIfNeeded(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,K),_chunk2GKPWQBQcjs.d.call(void 0, this,D)==null&&_chunk2GKPWQBQcjs.f.call(void 0, this,D,this.recover());try{yield _chunk2GKPWQBQcjs.d.call(void 0, this,D)}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,D,null)}let e=this.requireSigner();e instanceof _chunkYYFLQQPVcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=_chunk2GKPWQBQcjs.d.call(void 0, this,v);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 i=o=>{if(_chunkAS2YN2YCcjs.b.call(void 0, o))return[o.address];let{primary:l,legacy:g}=this.deriveServerSignerCandidates(o),u=[l.derivedAddress];return g!=null&&u.push(g.derivedAddress),u},t=i(e),a=i(r);if(!t.some(o=>a.includes(o)))return!1}else if(_chunkNX256LAHcjs.a.call(void 0, e)!==_chunkNX256LAHcjs.a.call(void 0, r))return!1;return _chunk2GKPWQBQcjs.f.call(void 0, this,v,e),!0}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 h;let r=(h=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:h.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let i=yield r.getKey(this.address);if(i!=null){e.locator=`device:${i}`;return}let a=(yield this.signers()).filter(o=>o.locator.startsWith("device:"));for(let o of a){let l=o.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=o.locator;return}}_chunk2GKPWQBQcjs.f.call(void 0, this,w,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,I,!1)})}assembleFullSigner(a){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=(t=>(t=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:t.deviceSignerKeyStorage)(),i){var o;let h=_chunkAET7QPSVcjs.a.call(void 0, this.chain,e,r);if(i!=null&&i.isAdminSigner)h.status="active";else{let l=yield this.getSignerState(h.locator());h.status=(o=l.signer)==null?void 0:o.status}return h})}getSignerState(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;try{r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getSigner(this.walletLocator,e)}catch(t){return{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return{response:null,signer:null,pendingOperation:null};let i=_chunkKXKBZNETcjs.b.call(void 0, r,this.chain);return{response:r,signer:i,pendingOperation:_chunkKXKBZNETcjs.c.call(void 0, r,this.chain)}})}buildInternalSignerConfig(e){var r,i,t,a,h,o;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,f).crossmint,clientTEEConnection:(r=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:r.clientTEEConnection,onAuthRequired:(t=(i=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:i.callbacks)==null?void 0:t.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,f).crossmint,clientTEEConnection:(a=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:a.clientTEEConnection,onAuthRequired:(o=(h=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:h.callbacks)==null?void 0:o.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:g}=this.resolveServerSignerDerivation(e);return{type:"server",derivedKeyBytes:l,locator:`server:${g}`,address:g}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}isAutoAssemblableSignerConfig(e){var r;switch(e.type){case"email":case"phone":case"passkey":case"api-key":return!0;case"device":return((r=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:r.deviceSignerKeyStorage)!=null;case"server":return!_chunkAS2YN2YCcjs.b.call(void 0, e);case"external-wallet":return"onSign"in e&&typeof e.onSign=="function";default:return!1}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=_chunkAAUS7KTRcjs.f.call(void 0, this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,f).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 i=yield this.approveSignatureInternal(e,r);return!("error"in i)&&i.status==="success"&&i.outputSignature!=null?{signature:i.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,g;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let i=this.requireSigner(),t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getSignature(this.walletLocator,e);if("error"in t)throw new (0, _chunkOWQZPI3Ucjs.s)(JSON.stringify(t));if(i.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let u=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,u)}let a=(l=t.approvals)==null?void 0:l.pending;if(a==null||a.length===0)return t;let h=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],i],o=yield Promise.all(a.map(u=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let S=h.find(C=>C.locator()===u.signer.locator);if(S==null)throw new (0, _chunkOWQZPI3Ucjs.j)(`Signer ${u.signer.locator} not found in pending approvals`);let y=yield S.signMessage(u.message);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},y),{signer:S.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,o)})}approveTransactionInternal(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,g,u,S,y;let i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getTransaction(this.walletLocator,e);if("error"in i)throw new (0, _chunkOWQZPI3Ucjs.w)(JSON.stringify(i));yield(u=(g=(l=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:l.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:u.call(g);let t=this.requireSigner();if(t.type==="api-key")return i;if((r==null?void 0:r.approval)!=null){let C=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,C)}let a=(S=i.approvals)==null?void 0:S.pending;if(a==null||a.length===0)return i;let h=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],t],o=yield Promise.all(a.map(C=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let F=h.find(ve=>ve.locator()===C.signer.locator);if(F==null)throw new (0, _chunkOWQZPI3Ucjs.j)(`Signer ${C.signer.locator} not found in pending approvals`);let H=F.type==="device",J=i.chainType==="solana"&&"transaction"in i.onChain&&!H?i.onChain.transaction:C.message,Se=yield F.signTransaction(J);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},Se),{signer:F.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,o)})}executeApproveTransactionWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkCFB27BFVcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).approveTransaction(this.walletLocator,e,{approvals:r});if(i.error)throw new (0, _chunkOWQZPI3Ucjs.B)(JSON.stringify(i));return i})}executeApproveSignatureWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).approveSignature(this.walletLocator,e,{approvals:r});if(i.error)throw new (0, _chunkOWQZPI3Ucjs.t)(JSON.stringify(i));return i})}waitForSignature(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;do if(yield new Promise(i=>setTimeout(i,_chunkX7E2YEIVcjs.d)),r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getSignature(this.walletLocator,e),"error"in r)throw new (0, _chunkOWQZPI3Ucjs.s)(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new (0, _chunkOWQZPI3Ucjs.p)("Signature signing failed");if(!r.outputSignature)throw new (0, _chunkOWQZPI3Ucjs.s)("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(h){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=6e4,{backoffMultiplier:i=1.1,maxBackoffMs:t=2e3,initialBackoffMs:a=_chunkX7E2YEIVcjs.d}={}){var S,y;_chunkCFB27BFVcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let o=Date.now(),l;do{if(Date.now()-o>r)throw new (0, _chunkOWQZPI3Ucjs.x)("Transaction confirmation timeout");if(l=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getTransaction(this.walletLocator,e),l.error)throw new (0, _chunkOWQZPI3Ucjs.w)(JSON.stringify(l));yield this.sleep(a),a=Math.min(a*i,t)}while(l.status==="pending");if(l.status==="failed")throw new (0, _chunkOWQZPI3Ucjs.y)(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new (0, _chunkOWQZPI3Ucjs.z)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let g="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,u=(S=l.onChain.txId)!=null?S:g;if(u==null)throw new (0, _chunkOWQZPI3Ucjs.A)("Transaction hash not found on transaction response");return{hash:u,explorerLink:(y=l.onChain.explorerLink)!=null?y:"",transactionId:l.id}})}sleep(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};p=new WeakMap,A=new WeakMap,f=new WeakMap,v=new WeakMap,R=new WeakMap,w=new WeakMap,I=new WeakMap,x=new WeakMap,L=new WeakMap,$=new WeakMap,K=new WeakMap,D=new WeakMap,B=new WeakMap,_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"balances",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"stagingFund",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"send",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"approve",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"addSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"removeSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"useSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"recover",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"signers",1);function fe(m){if(typeof m=="string"){if(!_commonsdkbase.isValidAddress.call(void 0, m))throw new (0, _chunkOWQZPI3Ucjs.D)(`Invalid recipient address: "${m}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return m}if("email"in m)return`email:${m.email}`;if("x"in m)return`x:${m.x}`;if("twitter"in m)return`twitter:${m.twitter}`;if("phone"in m)return`phoneNumber:${m.phone}`;if("userId"in m)return`userId:${m.userId}`;throw new Error("Invalid recipient locator")}function we(m,e){return _commonsdkbase.isValidAddress.call(void 0, m)?`${e}:${m}`:`${e}:${m.toLowerCase()}`}exports.a = E;
3
+ Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`):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,p)}preAuthIfNeeded(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,K),_chunk2GKPWQBQcjs.d.call(void 0, this,D)==null&&_chunk2GKPWQBQcjs.f.call(void 0, this,D,this.recover());try{yield _chunk2GKPWQBQcjs.d.call(void 0, this,D)}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,D,null)}let e=this.requireSigner();e instanceof _chunkSDVBLX5Jcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=_chunk2GKPWQBQcjs.d.call(void 0, this,v);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 i=s=>{if(_chunkEHMQ5WD7cjs.c.call(void 0, s))return[s.address];let{primary:l,legacy:g}=this.deriveServerSignerCandidates(s),u=[l.derivedAddress];return g!=null&&u.push(g.derivedAddress),u},t=i(e),o=i(r);if(!t.some(s=>o.includes(s)))return!1}else if(_chunkNX256LAHcjs.a.call(void 0, e)!==_chunkNX256LAHcjs.a.call(void 0, r))return!1;return _chunk2GKPWQBQcjs.f.call(void 0, this,v,e),!0}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 h;let r=(h=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:h.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let i=yield r.getKey(this.address);if(i!=null){e.locator=`device:${i}`;return}let o=(yield this.signers()).filter(s=>s.locator.startsWith("device:"));for(let s of o){let l=s.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=s.locator;return}}_chunk2GKPWQBQcjs.f.call(void 0, this,w,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,I,!1)})}assembleFullSigner(o){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=(t=>(t=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:t.deviceSignerKeyStorage)(),i){var s;let h=_chunkYWTJTAIUcjs.a.call(void 0, this.chain,e,r);if(i!=null&&i.isAdminSigner)h.status="active";else{let l=yield this.getSignerState(h.locator());h.status=(s=l.signer)==null?void 0:s.status}return h})}getSignerState(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;try{r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getSigner(this.walletLocator,e)}catch(t){return{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return{response:null,signer:null,pendingOperation:null};let i=_chunkKXKBZNETcjs.b.call(void 0, r,this.chain);return{response:r,signer:i,pendingOperation:_chunkKXKBZNETcjs.c.call(void 0, r,this.chain)}})}buildInternalSignerConfig(e){var r,i,t,o,h,s;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,f).crossmint,clientTEEConnection:(r=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:r.clientTEEConnection,onAuthRequired:(t=(i=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:i.callbacks)==null?void 0:t.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,f).crossmint,clientTEEConnection:(o=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:o.clientTEEConnection,onAuthRequired:(s=(h=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:h.callbacks)==null?void 0:s.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:g}=this.resolveServerSignerDerivation(e);return{type:"server",derivedKeyBytes:l,locator:`server:${g}`,address:g}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}isAutoAssemblableSignerConfig(e){var r;switch(e.type){case"email":case"phone":case"passkey":case"api-key":return!0;case"device":return((r=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:r.deviceSignerKeyStorage)!=null;case"server":return!_chunkEHMQ5WD7cjs.c.call(void 0, e);case"external-wallet":return"onSign"in e&&typeof e.onSign=="function";default:return!1}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=_chunkAGN3B4GScjs.f.call(void 0, this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,f).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 i=yield this.approveSignatureInternal(e,r);return!("error"in i)&&i.status==="success"&&i.outputSignature!=null?{signature:i.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,g;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let i=this.requireSigner(),t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getSignature(this.walletLocator,e);if("error"in t)throw new (0, _chunkOWQZPI3Ucjs.s)(JSON.stringify(t));if(i.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let u=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,u)}let o=(l=t.approvals)==null?void 0:l.pending;if(o==null||o.length===0)return t;let h=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],i],s=yield Promise.all(o.map(u=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let S=h.find(C=>C.locator()===u.signer.locator);if(S==null)throw new (0, _chunkOWQZPI3Ucjs.j)(`Signer ${u.signer.locator} not found in pending approvals`);let y=yield S.signMessage(u.message);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},y),{signer:S.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,s)})}approveTransactionInternal(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,g,u,S,y;let i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getTransaction(this.walletLocator,e);if("error"in i)throw new (0, _chunkOWQZPI3Ucjs.w)(JSON.stringify(i));yield(u=(g=(l=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:l.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:u.call(g);let t=this.requireSigner();if(t.type==="api-key")return i;if((r==null?void 0:r.approval)!=null){let C=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,C)}let o=(S=i.approvals)==null?void 0:S.pending;if(o==null||o.length===0)return i;let h=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],t],s=yield Promise.all(o.map(C=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let F=h.find(fe=>fe.locator()===C.signer.locator);if(F==null)throw new (0, _chunkOWQZPI3Ucjs.j)(`Signer ${C.signer.locator} not found in pending approvals`);let H=F.type==="device",J=i.chainType==="solana"&&"transaction"in i.onChain&&!H?i.onChain.transaction:C.message,ve=yield F.signTransaction(J);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},ve),{signer:F.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,s)})}executeApproveTransactionWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkXDHGCS4Wcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).approveTransaction(this.walletLocator,e,{approvals:r});if(i.error)throw new (0, _chunkOWQZPI3Ucjs.B)(JSON.stringify(i));return i})}executeApproveSignatureWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).approveSignature(this.walletLocator,e,{approvals:r});if(i.error)throw new (0, _chunkOWQZPI3Ucjs.t)(JSON.stringify(i));return i})}waitForSignature(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;do if(yield new Promise(i=>setTimeout(i,_chunkTQCD2GORcjs.d)),r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getSignature(this.walletLocator,e),"error"in r)throw new (0, _chunkOWQZPI3Ucjs.s)(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new (0, _chunkOWQZPI3Ucjs.p)("Signature signing failed");if(!r.outputSignature)throw new (0, _chunkOWQZPI3Ucjs.s)("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(h){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=6e4,{backoffMultiplier:i=1.1,maxBackoffMs:t=2e3,initialBackoffMs:o=_chunkTQCD2GORcjs.d}={}){var S,y;_chunkXDHGCS4Wcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let s=Date.now(),l;do{if(Date.now()-s>r)throw new (0, _chunkOWQZPI3Ucjs.x)("Transaction confirmation timeout");if(l=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getTransaction(this.walletLocator,e),l.error)throw new (0, _chunkOWQZPI3Ucjs.w)(JSON.stringify(l));yield this.sleep(o),o=Math.min(o*i,t)}while(l.status==="pending");if(l.status==="failed")throw new (0, _chunkOWQZPI3Ucjs.y)(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new (0, _chunkOWQZPI3Ucjs.z)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let g="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,u=(S=l.onChain.txId)!=null?S:g;if(u==null)throw new (0, _chunkOWQZPI3Ucjs.A)("Transaction hash not found on transaction response");return{hash:u,explorerLink:(y=l.onChain.explorerLink)!=null?y:"",transactionId:l.id}})}sleep(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};p=new WeakMap,A=new WeakMap,f=new WeakMap,v=new WeakMap,R=new WeakMap,w=new WeakMap,I=new WeakMap,x=new WeakMap,L=new WeakMap,$=new WeakMap,K=new WeakMap,D=new WeakMap,B=new WeakMap,_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"balances",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"stagingFund",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"send",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"approve",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"addSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"removeSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"useSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"recover",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],E.prototype,"signers",1);function we(m){if(typeof m=="string"){if(!_commonsdkbase.isValidAddress.call(void 0, m))throw new (0, _chunkOWQZPI3Ucjs.D)(`Invalid recipient address: "${m}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return m}if("email"in m)return`email:${m.email}`;if("x"in m)return`x:${m.x}`;if("twitter"in m)return`twitter:${m.twitter}`;if("phone"in m)return`phoneNumber:${m.phone}`;if("userId"in m)return`userId:${m.userId}`;throw new Error("Invalid recipient locator")}function ye(m,e){return _commonsdkbase.isValidAddress.call(void 0, m)?`${e}:${m}`:`${e}:${m.toLowerCase()}`}exports.a = E;
@@ -1 +1 @@
1
- import{a,b as g}from"./chunk-QQ46JY33.js";import{a as s}from"./chunk-UBDPBFAR.js";import{g as t}from"./chunk-J3R36SGJ.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
1
+ import{a,b as g}from"./chunk-QJ54STYO.js";import{a as s}from"./chunk-CHX7PG2J.js";import{g as t}from"./chunk-J3R36SGJ.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOWQZPI3Ucjs = require('./chunk-OWQZPI3U.cjs');var _chunkCFB27BFVcjs = require('./chunk-CFB27BFV.cjs');var _chunkX7E2YEIVcjs = require('./chunk-X7E2YEIV.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkX7E2YEIVcjs.c,version:_chunkX7E2YEIVcjs.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`;_chunkCFB27BFVcjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let n=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in n?_chunkCFB27BFVcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkCFB27BFVcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkCFB27BFVcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkCFB27BFVcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkCFB27BFVcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),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*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.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),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()})}removeSigner(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkCFB27BFVcjs.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?_chunkCFB27BFVcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkCFB27BFVcjs.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, _chunkOWQZPI3Ucjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkOWQZPI3Ucjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOWQZPI3Ucjs = require('./chunk-OWQZPI3U.cjs');var _chunkXDHGCS4Wcjs = require('./chunk-XDHGCS4W.cjs');var _chunkTQCD2GORcjs = require('./chunk-TQCD2GOR.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkTQCD2GORcjs.c,version:_chunkTQCD2GORcjs.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`;_chunkXDHGCS4Wcjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let n=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in n?_chunkXDHGCS4Wcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkXDHGCS4Wcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkXDHGCS4Wcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkXDHGCS4Wcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkXDHGCS4Wcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),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*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.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),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()})}removeSigner(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkXDHGCS4Wcjs.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?_chunkXDHGCS4Wcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkXDHGCS4Wcjs.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, _chunkOWQZPI3Ucjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkOWQZPI3Ucjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var _chunkCFB27BFVcjs = require('./chunk-CFB27BFV.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var b={[_commonsdkbase.APIKeyEnvironmentPrefix.DEVELOPMENT]:"https://development.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.STAGING]:"https://staging.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION]:"https://devicekey.store"},P=6e4,K="indexeddb-fatal",c= exports.a =class extends _chunk3VYGTPRFcjs.a{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;let r=_commonsdkbase.getEnvironmentForKey.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){_chunkCFB27BFVcjs.a.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 _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.reloading!=null)return this.reloading;let e=_chunk2GKPWQBQcjs.g.call(void 0, 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=>_chunk2GKPWQBQcjs.g.call(void 0, 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 _ox.WebAuthnP256.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 _ox.WebAuthnP256.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}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);exports.a = c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var _chunkXDHGCS4Wcjs = require('./chunk-XDHGCS4W.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var b={[_commonsdkbase.APIKeyEnvironmentPrefix.DEVELOPMENT]:"https://development.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.STAGING]:"https://staging.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION]:"https://devicekey.store"},P=6e4,K="indexeddb-fatal",c= exports.a =class extends _chunk3VYGTPRFcjs.a{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;let r=_commonsdkbase.getEnvironmentForKey.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){_chunkXDHGCS4Wcjs.a.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 _chunk2GKPWQBQcjs.g.call(void 0, 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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.reloading!=null)return this.reloading;let e=_chunk2GKPWQBQcjs.g.call(void 0, 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=>_chunk2GKPWQBQcjs.g.call(void 0, 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 _ox.WebAuthnP256.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 _ox.WebAuthnP256.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}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);exports.a = c;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYYFLQQPVcjs = require('./chunk-YYFLQQPV.cjs');var _chunkCFB27BFVcjs = require('./chunk-CFB27BFV.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var a=class g extends _chunkYYFLQQPVcjs.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();_chunkCFB27BFVcjs.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:_chunkYYFLQQPVcjs.b});if(_chunkCFB27BFVcjs.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 _chunkSDVBLX5Jcjs = require('./chunk-SDVBLX5J.cjs');var _chunkXDHGCS4Wcjs = require('./chunk-XDHGCS4W.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var a=class g extends _chunkSDVBLX5Jcjs.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();_chunkXDHGCS4Wcjs.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:_chunkSDVBLX5Jcjs.b});if(_chunkXDHGCS4Wcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-QQ46JY33.js";import{a as r}from"./chunk-UBDPBFAR.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-QJ54STYO.js";import{a as r}from"./chunk-CHX7PG2J.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});var _chunkBTMBO7VMcjs = require('./chunk-BTMBO7VM.cjs');var _chunkAAUS7KTRcjs = require('./chunk-AAUS7KTR.cjs');var _chunkOWQZPI3Ucjs = require('./chunk-OWQZPI3U.cjs');var _chunkCFB27BFVcjs = require('./chunk-CFB27BFV.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkBTMBO7VMcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkBTMBO7VMcjs.a.getOptions(e),alias:e.alias,recovery:_chunkBTMBO7VMcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkBTMBO7VMcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkBTMBO7VMcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkBTMBO7VMcjs.a.getInitialSigners(e)},_chunkBTMBO7VMcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkCFB27BFVcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=this.buildTransaction(e),t=yield this.createTransaction(r,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkCFB27BFVcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return _chunkCFB27BFVcjs.a.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkCFB27BFVcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let r=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:r.locator(),chain:this.chain}});if("error"in t)throw _chunkCFB27BFVcjs.a.error("evmWallet.signMessage.error",{error:t}),new (0, _chunkOWQZPI3Ucjs.r)(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return _chunkCFB27BFVcjs.a.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return _chunkCFB27BFVcjs.a.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var C;_chunkCFB27BFVcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let r=this.requireSigner(),{domain:t,message:a,primaryType:i,types:g,chain:T}=e;if(!t||!a||!g||!T)throw _chunkCFB27BFVcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkOWQZPI3Ucjs.n)("Invalid typed data");let{name:m,version:S,chainId:v,verifyingContract:I,salt:D}=t;if(!m||!S||!v||!I)throw _chunkCFB27BFVcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkOWQZPI3Ucjs.n)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:S,chainId:Number(v),verifyingContract:I,salt:D},message:y(a),primaryType:i,types:g},signer:r.locator(),chain:T}});if("error"in d)throw _chunkCFB27BFVcjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunkOWQZPI3Ucjs.r)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkCFB27BFVcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let M=yield this.approveSignatureAndWait(d.id);return _chunkCFB27BFVcjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),M})}getViemClient(e){var r;return _viem.createPublicClient.call(void 0, {transport:(r=e==null?void 0:e.transport)!=null?r:_viem.http.call(void 0, ),chain:_chunkAAUS7KTRcjs.a.call(void 0, this.chain)})}createTransaction(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t;(r==null?void 0:r.signer)==null?t=this.requireSigner().locator():typeof r.signer=="string"?t=r.signer:t=this.resolveServerSignerApiLocator(r.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkOWQZPI3Ucjs.v)(JSON.stringify(a));return a})}buildTransaction(e){var r,t,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(r=e.value)==null?void 0:r.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCFB27BFVcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var b=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,r])=>[e,y(r)])):s}exports.a = b;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHF4IRNP6cjs = require('./chunk-HF4IRNP6.cjs');var _chunkAGN3B4GScjs = require('./chunk-AGN3B4GS.cjs');var _chunkOWQZPI3Ucjs = require('./chunk-OWQZPI3U.cjs');var _chunkXDHGCS4Wcjs = require('./chunk-XDHGCS4W.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkHF4IRNP6cjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkHF4IRNP6cjs.a.getOptions(e),alias:e.alias,recovery:_chunkHF4IRNP6cjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkHF4IRNP6cjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkHF4IRNP6cjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkHF4IRNP6cjs.a.getInitialSigners(e)},_chunkHF4IRNP6cjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkXDHGCS4Wcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=this.buildTransaction(e),t=yield this.createTransaction(r,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkXDHGCS4Wcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return _chunkXDHGCS4Wcjs.a.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkXDHGCS4Wcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let r=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:r.locator(),chain:this.chain}});if("error"in t)throw _chunkXDHGCS4Wcjs.a.error("evmWallet.signMessage.error",{error:t}),new (0, _chunkOWQZPI3Ucjs.r)(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return _chunkXDHGCS4Wcjs.a.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return _chunkXDHGCS4Wcjs.a.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var C;_chunkXDHGCS4Wcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let r=this.requireSigner(),{domain:t,message:a,primaryType:i,types:g,chain:T}=e;if(!t||!a||!g||!T)throw _chunkXDHGCS4Wcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkOWQZPI3Ucjs.n)("Invalid typed data");let{name:m,version:S,chainId:v,verifyingContract:I,salt:D}=t;if(!m||!S||!v||!I)throw _chunkXDHGCS4Wcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkOWQZPI3Ucjs.n)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:S,chainId:Number(v),verifyingContract:I,salt:D},message:y(a),primaryType:i,types:g},signer:r.locator(),chain:T}});if("error"in d)throw _chunkXDHGCS4Wcjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunkOWQZPI3Ucjs.r)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkXDHGCS4Wcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let M=yield this.approveSignatureAndWait(d.id);return _chunkXDHGCS4Wcjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),M})}getViemClient(e){var r;return _viem.createPublicClient.call(void 0, {transport:(r=e==null?void 0:e.transport)!=null?r:_viem.http.call(void 0, ),chain:_chunkAGN3B4GScjs.a.call(void 0, this.chain)})}createTransaction(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t;(r==null?void 0:r.signer)==null?t=this.requireSigner().locator():typeof r.signer=="string"?t=r.signer:t=this.resolveServerSignerApiLocator(r.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkOWQZPI3Ucjs.v)(JSON.stringify(a));return a})}buildTransaction(e){var r,t,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(r=e.value)==null?void 0:r.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkXDHGCS4Wcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var b=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,r])=>[e,y(r)])):s}exports.a = b;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkYYFLQQPVcjs = require('./chunk-YYFLQQPV.cjs');var _chunkCFB27BFVcjs = require('./chunk-CFB27BFV.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 _chunkYYFLQQPVcjs.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();_chunkCFB27BFVcjs.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:_chunkYYFLQQPVcjs.b});if(_chunkCFB27BFVcjs.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 _chunkSDVBLX5Jcjs = require('./chunk-SDVBLX5J.cjs');var _chunkXDHGCS4Wcjs = require('./chunk-XDHGCS4W.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 _chunkSDVBLX5Jcjs.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();_chunkXDHGCS4Wcjs.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:_chunkSDVBLX5Jcjs.b});if(_chunkXDHGCS4Wcjs.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;
@@ -0,0 +1 @@
1
+ var n=class extends Error{constructor(){super("Authentication was rejected by the user"),this.name="AuthRejectedError"}},r=class extends Error{constructor(t,i){super(t),this.name="OtpValidationError",this.code=i}};function g(e){return e.type==="server"&&!("secret"in e)}function s(e){return e._exportPrivateKey!==void 0}export{n as a,r as b,g as c,s as d};
@@ -0,0 +1 @@
1
+ import{a as m}from"./chunk-O6VBO7KG.js";import{a as l,b as f}from"./chunk-PYIURK5B.js";import{a as n}from"./chunk-CHX7PG2J.js";import{c as E,g as u}from"./chunk-J3R36SGJ.js";import{validateAPIKey as w,WithLoggerContext as y}from"@crossmint/common-sdk-base";var p=class{constructor(i){this.config=i;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 u(this,null,function*(){try{if(this.config.clientTEEConnection==null){let i=w(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new m({environment:i.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return u(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 u(this,null,function*(){n.info("TEE connection not initialized, initializing now");let i=w(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new m({environment:i.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");n.info("TEE connection initialized successfully")})}handleAuthRequired(){return u(this,null,function*(){var d;let i=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);n.info("get-status: sending request");let t=Date.now(),r=yield i.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:g}),e=Date.now()-t;if((r==null?void 0:r.status)!=="success")throw n.error("get-status: failed",{status:r==null?void 0:r.status,error:r==null?void 0:r.error,durationMs:e}),new Error(r==null?void 0:r.error);if(n.info("get-status: response received",{signerStatus:r.signerStatus,durationMs:e}),r.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;n.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:a,resolve:s,reject:c}=this.createAuthPromise();if(this._authPromise={promise:a,resolve:s,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),o=>this.verifyOtp(o),()=>u(this,null,function*(){n.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(),o=>this.verifyOtp(o),()=>{var o;return(o=this._authPromise)==null?void 0:o.reject(new l)})),c(new l)}))}catch(o){n.error("handleAuthRequired error",{error:o}),c(o)}try{yield a}catch(o){throw n.error("handleAuthRequired promise error",{error:o}),o}})}ensureAuthenticated(){return u(this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null)throw new Error("JWT is required");return i}createAuthPromise(){let i,t;return{promise:new Promise((e,a)=>{i=e,t=a}),resolve:i,reject:t}}sendMessageWithOtp(){return u(this,null,function*(){var s,c;let i=yield this.getTEEConnection(),t=this.getAuthId();n.info("start-onboarding: sending request");let r=Date.now(),e=yield i.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:g}),a=Date.now()-r;if(n.info("start-onboarding: response received",{status:e==null?void 0:e.status,durationMs:a}),(e==null?void 0:e.status)==="success"&&e.signerStatus==="ready"){this._needsAuth=!1;return}if((e==null?void 0:e.status)==="error"){n.error("start-onboarding: failed",{error:e.error,code:e.code});let d=new f(e.error||"Failed to initiate OTP process.",e.code);(c=this._authPromise)==null||c.reject(d)}})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(i){return u(this,null,function*(){var s,c,d,o;let t;try{let h=yield this.getTEEConnection();n.info("complete-onboarding: sending request");let v=Date.now();t=yield h.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:i}}},options:g}),n.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-v})}catch(h){throw n.error("complete-onboarding: error",{error:h}),this._needsAuth=!0,(c=this._authPromise)==null||c.reject(h),h}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(),h=>this.verifyOtp(h),()=>{var h;return(h=this._authPromise)==null?void 0:h.reject(new l)})),(d=this._authPromise)==null||d.resolve();return}n.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0}),this._needsAuth=!0;let r=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",e=(t==null?void 0:t.status)==="error"?t.code:void 0,a=new f(r,e);throw(o=this._authPromise)==null||o.reject(a),a})}_exportPrivateKey(i,t){return u(this,null,function*(){yield this.handleAuthRequired();let r=this.getJwtOrThrow(),{scheme:e,encoding:a}=this.getChainKeyParams();if(t!=null){let c=i.on("event:key-exported",d=>{i.off(c),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let s=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:r,apiKey:this.config.crossmint.apiKey},data:{scheme:e,encoding:a}},options:g});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};E([y({logger:n,methodName:"handleAuthRequired"})],p.prototype,"handleAuthRequired",1);var g={timeoutMs:3e4};export{p as a,g as b};
@@ -0,0 +1 @@
1
+ import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{b as i,c as s}from"./chunk-5OYPWGMX.js";import{a as E}from"./chunk-CHX7PG2J.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as R,arbitrum as N,arbitrumNova as p,modeTestnet as h,mode as d,mainnet as f,bsc as W,shape as U,zora as V,zoraSepolia as B,sepolia as y,flowMainnet as H,flowTestnet as v,plume as x,plumeTestnet as b}from"viem/chains";var w=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],D=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.ETHEREUM,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function ee(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return R;case e.ARBITRUM:return N;case e.ARBITRUMNOVA:return p;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return W;case e.SHAPE:return U;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return y;case e.ETHEREUM:return f;case e.FLOW:return H;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return b;case e.PLUME:return x;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return w.includes(t)}function C(t){return D.includes(t)}var Y={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.ETHEREUM]:e.ETHEREUM_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function g(t){return Y[t]}function F(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function te(t,a){if(!F(t))throw new s(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=g(r);if(n!=null)return E.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;E.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}export{ee as a,I as b,C as c,g as d,F as e,te as f};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJBP52JOHcjs = require('./chunk-JBP52JOH.cjs');var _chunkEHMQ5WD7cjs = require('./chunk-EHMQ5WD7.cjs');var _chunkXDHGCS4Wcjs = require('./chunk-XDHGCS4W.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var p=class{constructor(i){this.config=i;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 i=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:i.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*(){_chunkXDHGCS4Wcjs.a.info("TEE connection not initialized, initializing now");let i=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:i.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkXDHGCS4Wcjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d;let i=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);_chunkXDHGCS4Wcjs.a.info("get-status: sending request");let t=Date.now(),r=yield i.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:g}),e=Date.now()-t;if((r==null?void 0:r.status)!=="success")throw _chunkXDHGCS4Wcjs.a.error("get-status: failed",{status:r==null?void 0:r.status,error:r==null?void 0:r.error,durationMs:e}),new Error(r==null?void 0:r.error);if(_chunkXDHGCS4Wcjs.a.info("get-status: response received",{signerStatus:r.signerStatus,durationMs:e}),r.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkXDHGCS4Wcjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:a,resolve:s,reject:c}=this.createAuthPromise();if(this._authPromise={promise:a,resolve:s,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),o=>this.verifyOtp(o),()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkXDHGCS4Wcjs.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(),o=>this.verifyOtp(o),()=>{var o;return(o=this._authPromise)==null?void 0:o.reject(new _chunkEHMQ5WD7cjs.a)})),c(new _chunkEHMQ5WD7cjs.a)}))}catch(o){_chunkXDHGCS4Wcjs.a.error("handleAuthRequired error",{error:o}),c(o)}try{yield a}catch(o){throw _chunkXDHGCS4Wcjs.a.error("handleAuthRequired promise error",{error:o}),o}})}ensureAuthenticated(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null)throw new Error("JWT is required");return i}createAuthPromise(){let i,t;return{promise:new Promise((e,a)=>{i=e,t=a}),resolve:i,reject:t}}sendMessageWithOtp(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,c;let i=yield this.getTEEConnection(),t=this.getAuthId();_chunkXDHGCS4Wcjs.a.info("start-onboarding: sending request");let r=Date.now(),e=yield i.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:g}),a=Date.now()-r;if(_chunkXDHGCS4Wcjs.a.info("start-onboarding: response received",{status:e==null?void 0:e.status,durationMs:a}),(e==null?void 0:e.status)==="success"&&e.signerStatus==="ready"){this._needsAuth=!1;return}if((e==null?void 0:e.status)==="error"){_chunkXDHGCS4Wcjs.a.error("start-onboarding: failed",{error:e.error,code:e.code});let d=new (0, _chunkEHMQ5WD7cjs.b)(e.error||"Failed to initiate OTP process.",e.code);(c=this._authPromise)==null||c.reject(d)}})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(i){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,c,d,o;let t;try{let h=yield this.getTEEConnection();_chunkXDHGCS4Wcjs.a.info("complete-onboarding: sending request");let v=Date.now();t=yield h.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:i}}},options:g}),_chunkXDHGCS4Wcjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-v})}catch(h){throw _chunkXDHGCS4Wcjs.a.error("complete-onboarding: error",{error:h}),this._needsAuth=!0,(c=this._authPromise)==null||c.reject(h),h}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(),h=>this.verifyOtp(h),()=>{var h;return(h=this._authPromise)==null?void 0:h.reject(new _chunkEHMQ5WD7cjs.a)})),(d=this._authPromise)==null||d.resolve();return}_chunkXDHGCS4Wcjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0}),this._needsAuth=!0;let r=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",e=(t==null?void 0:t.status)==="error"?t.code:void 0,a=new (0, _chunkEHMQ5WD7cjs.b)(r,e);throw(o=this._authPromise)==null||o.reject(a),a})}_exportPrivateKey(i,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired();let r=this.getJwtOrThrow(),{scheme:e,encoding:a}=this.getChainKeyParams();if(t!=null){let c=i.on("event:key-exported",d=>{i.off(c),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let s=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:r,apiKey:this.config.crossmint.apiKey},data:{scheme:e,encoding:a}},options:g});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:_chunkXDHGCS4Wcjs.a,methodName:"handleAuthRequired"})],p.prototype,"handleAuthRequired",1);var g={timeoutMs:3e4};exports.a = p; exports.b = g;
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-QQ46JY33.js";import{a as r}from"./chunk-UBDPBFAR.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-QJ54STYO.js";import{a as r}from"./chunk-CHX7PG2J.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 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYYFLQQPVcjs = require('./chunk-YYFLQQPV.cjs');var _chunkCFB27BFVcjs = require('./chunk-CFB27BFV.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkYYFLQQPVcjs.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","");_chunkCFB27BFVcjs.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:_chunkYYFLQQPVcjs.b});if(_chunkCFB27BFVcjs.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 _chunkSDVBLX5Jcjs = require('./chunk-SDVBLX5J.cjs');var _chunkXDHGCS4Wcjs = require('./chunk-XDHGCS4W.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkSDVBLX5Jcjs.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","");_chunkXDHGCS4Wcjs.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:_chunkSDVBLX5Jcjs.b});if(_chunkXDHGCS4Wcjs.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 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.4.0";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =500;exports.a = p; exports.b = c; exports.c = r; exports.d = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.5.0";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =500;exports.a = p; exports.b = c; exports.c = r; exports.d = a;