@crossmint/wallets-sdk 1.20.0 → 1.20.1

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 (123) hide show
  1. package/dist/api/__tests__/test-utils.cjs +1 -1
  2. package/dist/api/__tests__/test-utils.js +1 -1
  3. package/dist/api/client.cjs +1 -1
  4. package/dist/api/client.js +1 -1
  5. package/dist/api/index.cjs +1 -1
  6. package/dist/api/index.js +1 -1
  7. package/dist/chains/adapters/evm.cjs +1 -1
  8. package/dist/chains/adapters/evm.js +1 -1
  9. package/dist/chains/adapters/solana.cjs +1 -1
  10. package/dist/chains/adapters/solana.js +1 -1
  11. package/dist/chains/adapters/stellar.cjs +1 -1
  12. package/dist/chains/adapters/stellar.js +1 -1
  13. package/dist/chains/chain-adapter.cjs +1 -1
  14. package/dist/chains/chain-adapter.js +1 -1
  15. package/dist/chains/chains.cjs +1 -1
  16. package/dist/chains/chains.d.cts +2 -2
  17. package/dist/chains/chains.d.ts +2 -2
  18. package/dist/chains/chains.js +1 -1
  19. package/dist/{chunk-N3W3FP2G.js → chunk-2SQXN4JL.js} +1 -1
  20. package/dist/{chunk-LH6A7CFO.cjs → chunk-3GWEE56X.cjs} +1 -1
  21. package/dist/{chunk-75NMYYJY.cjs → chunk-3HUNEWAR.cjs} +1 -1
  22. package/dist/{chunk-OQINX6EJ.js → chunk-3RWQHOBG.js} +1 -1
  23. package/dist/{chunk-W4GCZ4UZ.js → chunk-4VGTYVW7.js} +1 -1
  24. package/dist/{chunk-BQZHLT2Q.js → chunk-6EPYTT7A.js} +1 -1
  25. package/dist/{chunk-ZLR6K3KY.cjs → chunk-754XJCSX.cjs} +1 -1
  26. package/dist/chunk-A4F6GFJC.cjs +1 -0
  27. package/dist/{chunk-GYXKGRZY.js → chunk-AMGE2J7V.js} +1 -1
  28. package/dist/{chunk-H4RL6UJU.js → chunk-AOZ2VVTT.js} +1 -1
  29. package/dist/{chunk-PTGEMNUR.js → chunk-BF5VS7HX.js} +1 -1
  30. package/dist/{chunk-T4FKMQ6Y.js → chunk-C2R47XW6.js} +1 -1
  31. package/dist/{chunk-TJXUJBM7.cjs → chunk-DFJ63LIQ.cjs} +1 -1
  32. package/dist/{chunk-32GROW5L.js → chunk-DVVGWCH7.js} +1 -1
  33. package/dist/{chunk-FS72XBWN.cjs → chunk-ENLWAIYV.cjs} +1 -1
  34. package/dist/{chunk-MZPMVQ5J.js → chunk-GFK67DR4.js} +1 -1
  35. package/dist/{chunk-UNAH34G2.cjs → chunk-H52MPNZP.cjs} +1 -1
  36. package/dist/{chunk-3I2MB7SJ.js → chunk-HODQMDIV.js} +1 -1
  37. package/dist/{chunk-AWIDML36.js → chunk-I3FLN7RY.js} +1 -1
  38. package/dist/{chunk-CPXJHFSR.cjs → chunk-IHIJ7G64.cjs} +1 -1
  39. package/dist/{chunk-BGQ4QX25.cjs → chunk-IYWWY7T5.cjs} +1 -1
  40. package/dist/{chunk-LX55L36L.js → chunk-J7N56JUE.js} +1 -1
  41. package/dist/{chunk-HADAG3ZB.js → chunk-JAP6U3CJ.js} +1 -1
  42. package/dist/{chunk-QUYYIVZB.js → chunk-KNAIS6WY.js} +1 -1
  43. package/dist/{chunk-MPIIBOOK.cjs → chunk-KUT3FS3U.cjs} +1 -1
  44. package/dist/{chunk-U73R5Z3Z.cjs → chunk-LRWKIVXL.cjs} +1 -1
  45. package/dist/chunk-MFQX2HNH.js +1 -0
  46. package/dist/{chunk-5DVT5DB6.cjs → chunk-NBZEWJUH.cjs} +1 -1
  47. package/dist/{chunk-TI6QPYIE.cjs → chunk-NHNNPXP7.cjs} +1 -1
  48. package/dist/chunk-NULQLE3D.js +1 -0
  49. package/dist/{chunk-M2AM4CBT.cjs → chunk-O673DZDX.cjs} +1 -1
  50. package/dist/{chunk-5T2BUXCF.cjs → chunk-OAFFHV5G.cjs} +1 -1
  51. package/dist/{chunk-FXKT7O4T.js → chunk-PEHDJW5W.js} +1 -1
  52. package/dist/{chunk-DNAHI43Y.cjs → chunk-PQ4LAXVO.cjs} +1 -1
  53. package/dist/{chunk-KCO6YNJR.cjs → chunk-QD53EMTK.cjs} +1 -1
  54. package/dist/{chunk-YIUOOMT4.js → chunk-QNNWOOHI.js} +1 -1
  55. package/dist/{chunk-5YNL2XRE.cjs → chunk-R3CAXQLJ.cjs} +1 -1
  56. package/dist/{chunk-QUOYTOHY.js → chunk-RAQFOCJT.js} +1 -1
  57. package/dist/{chunk-FWONJJK4.js → chunk-SGLJQXKH.js} +1 -1
  58. package/dist/{chunk-BSRBEBBA.cjs → chunk-SINS7Z5F.cjs} +1 -1
  59. package/dist/chunk-TISVJEJ4.cjs +1 -0
  60. package/dist/{chunk-FWPLRK7S.cjs → chunk-VRA6S3DJ.cjs} +1 -1
  61. package/dist/{chunk-N4DNCKHY.cjs → chunk-VRO4EPRC.cjs} +1 -1
  62. package/dist/chunk-VUCADC63.cjs +1 -0
  63. package/dist/{chunk-IAPGBR2Z.js → chunk-WQ7JSD6A.js} +1 -1
  64. package/dist/{chunk-IX646CRE.cjs → chunk-WS27JTIY.cjs} +1 -1
  65. package/dist/{chunk-NDTDJCCO.js → chunk-YHPZJA2F.js} +1 -1
  66. package/dist/{chunk-IMJ2V4F4.js → chunk-YNOT3UTT.js} +1 -1
  67. package/dist/chunk-Z4OBKN5C.js +1 -0
  68. package/dist/{chunk-MQEPGBWN.cjs → chunk-Z6CVEP22.cjs} +1 -1
  69. package/dist/index.cjs +1 -1
  70. package/dist/index.js +1 -1
  71. package/dist/logger/index.cjs +1 -1
  72. package/dist/logger/index.js +1 -1
  73. package/dist/logger/init.cjs +1 -1
  74. package/dist/logger/init.js +1 -1
  75. package/dist/sdk.cjs +1 -1
  76. package/dist/sdk.js +1 -1
  77. package/dist/signers/index.cjs +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.js +1 -1
  81. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  82. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  83. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  84. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  85. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  86. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  87. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  88. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  89. package/dist/utils/constants.cjs +1 -1
  90. package/dist/utils/constants.js +1 -1
  91. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  92. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  93. package/dist/utils/device-signers/index.cjs +1 -1
  94. package/dist/utils/device-signers/index.js +1 -1
  95. package/dist/utils/recovery.cjs +1 -1
  96. package/dist/utils/recovery.js +1 -1
  97. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  98. package/dist/wallets/__tests__/test-helpers.js +1 -1
  99. package/dist/wallets/evm.cjs +1 -1
  100. package/dist/wallets/evm.js +1 -1
  101. package/dist/wallets/services/balance-formatter.cjs +1 -1
  102. package/dist/wallets/services/balance-formatter.js +1 -1
  103. package/dist/wallets/services/device-recovery-service.cjs +1 -1
  104. package/dist/wallets/services/device-recovery-service.js +1 -1
  105. package/dist/wallets/services/operation-poller.cjs +1 -1
  106. package/dist/wallets/services/operation-poller.js +1 -1
  107. package/dist/wallets/services/signer-manager.cjs +1 -1
  108. package/dist/wallets/services/signer-manager.js +1 -1
  109. package/dist/wallets/solana.cjs +1 -1
  110. package/dist/wallets/solana.js +1 -1
  111. package/dist/wallets/stellar.cjs +1 -1
  112. package/dist/wallets/stellar.js +1 -1
  113. package/dist/wallets/wallet-factory.cjs +1 -1
  114. package/dist/wallets/wallet-factory.js +1 -1
  115. package/dist/wallets/wallet.cjs +1 -1
  116. package/dist/wallets/wallet.js +1 -1
  117. package/package.json +5 -5
  118. package/dist/chunk-7TVBGFKY.js +0 -1
  119. package/dist/chunk-FY4JJ3QZ.cjs +0 -1
  120. package/dist/chunk-JVBAZHA6.js +0 -1
  121. package/dist/chunk-UV3NUVR3.js +0 -1
  122. package/dist/chunk-X5PKHTFG.cjs +0 -1
  123. package/dist/chunk-XIO3CEXH.cjs +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5DVT5DB6cjs = require('./chunk-5DVT5DB6.cjs');var _chunkXIO3CEXHcjs = require('./chunk-XIO3CEXH.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunk5DVT5DB6cjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk5DVT5DB6cjs.a.getOptions(e),alias:e.alias,recovery:_chunk5DVT5DB6cjs.a.getRecoverySigners(e),apiRecoveryServerSignerAddresses:_chunk5DVT5DB6cjs.a.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:_chunk5DVT5DB6cjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk5DVT5DB6cjs.a.getInitialSigners(e)},_chunk5DVT5DB6cjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkM2AM4CBTcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=this.buildTransaction(e),r=yield this.createTransaction(t,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkM2AM4CBTcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return _chunkM2AM4CBTcjs.a.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkM2AM4CBTcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),r=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:t.locator(),chain:this.chain}});if("error"in r)throw _chunkM2AM4CBTcjs.a.error("evmWallet.signMessage.error",{error:r}),new (0, _chunkD2S37DJ5cjs.D)(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return _chunkM2AM4CBTcjs.a.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return _chunkM2AM4CBTcjs.a.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var C;_chunkM2AM4CBTcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),{domain:r,message:a,primaryType:i,types:g,chain:T}=e;if(!r||!a||!g||!T)throw _chunkM2AM4CBTcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkD2S37DJ5cjs.z)("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw _chunkM2AM4CBTcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkD2S37DJ5cjs.z)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:v,chainId:Number(S),verifyingContract:I,salt:b},message:y(a),primaryType:i,types:g},signer:t.locator(),chain:T}});if("error"in d)throw _chunkM2AM4CBTcjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunkD2S37DJ5cjs.D)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkM2AM4CBTcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return _chunkM2AM4CBTcjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return _viem.createPublicClient.call(void 0, {transport:(t=e==null?void 0:e.transport)!=null?t:_viem.http.call(void 0, ),chain:_chunkXIO3CEXHcjs.a.call(void 0, this.chain)})}createTransaction(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r;(t==null?void 0:t.signer)==null?r=this.signerManager.require().locator():typeof t.signer=="string"?r=t.signer:r=this.resolveServerSignerApiLocator(t.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:r,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkD2S37DJ5cjs.I)(JSON.stringify(a));return a})}buildTransaction(e){var t,r,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(r=(t=e.value)==null?void 0:t.toString())!=null?r:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var M=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,y(t)])):s}exports.a = M;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkNBZEWJUHcjs = require('./chunk-NBZEWJUH.cjs');var _chunkA4F6GFJCcjs = require('./chunk-A4F6GFJC.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkNBZEWJUHcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkNBZEWJUHcjs.a.getOptions(e),alias:e.alias,recovery:_chunkNBZEWJUHcjs.a.getRecoverySigners(e),apiRecoveryServerSignerAddresses:_chunkNBZEWJUHcjs.a.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:_chunkNBZEWJUHcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkNBZEWJUHcjs.a.getInitialSigners(e)},_chunkNBZEWJUHcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkO673DZDXcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=this.buildTransaction(e),r=yield this.createTransaction(t,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkO673DZDXcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return _chunkO673DZDXcjs.a.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;_chunkO673DZDXcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),r=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:t.locator(),chain:this.chain}});if("error"in r)throw _chunkO673DZDXcjs.a.error("evmWallet.signMessage.error",{error:r}),new (0, _chunkD2S37DJ5cjs.D)(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return _chunkO673DZDXcjs.a.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return _chunkO673DZDXcjs.a.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var C;_chunkO673DZDXcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),{domain:r,message:a,primaryType:i,types:g,chain:T}=e;if(!r||!a||!g||!T)throw _chunkO673DZDXcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkD2S37DJ5cjs.z)("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw _chunkO673DZDXcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkD2S37DJ5cjs.z)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:v,chainId:Number(S),verifyingContract:I,salt:b},message:y(a),primaryType:i,types:g},signer:t.locator(),chain:T}});if("error"in d)throw _chunkO673DZDXcjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunkD2S37DJ5cjs.D)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkO673DZDXcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return _chunkO673DZDXcjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return _viem.createPublicClient.call(void 0, {transport:(t=e==null?void 0:e.transport)!=null?t:_viem.http.call(void 0, ),chain:_chunkA4F6GFJCcjs.a.call(void 0, this.chain)})}createTransaction(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r;(t==null?void 0:t.signer)==null?r=this.signerManager.require().locator():typeof t.signer=="string"?r=t.signer:r=this.resolveServerSignerApiLocator(t.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:r,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkD2S37DJ5cjs.I)(JSON.stringify(a));return a})}buildTransaction(e){var t,r,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(r=(t=e.value)==null?void 0:t.toString())!=null?r:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var M=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,y(t)])):s}exports.a = M;
@@ -1 +1 @@
1
- import{a as i}from"./chunk-YIUOOMT4.js";import a from"bs58";import{Base64 as o,Hex as s}from"ox";function d(n){let e=a.decode(n)[0];return e!=null&&(e&128)!==0&&(e&127)===1}function c(n){return"transaction"in n.onChain&&typeof n.onChain.transaction=="string"?n.onChain.transaction:void 0}var m={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,e,r){if(!("transaction"in n)||n.transaction==null)throw i.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");return{type:"transaction",id:n.transaction.id}},balanceTokenFields(n){return n!=null&&"mintHash"in n?{mintHash:n.mintHash}:n!=null&&"contractAddress"in n?{contractAddress:n.contractAddress}:{}},emptyBalanceTokenFields(){return{mintHash:void 0}},signApproval(n,e,r){var t;return n.type==="passkey"?n.signTransaction(s.fromBytes(o.toBytes(r))):n.type!=="external-wallet"?n.signTransaction(r):d(r)?n.signMessage(r):n.signTransaction((t=c(e))!=null?t:r)}};export{m as a};
1
+ import{a as i}from"./chunk-QNNWOOHI.js";import a from"bs58";import{Base64 as o,Hex as s}from"ox";function d(n){let e=a.decode(n)[0];return e!=null&&(e&128)!==0&&(e&127)===1}function c(n){return"transaction"in n.onChain&&typeof n.onChain.transaction=="string"?n.onChain.transaction:void 0}var m={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,e,r){if(!("transaction"in n)||n.transaction==null)throw i.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");return{type:"transaction",id:n.transaction.id}},balanceTokenFields(n){return n!=null&&"mintHash"in n?{mintHash:n.mintHash}:n!=null&&"contractAddress"in n?{contractAddress:n.contractAddress}:{}},emptyBalanceTokenFields(){return{mintHash:void 0}},signApproval(n,e,r){var t;return n.type==="passkey"?n.signTransaction(s.fromBytes(o.toBytes(r))):n.type!=="external-wallet"?n.signTransaction(r):d(r)?n.signMessage(r):n.signTransaction((t=c(e))!=null?t:r)}};export{m as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.20.0";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =200;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.20.1";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =200;exports.a = p; exports.b = c; exports.c = r; exports.d = a;
@@ -1 +1 @@
1
- import{a as r}from"./chunk-32GROW5L.js";import{a as f}from"./chunk-ECKSTWA3.js";import{I as h}from"./chunk-4I3EXM4B.js";import{a as t}from"./chunk-YIUOOMT4.js";import{c as u,h as l}from"./chunk-NU7VF7MC.js";import p from"bs58";import m from"tweetnacl";import{isValidSolanaAddress as y,WithLoggerContext as v}from"@crossmint/common-sdk-base";var c=class c extends r{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:r.getOptions(e),alias:e.alias,recovery:r.getRecoverySigners(e),apiRecoveryServerSignerAddresses:r.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:r.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:r.getInitialSigners(e)},r.getApiClient(e))}static from(e){if(!y(e.address))throw new Error("Wallet is not a Solana wallet");return new c(e)}sendTransaction(e){return l(this,null,function*(){var g,S;t.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((g=e.options)!=null&&g.prepareOnly)return t.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(S=e.additionalSigners)==null?void 0:S.map(o=>new f({type:"external-wallet",address:o.publicKey.toString(),locator:`external-wallet:${o.publicKey.toString()}`,onSign:d=>(d.sign([o]),Promise.resolve(d)),onSignBytes:d=>Promise.resolve(p.encode(m.sign.detached(p.decode(d),o.secretKey)))}))},a=yield this.approveTransactionAndWait(n.id,i);return t.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return l(this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.signerManager.require().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=p.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new h(JSON.stringify(i));return i})}};u([v({logger:t,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1);var T=c;export{T as a};
1
+ import{a as r}from"./chunk-DVVGWCH7.js";import{a as f}from"./chunk-ECKSTWA3.js";import{I as h}from"./chunk-4I3EXM4B.js";import{a as t}from"./chunk-QNNWOOHI.js";import{c as u,h as l}from"./chunk-NU7VF7MC.js";import p from"bs58";import m from"tweetnacl";import{isValidSolanaAddress as y,WithLoggerContext as v}from"@crossmint/common-sdk-base";var c=class c extends r{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:r.getOptions(e),alias:e.alias,recovery:r.getRecoverySigners(e),apiRecoveryServerSignerAddresses:r.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:r.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:r.getInitialSigners(e)},r.getApiClient(e))}static from(e){if(!y(e.address))throw new Error("Wallet is not a Solana wallet");return new c(e)}sendTransaction(e){return l(this,null,function*(){var g,S;t.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((g=e.options)!=null&&g.prepareOnly)return t.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(S=e.additionalSigners)==null?void 0:S.map(o=>new f({type:"external-wallet",address:o.publicKey.toString(),locator:`external-wallet:${o.publicKey.toString()}`,onSign:d=>(d.sign([o]),Promise.resolve(d)),onSignBytes:d=>Promise.resolve(p.encode(m.sign.detached(p.decode(d),o.secretKey)))}))},a=yield this.approveTransactionAndWait(n.id,i);return t.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return l(this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.signerManager.require().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=p.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new h(JSON.stringify(i));return i})}};u([v({logger:t,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1);var T=c;export{T as a};
@@ -1 +1 @@
1
- import{a as o}from"./chunk-UV3NUVR3.js";import{a as n}from"./chunk-5LNDUSMZ.js";import{a as s}from"./chunk-IAPGBR2Z.js";import{a as i,b as l}from"./chunk-YIUOOMT4.js";import{h as r}from"./chunk-NU7VF7MC.js";import{createCrossmint as w}from"@crossmint/common-sdk-base";import{WebAuthnP256 as y}from"ox";var c=class p{constructor(e){l(e.apiKey);let t=new s(e);this.walletFactory=new o(t),i.info("wallets.sdk.initialized")}static from(e){return new p(e)}getWallet(e,t){return r(this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return r(this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return r(this,null,function*(){return yield n(e,t)})}createPasskeySigner(e,t){return r(this,null,function*(){let a=t?yield t.createPasskey(e):yield y.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}};export{w as a,c as b};
1
+ import{a as o}from"./chunk-MFQX2HNH.js";import{a as n}from"./chunk-5LNDUSMZ.js";import{a as s}from"./chunk-WQ7JSD6A.js";import{a as i,b as l}from"./chunk-QNNWOOHI.js";import{h as r}from"./chunk-NU7VF7MC.js";import{createCrossmint as w}from"@crossmint/common-sdk-base";import{WebAuthnP256 as y}from"ox";var c=class p{constructor(e){l(e.apiKey);let t=new s(e);this.walletFactory=new o(t),i.info("wallets.sdk.initialized")}static from(e){return new p(e)}getWallet(e,t){return r(this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return r(this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return r(this,null,function*(){return yield n(e,t)})}createPasskeySigner(e,t){return r(this,null,function*(){let a=t?yield t.createPasskey(e):yield y.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}};export{w as a,c as b};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkXTYSMO67cjs = require('./chunk-XTYSMO67.cjs');var _chunkU73R5Z3Zcjs = require('./chunk-U73R5Z3Z.cjs');var _chunk664ATEWTcjs = require('./chunk-664ATEWT.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var l,m,C,S,y,o,b,A,k,L,K,P,u,q,I,B,$,z,V= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,l,"unknown");_chunkDSIFRRBScjs.e.call(void 0, this,m,!1);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,o);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,k);_chunkDSIFRRBScjs.e.call(void 0, this,L);_chunkDSIFRRBScjs.e.call(void 0, this,K);_chunkDSIFRRBScjs.e.call(void 0, this,P);_chunkDSIFRRBScjs.f.call(void 0, this,C,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,S,r.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,y,r.options),_chunkDSIFRRBScjs.f.call(void 0, this,o,r.signerManager),_chunkDSIFRRBScjs.f.call(void 0, this,b,r.serverSignerResolver),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.signers),_chunkDSIFRRBScjs.f.call(void 0, this,k,r.addSigner),_chunkDSIFRRBScjs.f.call(void 0, this,L,r.removeSigner),_chunkDSIFRRBScjs.f.call(void 0, this,K,r.approveSignature),_chunkDSIFRRBScjs.f.call(void 0, this,P,r.approveTransaction)}get needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"}onSignerSelected(){_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"&&_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown")}initDeviceSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g;if(((g=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:g.deviceSignerKeyStorage)==null||_chunkDSIFRRBScjs.d.call(void 0, this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(h){_chunkM2AM4CBTcjs.a.error("wallet.initDeviceSigner.error",{error:h}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery");return}if(_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery")return;let c=_chunkXTYSMO67cjs.a.call(void 0, i.type).buildInternalConfig(i,_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext()),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(c);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(t),_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(t.status)||(_chunkM2AM4CBTcjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery"))})}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var D;if(_chunkM2AM4CBTcjs.a.info("wallet.recover.start"),_chunkDSIFRRBScjs.d.call(void 0, this,l)==="resolved"){_chunkM2AM4CBTcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunkDSIFRRBScjs.d.call(void 0, this,m)){_chunkM2AM4CBTcjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}let r=_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,I).call(this,r))){_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}if(r!=null&&r.type!=="device"){_chunkM2AM4CBTcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let i=(D=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let c=yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this),t=yield _chunkDSIFRRBScjs.g.call(void 0, this,u,$).call(this,i,c);if(t!=null&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,I).call(this,t))){_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(t),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");let n=t.locator().replace("device:","");try{yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,S),n)}catch(G){_chunkM2AM4CBTcjs.a.warn("wallet.recover.mapAddressToKey.error",{error:G})}return}let g=c.filter(n=>n.type==="device"),h=_chunkDSIFRRBScjs.g.call(void 0, this,u,q).call(this,g,i),v=yield _chunkGMU3ZYLScjs.a.call(void 0, i,_chunkDSIFRRBScjs.d.call(void 0, this,S));try{yield _chunkDSIFRRBScjs.d.call(void 0, this,k).call(this,v)}catch(n){if(n instanceof _chunkD2S37DJ5cjs.m){_chunkM2AM4CBTcjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,S)),_chunkDSIFRRBScjs.f.call(void 0, this,m,!0),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),yield _chunkDSIFRRBScjs.g.call(void 0, this,u,z).call(this);return}else if(H(n))_chunkM2AM4CBTcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw n instanceof _chunk664ATEWTcjs.a||n instanceof Error&&n.name==="AuthRejectedError"?(_chunkM2AM4CBTcjs.a.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),n):n instanceof _chunk664ATEWTcjs.c||n instanceof Error&&n.name==="SignerAuthenticationError"?(_chunkM2AM4CBTcjs.a.warn("wallet.recover.device.authenticationFailed",{signerLocator:v.locator,code:n instanceof _chunk664ATEWTcjs.c?n.code:void 0}),n):n instanceof _chunk664ATEWTcjs.b||n instanceof Error&&n.name==="OtpValidationError"?(_chunkM2AM4CBTcjs.a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:n instanceof _chunk664ATEWTcjs.b?n.code:void 0}),n):(_chunkM2AM4CBTcjs.a.error("wallet.recover.device.error",{error:n}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,S)),n)}let p=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble({type:"device",locator:v.locator,address:_chunkDSIFRRBScjs.d.call(void 0, this,S)});if(_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(p),p.type==="device"&&(p.status="success"),_chunkM2AM4CBTcjs.a.info("wallet.recover.device.success",{signerLocator:v.locator}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),h!=null)try{yield _chunkDSIFRRBScjs.d.call(void 0, this,L).call(this,h),_chunkM2AM4CBTcjs.a.info("wallet.recover.staleSignerRemoved",{signerLocator:h})}catch(n){_chunkM2AM4CBTcjs.a.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:h,error:n})}})}resolveAvailability(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h;let i=(h=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:h.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let c=yield i.getKey(_chunkDSIFRRBScjs.d.call(void 0, this,S));if(c!=null){r.locator=`device:${c}`,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let g=(yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let p=v.locator.replace("device:","");if(yield i.hasKey(p)){yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,S),p),r.locator=v.locator,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}}_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(r,i=(c=>(c=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:c.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield _chunkU73R5Z3Zcjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),r,_chunkDSIFRRBScjs.d.call(void 0, this,S),i)}catch(g){return _chunkM2AM4CBTcjs.a.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakMap,y=new WeakMap,o=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,q=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let c=i.getDeviceName(),t=r.filter(g=>g.name===c);return t.length===1?t[0].locator:void 0},I=function(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var c;if(_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(r.status))return _chunkM2AM4CBTcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).getSignerState(r.locator());return r.status=(c=i.signer)==null?void 0:c.status,i.pendingOperation!=null?(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,B).call(this,r,i.pendingOperation),!0):_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(r.status)?(_chunkM2AM4CBTcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},B=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var p;let c=_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner,t=_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery;if(_chunk664ATEWTcjs.g.call(void 0, t)&&!_chunkDSIFRRBScjs.d.call(void 0, this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=_chunkXTYSMO67cjs.a.call(void 0, t.type),h=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,h))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,h);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(_chunkU73R5Z3Zcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),v,(p=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:p.deviceSignerKeyStorage));try{i.type==="signature"?yield _chunkDSIFRRBScjs.d.call(void 0, this,K).call(this,i.id):yield _chunkDSIFRRBScjs.d.call(void 0, this,P).call(this,i.id)}catch(D){throw _chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(r),D}finally{_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner!==r&&_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(c)}r.status="success",_chunkM2AM4CBTcjs.a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},$=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let c=i.filter(t=>t.locator.startsWith("device:"));for(let t of c){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return _chunkM2AM4CBTcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},z=function(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery,i=_chunkXTYSMO67cjs.a.call(void 0, r.type),c=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext();if(i.canAutoAssemble(r,c))try{let t=i.buildInternalConfig(r,c);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(t,{isAdminSigner:!0}))}catch(t){_chunkM2AM4CBTcjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function H(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}exports.a = V;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkXTYSMO67cjs = require('./chunk-XTYSMO67.cjs');var _chunkLRWKIVXLcjs = require('./chunk-LRWKIVXL.cjs');var _chunk664ATEWTcjs = require('./chunk-664ATEWT.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var l,m,C,S,y,o,b,A,k,L,K,P,u,q,I,B,$,z,V= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,l,"unknown");_chunkDSIFRRBScjs.e.call(void 0, this,m,!1);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.e.call(void 0, this,o);_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,A);_chunkDSIFRRBScjs.e.call(void 0, this,k);_chunkDSIFRRBScjs.e.call(void 0, this,L);_chunkDSIFRRBScjs.e.call(void 0, this,K);_chunkDSIFRRBScjs.e.call(void 0, this,P);_chunkDSIFRRBScjs.f.call(void 0, this,C,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,S,r.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,y,r.options),_chunkDSIFRRBScjs.f.call(void 0, this,o,r.signerManager),_chunkDSIFRRBScjs.f.call(void 0, this,b,r.serverSignerResolver),_chunkDSIFRRBScjs.f.call(void 0, this,A,r.signers),_chunkDSIFRRBScjs.f.call(void 0, this,k,r.addSigner),_chunkDSIFRRBScjs.f.call(void 0, this,L,r.removeSigner),_chunkDSIFRRBScjs.f.call(void 0, this,K,r.approveSignature),_chunkDSIFRRBScjs.f.call(void 0, this,P,r.approveTransaction)}get needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"}onSignerSelected(){_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery"&&_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown")}initDeviceSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g;if(((g=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:g.deviceSignerKeyStorage)==null||_chunkDSIFRRBScjs.d.call(void 0, this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(h){_chunkO673DZDXcjs.a.error("wallet.initDeviceSigner.error",{error:h}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery");return}if(_chunkDSIFRRBScjs.d.call(void 0, this,l)==="needs-recovery")return;let c=_chunkXTYSMO67cjs.a.call(void 0, i.type).buildInternalConfig(i,_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext()),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(c);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(t),_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(t.status)||(_chunkO673DZDXcjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery"))})}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var D;if(_chunkO673DZDXcjs.a.info("wallet.recover.start"),_chunkDSIFRRBScjs.d.call(void 0, this,l)==="resolved"){_chunkO673DZDXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunkDSIFRRBScjs.d.call(void 0, this,m)){_chunkO673DZDXcjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}let r=_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,I).call(this,r))){_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");return}if(r!=null&&r.type!=="device"){_chunkO673DZDXcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let i=(D=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let c=yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this),t=yield _chunkDSIFRRBScjs.g.call(void 0, this,u,$).call(this,i,c);if(t!=null&&(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,I).call(this,t))){_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(t),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved");let n=t.locator().replace("device:","");try{yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,S),n)}catch(G){_chunkO673DZDXcjs.a.warn("wallet.recover.mapAddressToKey.error",{error:G})}return}let g=c.filter(n=>n.type==="device"),h=_chunkDSIFRRBScjs.g.call(void 0, this,u,q).call(this,g,i),v=yield _chunkGMU3ZYLScjs.a.call(void 0, i,_chunkDSIFRRBScjs.d.call(void 0, this,S));try{yield _chunkDSIFRRBScjs.d.call(void 0, this,k).call(this,v)}catch(n){if(n instanceof _chunkD2S37DJ5cjs.m){_chunkO673DZDXcjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,S)),_chunkDSIFRRBScjs.f.call(void 0, this,m,!0),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),yield _chunkDSIFRRBScjs.g.call(void 0, this,u,z).call(this);return}else if(H(n))_chunkO673DZDXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw n instanceof _chunk664ATEWTcjs.a||n instanceof Error&&n.name==="AuthRejectedError"?(_chunkO673DZDXcjs.a.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),n):n instanceof _chunk664ATEWTcjs.c||n instanceof Error&&n.name==="SignerAuthenticationError"?(_chunkO673DZDXcjs.a.warn("wallet.recover.device.authenticationFailed",{signerLocator:v.locator,code:n instanceof _chunk664ATEWTcjs.c?n.code:void 0}),n):n instanceof _chunk664ATEWTcjs.b||n instanceof Error&&n.name==="OtpValidationError"?(_chunkO673DZDXcjs.a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:n instanceof _chunk664ATEWTcjs.b?n.code:void 0}),n):(_chunkO673DZDXcjs.a.error("wallet.recover.device.error",{error:n}),yield i.deleteKey(_chunkDSIFRRBScjs.d.call(void 0, this,S)),n)}let p=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble({type:"device",locator:v.locator,address:_chunkDSIFRRBScjs.d.call(void 0, this,S)});if(_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(p),p.type==="device"&&(p.status="success"),_chunkO673DZDXcjs.a.info("wallet.recover.device.success",{signerLocator:v.locator}),_chunkDSIFRRBScjs.f.call(void 0, this,l,"resolved"),h!=null)try{yield _chunkDSIFRRBScjs.d.call(void 0, this,L).call(this,h),_chunkO673DZDXcjs.a.info("wallet.recover.staleSignerRemoved",{signerLocator:h})}catch(n){_chunkO673DZDXcjs.a.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:h,error:n})}})}resolveAvailability(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h;let i=(h=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:h.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let c=yield i.getKey(_chunkDSIFRRBScjs.d.call(void 0, this,S));if(c!=null){r.locator=`device:${c}`,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}let g=(yield _chunkDSIFRRBScjs.d.call(void 0, this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let p=v.locator.replace("device:","");if(yield i.hasKey(p)){yield i.mapAddressToKey(_chunkDSIFRRBScjs.d.call(void 0, this,S),p),r.locator=v.locator,_chunkDSIFRRBScjs.f.call(void 0, this,l,"unknown");return}}_chunkDSIFRRBScjs.f.call(void 0, this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(r,i=(c=>(c=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:c.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield _chunkLRWKIVXLcjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),r,_chunkDSIFRRBScjs.d.call(void 0, this,S),i)}catch(g){return _chunkO673DZDXcjs.a.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakMap,y=new WeakMap,o=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,q=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let c=i.getDeviceName(),t=r.filter(g=>g.name===c);return t.length===1?t[0].locator:void 0},I=function(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var c;if(_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(r.status))return _chunkO673DZDXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).getSignerState(r.locator());return r.status=(c=i.signer)==null?void 0:c.status,i.pendingOperation!=null?(yield _chunkDSIFRRBScjs.g.call(void 0, this,u,B).call(this,r,i.pendingOperation),!0):_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(r.status)?(_chunkO673DZDXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},B=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var p;let c=_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner,t=_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery;if(_chunk664ATEWTcjs.g.call(void 0, t)&&!_chunkDSIFRRBScjs.d.call(void 0, this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=_chunkXTYSMO67cjs.a.call(void 0, t.type),h=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,h))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,h);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(_chunkLRWKIVXLcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,C),v,(p=_chunkDSIFRRBScjs.d.call(void 0, this,y))==null?void 0:p.deviceSignerKeyStorage));try{i.type==="signature"?yield _chunkDSIFRRBScjs.d.call(void 0, this,K).call(this,i.id):yield _chunkDSIFRRBScjs.d.call(void 0, this,P).call(this,i.id)}catch(D){throw _chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(r),D}finally{_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner!==r&&_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(c)}r.status="success",_chunkO673DZDXcjs.a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},$=function(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let c=i.filter(t=>t.locator.startsWith("device:"));for(let t of c){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return _chunkO673DZDXcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},z=function(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery,i=_chunkXTYSMO67cjs.a.call(void 0, r.type),c=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext();if(i.canAutoAssemble(r,c))try{let t=i.buildInternalConfig(r,c);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(t,{isAdminSigner:!0}))}catch(t){_chunkO673DZDXcjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function H(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}exports.a = V;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMQEPGBWNcjs = require('./chunk-MQEPGBWN.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a=class g extends _chunkMQEPGBWNcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow();_chunkM2AM4CBTcjs.a.info("sign: sending request",{keyType:"ed25519"});let c=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:n,encoding:"base64",authId:this.getAuthId()}},options:_chunkMQEPGBWNcjs.b});if(_chunkM2AM4CBTcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-c}),(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 _chunkZ6CVEP22cjs = require('./chunk-Z6CVEP22.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a=class g extends _chunkZ6CVEP22cjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow();_chunkO673DZDXcjs.a.info("sign: sending request",{keyType:"ed25519"});let c=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:n,encoding:"base64",authId:this.getAuthId()}},options:_chunkZ6CVEP22cjs.b});if(_chunkO673DZDXcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-c}),(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 N}from"./chunk-5LNDUSMZ.js";import{a as R}from"./chunk-HDVUDIDC.js";import{a as M,b as j}from"./chunk-W4GCZ4UZ.js";import{a as O,b as E,c as F,g as T}from"./chunk-43LFPZII.js";import{m as W}from"./chunk-4I3EXM4B.js";import{a}from"./chunk-YIUOOMT4.js";import{d as e,e as d,f as s,g as w,h as f}from"./chunk-NU7VF7MC.js";var l,m,C,S,y,o,b,A,k,L,K,P,u,q,I,B,$,z,V=class{constructor(r){d(this,u);d(this,l,"unknown");d(this,m,!1);d(this,C);d(this,S);d(this,y);d(this,o);d(this,b);d(this,A);d(this,k);d(this,L);d(this,K);d(this,P);s(this,C,r.chain),s(this,S,r.walletAddress),s(this,y,r.options),s(this,o,r.signerManager),s(this,b,r.serverSignerResolver),s(this,A,r.signers),s(this,k,r.addSigner),s(this,L,r.removeSigner),s(this,K,r.approveSignature),s(this,P,r.approveTransaction)}get needsRecovery(){return e(this,l)==="needs-recovery"}onSignerSelected(){e(this,l)==="needs-recovery"&&s(this,l,"unknown")}initDeviceSigner(){return f(this,null,function*(){var g;if(((g=e(this,y))==null?void 0:g.deviceSignerKeyStorage)==null||e(this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(h){a.error("wallet.initDeviceSigner.error",{error:h}),s(this,l,"needs-recovery");return}if(e(this,l)==="needs-recovery")return;let c=R(i.type).buildInternalConfig(i,e(this,o).descriptorContext()),t=yield e(this,o).assemble(c);e(this,o).setActiveSigner(t),e(this,o).isApprovedSignerStatus(t.status)||(a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),s(this,l,"needs-recovery"))})}recover(){return f(this,null,function*(){var D;if(a.info("wallet.recover.start"),e(this,l)==="resolved"){a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(e(this,m)){a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),s(this,l,"resolved");return}let r=e(this,o).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield w(this,u,I).call(this,r))){s(this,l,"resolved");return}if(r!=null&&r.type!=="device"){a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),s(this,l,"unknown");return}let i=(D=e(this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(e(this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let c=yield e(this,A).call(this),t=yield w(this,u,$).call(this,i,c);if(t!=null&&(yield w(this,u,I).call(this,t))){e(this,o).setActiveSigner(t),s(this,l,"resolved");let n=t.locator().replace("device:","");try{yield i.mapAddressToKey(e(this,S),n)}catch(G){a.warn("wallet.recover.mapAddressToKey.error",{error:G})}return}let g=c.filter(n=>n.type==="device"),h=w(this,u,q).call(this,g,i),v=yield N(i,e(this,S));try{yield e(this,k).call(this,v)}catch(n){if(n instanceof W){a.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(e(this,S)),s(this,m,!0),s(this,l,"resolved"),yield w(this,u,z).call(this);return}else if(H(n))a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw n instanceof O||n instanceof Error&&n.name==="AuthRejectedError"?(a.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),n):n instanceof F||n instanceof Error&&n.name==="SignerAuthenticationError"?(a.warn("wallet.recover.device.authenticationFailed",{signerLocator:v.locator,code:n instanceof F?n.code:void 0}),n):n instanceof E||n instanceof Error&&n.name==="OtpValidationError"?(a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:n instanceof E?n.code:void 0}),n):(a.error("wallet.recover.device.error",{error:n}),yield i.deleteKey(e(this,S)),n)}let p=yield e(this,o).assemble({type:"device",locator:v.locator,address:e(this,S)});if(e(this,o).setActiveSigner(p),p.type==="device"&&(p.status="success"),a.info("wallet.recover.device.success",{signerLocator:v.locator}),s(this,l,"resolved"),h!=null)try{yield e(this,L).call(this,h),a.info("wallet.recover.staleSignerRemoved",{signerLocator:h})}catch(n){a.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:h,error:n})}})}resolveAvailability(r){return f(this,null,function*(){var h;let i=(h=e(this,y))==null?void 0:h.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let c=yield i.getKey(e(this,S));if(c!=null){r.locator=`device:${c}`,s(this,l,"unknown");return}let g=(yield e(this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let p=v.locator.replace("device:","");if(yield i.hasKey(p)){yield i.mapAddressToKey(e(this,S),p),r.locator=v.locator,s(this,l,"unknown");return}}s(this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return f(this,arguments,function*(r,i=(c=>(c=e(this,y))==null?void 0:c.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield j(e(this,C),r,e(this,S),i)}catch(g){return a.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakMap,y=new WeakMap,o=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,q=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let c=i.getDeviceName(),t=r.filter(g=>g.name===c);return t.length===1?t[0].locator:void 0},I=function(r){return f(this,null,function*(){var c;if(e(this,o).isApprovedSignerStatus(r.status))return a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield e(this,o).getSignerState(r.locator());return r.status=(c=i.signer)==null?void 0:c.status,i.pendingOperation!=null?(yield w(this,u,B).call(this,r,i.pendingOperation),!0):e(this,o).isApprovedSignerStatus(r.status)?(a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},B=function(r,i){return f(this,null,function*(){var p;let c=e(this,o).activeSigner,t=e(this,o).recovery;if(T(t)&&!e(this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=R(t.type),h=e(this,o).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,h))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,h);e(this,o).setActiveSigner(M(e(this,C),v,(p=e(this,y))==null?void 0:p.deviceSignerKeyStorage));try{i.type==="signature"?yield e(this,K).call(this,i.id):yield e(this,P).call(this,i.id)}catch(D){throw e(this,o).setActiveSigner(r),D}finally{e(this,o).activeSigner!==r&&e(this,o).setActiveSigner(c)}r.status="success",a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},$=function(r,i){return f(this,null,function*(){let c=i.filter(t=>t.locator.startsWith("device:"));for(let t of c){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},z=function(){return f(this,null,function*(){let r=e(this,o).recovery,i=R(r.type),c=e(this,o).descriptorContext();if(i.canAutoAssemble(r,c))try{let t=i.buildInternalConfig(r,c);e(this,o).setActiveSigner(yield e(this,o).assemble(t,{isAdminSigner:!0}))}catch(t){a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function H(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}export{V as a};
1
+ import{a as N}from"./chunk-5LNDUSMZ.js";import{a as R}from"./chunk-HDVUDIDC.js";import{a as M,b as j}from"./chunk-4VGTYVW7.js";import{a as O,b as E,c as F,g as T}from"./chunk-43LFPZII.js";import{m as W}from"./chunk-4I3EXM4B.js";import{a}from"./chunk-QNNWOOHI.js";import{d as e,e as d,f as s,g as w,h as f}from"./chunk-NU7VF7MC.js";var l,m,C,S,y,o,b,A,k,L,K,P,u,q,I,B,$,z,V=class{constructor(r){d(this,u);d(this,l,"unknown");d(this,m,!1);d(this,C);d(this,S);d(this,y);d(this,o);d(this,b);d(this,A);d(this,k);d(this,L);d(this,K);d(this,P);s(this,C,r.chain),s(this,S,r.walletAddress),s(this,y,r.options),s(this,o,r.signerManager),s(this,b,r.serverSignerResolver),s(this,A,r.signers),s(this,k,r.addSigner),s(this,L,r.removeSigner),s(this,K,r.approveSignature),s(this,P,r.approveTransaction)}get needsRecovery(){return e(this,l)==="needs-recovery"}onSignerSelected(){e(this,l)==="needs-recovery"&&s(this,l,"unknown")}initDeviceSigner(){return f(this,null,function*(){var g;if(((g=e(this,y))==null?void 0:g.deviceSignerKeyStorage)==null||e(this,m))return;let i={type:"device"};try{yield this.resolveAvailability(i)}catch(h){a.error("wallet.initDeviceSigner.error",{error:h}),s(this,l,"needs-recovery");return}if(e(this,l)==="needs-recovery")return;let c=R(i.type).buildInternalConfig(i,e(this,o).descriptorContext()),t=yield e(this,o).assemble(c);e(this,o).setActiveSigner(t),e(this,o).isApprovedSignerStatus(t.status)||(a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),s(this,l,"needs-recovery"))})}recover(){return f(this,null,function*(){var D;if(a.info("wallet.recover.start"),e(this,l)==="resolved"){a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(e(this,m)){a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),s(this,l,"resolved");return}let r=e(this,o).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield w(this,u,I).call(this,r))){s(this,l,"resolved");return}if(r!=null&&r.type!=="device"){a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),s(this,l,"unknown");return}let i=(D=e(this,y))==null?void 0:D.deviceSignerKeyStorage;if(i==null){if(e(this,l)!=="needs-recovery")return;throw new Error("Device signer key storage is required to recover a device signer")}let c=yield e(this,A).call(this),t=yield w(this,u,$).call(this,i,c);if(t!=null&&(yield w(this,u,I).call(this,t))){e(this,o).setActiveSigner(t),s(this,l,"resolved");let n=t.locator().replace("device:","");try{yield i.mapAddressToKey(e(this,S),n)}catch(G){a.warn("wallet.recover.mapAddressToKey.error",{error:G})}return}let g=c.filter(n=>n.type==="device"),h=w(this,u,q).call(this,g,i),v=yield N(i,e(this,S));try{yield e(this,k).call(this,v)}catch(n){if(n instanceof W){a.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(e(this,S)),s(this,m,!0),s(this,l,"resolved"),yield w(this,u,z).call(this);return}else if(H(n))a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw n instanceof O||n instanceof Error&&n.name==="AuthRejectedError"?(a.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),n):n instanceof F||n instanceof Error&&n.name==="SignerAuthenticationError"?(a.warn("wallet.recover.device.authenticationFailed",{signerLocator:v.locator,code:n instanceof F?n.code:void 0}),n):n instanceof E||n instanceof Error&&n.name==="OtpValidationError"?(a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:n instanceof E?n.code:void 0}),n):(a.error("wallet.recover.device.error",{error:n}),yield i.deleteKey(e(this,S)),n)}let p=yield e(this,o).assemble({type:"device",locator:v.locator,address:e(this,S)});if(e(this,o).setActiveSigner(p),p.type==="device"&&(p.status="success"),a.info("wallet.recover.device.success",{signerLocator:v.locator}),s(this,l,"resolved"),h!=null)try{yield e(this,L).call(this,h),a.info("wallet.recover.staleSignerRemoved",{signerLocator:h})}catch(n){a.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:h,error:n})}})}resolveAvailability(r){return f(this,null,function*(){var h;let i=(h=e(this,y))==null?void 0:h.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let c=yield i.getKey(e(this,S));if(c!=null){r.locator=`device:${c}`,s(this,l,"unknown");return}let g=(yield e(this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let p=v.locator.replace("device:","");if(yield i.hasKey(p)){yield i.mapAddressToKey(e(this,S),p),r.locator=v.locator,s(this,l,"unknown");return}}s(this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return f(this,arguments,function*(r,i=(c=>(c=e(this,y))==null?void 0:c.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield j(e(this,C),r,e(this,S),i)}catch(g){return a.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,S=new WeakMap,y=new WeakMap,o=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,q=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let c=i.getDeviceName(),t=r.filter(g=>g.name===c);return t.length===1?t[0].locator:void 0},I=function(r){return f(this,null,function*(){var c;if(e(this,o).isApprovedSignerStatus(r.status))return a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield e(this,o).getSignerState(r.locator());return r.status=(c=i.signer)==null?void 0:c.status,i.pendingOperation!=null?(yield w(this,u,B).call(this,r,i.pendingOperation),!0):e(this,o).isApprovedSignerStatus(r.status)?(a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},B=function(r,i){return f(this,null,function*(){var p;let c=e(this,o).activeSigner,t=e(this,o).recovery;if(T(t)&&!e(this,b).hasRecoveryResolutionFor(t.address))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let g=R(t.type),h=e(this,o).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,h))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let v=g.buildInternalConfig(t,h);e(this,o).setActiveSigner(M(e(this,C),v,(p=e(this,y))==null?void 0:p.deviceSignerKeyStorage));try{i.type==="signature"?yield e(this,K).call(this,i.id):yield e(this,P).call(this,i.id)}catch(D){throw e(this,o).setActiveSigner(r),D}finally{e(this,o).activeSigner!==r&&e(this,o).setActiveSigner(c)}r.status="success",a.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},$=function(r,i){return f(this,null,function*(){let c=i.filter(t=>t.locator.startsWith("device:"));for(let t of c){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},z=function(){return f(this,null,function*(){let r=e(this,o).recovery,i=R(r.type),c=e(this,o).descriptorContext();if(i.canAutoAssemble(r,c))try{let t=i.buildInternalConfig(r,c);e(this,o).setActiveSigner(yield e(this,o).assemble(t,{isAdminSigner:!0}))}catch(t){a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function H(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}export{V as a};
@@ -1 +1 @@
1
- import{a as t}from"./chunk-OQINX6EJ.js";import{a}from"./chunk-MZPMVQ5J.js";import{a as i}from"./chunk-FWONJJK4.js";import{a as r}from"./chunk-OQZTL6ZG.js";var n={evm:t,solana:a,stellar:i};function m(e){return n[r(e)]}function p(e){return Object.prototype.hasOwnProperty.call(n,e)}function A(e,o){return p(e)?n[e]:o}export{m as a,p as b,A as c};
1
+ import{a as t}from"./chunk-3RWQHOBG.js";import{a}from"./chunk-GFK67DR4.js";import{a as i}from"./chunk-SGLJQXKH.js";import{a as r}from"./chunk-OQZTL6ZG.js";var n={evm:t,solana:a,stellar:i};function m(e){return n[r(e)]}function p(e){return Object.prototype.hasOwnProperty.call(n,e)}function A(e,o){return p(e)?n[e]:o}export{m as a,p as b,A as c};
@@ -1 +1 @@
1
- import{a as m}from"./chunk-HADAG3ZB.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(e,s){var l,t,r,i,a;let n=(l=e.chains)==null?void 0:l[s],c=m(s).balanceTokenFields(n);return u(u(u(u({symbol:(t=e.symbol)!=null?t:"",name:(r=e.name)!=null?r:"",amount:(i=e.amount)!=null?i:"0",decimals:e.decimals,rawAmount:(a=e.rawAmount)!=null?a:"0"},(n==null?void 0:n.available)!=null?{available:n.available}:{}),(n==null?void 0:n.locked)!=null?{locked:n.locked}:{}),(n==null?void 0:n.accounts)!=null?{accounts:n.accounts}:{}),c)}function B(e,s){let n={symbol:e,name:e,amount:"0",decimals:0,rawAmount:"0"},c=m(s).emptyBalanceTokenFields();return u(u({},n),c)}function b(e,s,n){var r,i,a,f,p;if(s==null)return!0;let c=((r=e.symbol)!=null?r:"").toLowerCase();if(s.has(c))return!0;let l=(i=e.chains)==null?void 0:i[n];if(l==null)return!1;let t=C(n);if(t==="solana"&&"mintHash"in l){let o=(a=l.mintHash)==null?void 0:a.toLowerCase();return o!=null&&(s.has(o)||s.has(`solana:${o}`))}if(t==="stellar"&&"contractId"in l){let o=(f=l.contractId)==null?void 0:f.toLowerCase();return o!=null&&(s.has(o)||s.has(`stellar:${o}`))}if("contractAddress"in l){let o=(p=l.contractAddress)==null?void 0:p.toLowerCase();return o!=null&&(s.has(o)||s.has(`${n}:${o}`))}return!1}function g(e,s,n,c){let l=e.find(a=>a.symbol===n),t=e.find(a=>a.symbol==="usdc"),r=c!=null?new Set(c.map(a=>a.toLowerCase())):null,i=e.filter(a=>a.symbol!==n&&a.symbol!=="usdc"&&b(a,r,s));return{nativeToken:l!=null?d(l,s):B(n,s),usdc:t!=null?d(t,s):B("usdc",s),tokens:i.map(a=>d(a,s))}}export{g as a};
1
+ import{a as m}from"./chunk-JAP6U3CJ.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(e,s){var l,t,r,i,a;let n=(l=e.chains)==null?void 0:l[s],c=m(s).balanceTokenFields(n);return u(u(u(u({symbol:(t=e.symbol)!=null?t:"",name:(r=e.name)!=null?r:"",amount:(i=e.amount)!=null?i:"0",decimals:e.decimals,rawAmount:(a=e.rawAmount)!=null?a:"0"},(n==null?void 0:n.available)!=null?{available:n.available}:{}),(n==null?void 0:n.locked)!=null?{locked:n.locked}:{}),(n==null?void 0:n.accounts)!=null?{accounts:n.accounts}:{}),c)}function B(e,s){let n={symbol:e,name:e,amount:"0",decimals:0,rawAmount:"0"},c=m(s).emptyBalanceTokenFields();return u(u({},n),c)}function b(e,s,n){var r,i,a,f,p;if(s==null)return!0;let c=((r=e.symbol)!=null?r:"").toLowerCase();if(s.has(c))return!0;let l=(i=e.chains)==null?void 0:i[n];if(l==null)return!1;let t=C(n);if(t==="solana"&&"mintHash"in l){let o=(a=l.mintHash)==null?void 0:a.toLowerCase();return o!=null&&(s.has(o)||s.has(`solana:${o}`))}if(t==="stellar"&&"contractId"in l){let o=(f=l.contractId)==null?void 0:f.toLowerCase();return o!=null&&(s.has(o)||s.has(`stellar:${o}`))}if("contractAddress"in l){let o=(p=l.contractAddress)==null?void 0:p.toLowerCase();return o!=null&&(s.has(o)||s.has(`${n}:${o}`))}return!1}function g(e,s,n,c){let l=e.find(a=>a.symbol===n),t=e.find(a=>a.symbol==="usdc"),r=c!=null?new Set(c.map(a=>a.toLowerCase())):null,i=e.filter(a=>a.symbol!==n&&a.symbol!=="usdc"&&b(a,r,s));return{nativeToken:l!=null?d(l,s):B(n,s),usdc:t!=null?d(t,s):B("usdc",s),tokens:i.map(a=>d(a,s))}}export{g as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkUNAH34G2cjs = require('./chunk-UNAH34G2.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var l=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkUNAH34G2cjs.c,version:_chunkUNAH34G2cjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkM2AM4CBTcjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let t=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in t?_chunkM2AM4CBTcjs.a.error("wallets.api.createWallet.error",{error:t.error,chainType:e.chainType}):"address"in t&&_chunkM2AM4CBTcjs.a.info("wallets.api.createWallet.success",{address:t.address,chainType:e.chainType}),t})}getWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkM2AM4CBTcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkM2AM4CBTcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkM2AM4CBTcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return t.status===422?this.getSignature(e,s):t.json()})}getSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=encodeURIComponent(s),a=new URLSearchParams;r.chain&&a.append("chain",r.chain),r.approver!=null&&a.append("approver",r.approver);let o=`${this.apiPrefix}/${e}/signers/${t}${a.size>0?`?${a.toString()}`:""}`;return(yield this.delete(o,{headers:this.headers})).json()})}registerRecoveryMethod(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/recovery-methods`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeRecoveryMethod(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=encodeURIComponent(s),a=new URLSearchParams;return r.chain!=null&&a.append("chain",r.chain),a.append("approver",r.approver),(yield this.delete(`${this.apiPrefix}/${e}/recovery-methods/${t}?${a.toString()}`,{headers:this.headers})).json()})}getSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=encodeURIComponent(s),t=yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers});if(!t.ok){let a=null;try{a=yield t.text()}catch(o){}throw new (0, _commonsdkbase.ApiClientError)(`API request failed: ${t.status} ${t.statusText}`,t.status,t.statusText,a)}return t.json()})}send(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkM2AM4CBTcjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let a=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in a?_chunkM2AM4CBTcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:a.error}):"id"in a&&_chunkM2AM4CBTcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:a.id}),a})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkD2S37DJ5cjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkD2S37DJ5cjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = l;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkH52MPNZPcjs = require('./chunk-H52MPNZP.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var l=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkH52MPNZPcjs.c,version:_chunkH52MPNZPcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkO673DZDXcjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let t=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in t?_chunkO673DZDXcjs.a.error("wallets.api.createWallet.error",{error:t.error,chainType:e.chainType}):"address"in t&&_chunkO673DZDXcjs.a.info("wallets.api.createWallet.success",{address:t.address,chainType:e.chainType}),t})}getWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkO673DZDXcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkO673DZDXcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return t.status===422?this.getSignature(e,s):t.json()})}getSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=encodeURIComponent(s),a=new URLSearchParams;r.chain&&a.append("chain",r.chain),r.approver!=null&&a.append("approver",r.approver);let o=`${this.apiPrefix}/${e}/signers/${t}${a.size>0?`?${a.toString()}`:""}`;return(yield this.delete(o,{headers:this.headers})).json()})}registerRecoveryMethod(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/recovery-methods`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeRecoveryMethod(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=encodeURIComponent(s),a=new URLSearchParams;return r.chain!=null&&a.append("chain",r.chain),a.append("approver",r.approver),(yield this.delete(`${this.apiPrefix}/${e}/recovery-methods/${t}?${a.toString()}`,{headers:this.headers})).json()})}getSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=encodeURIComponent(s),t=yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers});if(!t.ok){let a=null;try{a=yield t.text()}catch(o){}throw new (0, _commonsdkbase.ApiClientError)(`API request failed: ${t.status} ${t.statusText}`,t.status,t.statusText,a)}return t.json()})}send(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let a=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in a?_chunkO673DZDXcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:a.error}):"id"in a&&_chunkO673DZDXcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:a.id}),a})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkD2S37DJ5cjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkD2S37DJ5cjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = l;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkLH6A7CFOcjs = require('./chunk-LH6A7CFO.cjs');var _chunkDNAHI43Ycjs = require('./chunk-DNAHI43Y.cjs');var _chunkBGQ4QX25cjs = require('./chunk-BGQ4QX25.cjs');var _chunk7FIAYQ4Ocjs = require('./chunk-7FIAYQ4O.cjs');var _chunk5GYSXH4Xcjs = require('./chunk-5GYSXH4X.cjs');var _chunk5FVDLMWWcjs = require('./chunk-5FVDLMWW.cjs');var _chunkXWQC6G7Ncjs = require('./chunk-XWQC6G7N.cjs');var _chunkR4SBFRTMcjs = require('./chunk-R4SBFRTM.cjs');var _chunkHYWIWJ6Hcjs = require('./chunk-HYWIWJ6H.cjs');var _chunk4M6KYXG7cjs = require('./chunk-4M6KYXG7.cjs');var _chunkCDHMNLZ6cjs = require('./chunk-CDHMNLZ6.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function c(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new (0, _chunkDNAHI43Ycjs.a)(e):r==="stellar"?new (0, _chunkBGQ4QX25cjs.a)(e):new (0, _chunkLH6A7CFOcjs.a)(e);case"api-key":return r==="solana"?new (0, _chunkCDHMNLZ6cjs.a)(e):new (0, _chunkR4SBFRTMcjs.a)(e);case"external-wallet":return r==="solana"?new (0, _chunk5GYSXH4Xcjs.a)(e):r==="stellar"?new (0, _chunk5FVDLMWWcjs.a)(e):new (0, _chunkHYWIWJ6Hcjs.a)(e);case"server":return _chunk7FIAYQ4Ocjs.a.call(void 0, r,e);case"passkey":return new (0, _chunk4M6KYXG7cjs.a)(e);case"device":if(n==null)throw new (0, _chunkD2S37DJ5cjs.g)("Device signer key storage is required for device signers");return new (0, _chunkXWQC6G7Ncjs.a)(e,n)}}function b(r,e,n,a){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(!e.startsWith("device:"))return null;let w=e.replace("device:","");return(yield a.hasKey(w))?c(r,{type:"device",locator:e,address:n},a):null})}exports.a = c; exports.b = b;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3GWEE56Xcjs = require('./chunk-3GWEE56X.cjs');var _chunkPQ4LAXVOcjs = require('./chunk-PQ4LAXVO.cjs');var _chunkIYWWY7T5cjs = require('./chunk-IYWWY7T5.cjs');var _chunk7FIAYQ4Ocjs = require('./chunk-7FIAYQ4O.cjs');var _chunk5GYSXH4Xcjs = require('./chunk-5GYSXH4X.cjs');var _chunk5FVDLMWWcjs = require('./chunk-5FVDLMWW.cjs');var _chunkXWQC6G7Ncjs = require('./chunk-XWQC6G7N.cjs');var _chunkR4SBFRTMcjs = require('./chunk-R4SBFRTM.cjs');var _chunkHYWIWJ6Hcjs = require('./chunk-HYWIWJ6H.cjs');var _chunk4M6KYXG7cjs = require('./chunk-4M6KYXG7.cjs');var _chunkCDHMNLZ6cjs = require('./chunk-CDHMNLZ6.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function c(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new (0, _chunkPQ4LAXVOcjs.a)(e):r==="stellar"?new (0, _chunkIYWWY7T5cjs.a)(e):new (0, _chunk3GWEE56Xcjs.a)(e);case"api-key":return r==="solana"?new (0, _chunkCDHMNLZ6cjs.a)(e):new (0, _chunkR4SBFRTMcjs.a)(e);case"external-wallet":return r==="solana"?new (0, _chunk5GYSXH4Xcjs.a)(e):r==="stellar"?new (0, _chunk5FVDLMWWcjs.a)(e):new (0, _chunkHYWIWJ6Hcjs.a)(e);case"server":return _chunk7FIAYQ4Ocjs.a.call(void 0, r,e);case"passkey":return new (0, _chunk4M6KYXG7cjs.a)(e);case"device":if(n==null)throw new (0, _chunkD2S37DJ5cjs.g)("Device signer key storage is required for device signers");return new (0, _chunkXWQC6G7Ncjs.a)(e,n)}}function b(r,e,n,a){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(!e.startsWith("device:"))return null;let w=e.replace("device:","");return(yield a.hasKey(w))?c(r,{type:"device",locator:e,address:n},a):null})}exports.a = c; exports.b = b;
@@ -0,0 +1 @@
1
+ import{a as S,b as I}from"./chunk-C2R47XW6.js";import{a as _}from"./chunk-DVVGWCH7.js";import{a as j}from"./chunk-5LNDUSMZ.js";import{b as R}from"./chunk-RV3Q5EIA.js";import{f as k}from"./chunk-Z4OBKN5C.js";import{b,c as E}from"./chunk-TSJUK3ED.js";import{b as m,c as x}from"./chunk-PWYCEHYZ.js";import{S as O,e as q,g as h,l as L,o as W,u as N}from"./chunk-4I3EXM4B.js";import{a as C}from"./chunk-QNNWOOHI.js";import{a as f,b as w,c as F,h as y}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as G}from"@crossmint/common-sdk-base";import{WebAuthnP256 as B}from"ox";var U="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.";function J(D){return D!=="device"}var A=class{constructor(e){this.apiClient=e}getWallet(e,r){return y(this,null,function*(){let t,i;if(typeof e=="string"){if(!this.apiClient.isServerSide)throw new h("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(r==null)throw new h("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");t=e,i=r}else{if(this.apiClient.isServerSide)throw new h("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");i=e,t=this.getWalletLocator(i)}let n=w(f({},i),{chain:k(i.chain,this.apiClient.environment)}),a=n;(a.recovery!=null||a.recoveryMethods!=null)&&this.validatedRecoverySignerList(S(a),n.chain),C.info("walletFactory.getWallet.start");let o=yield this.apiClient.getWallet(t);if("error"in o)throw C.warn("walletFactory.getWallet.notFound",{error:o.error}),new q(JSON.stringify(o));return C.info("walletFactory.getWallet.success",{address:o.address}),yield this.createWalletInstance(o,n)})}createWallet(e){return y(this,null,function*(){var p,c,v,u,T,$,M,K;let r=w(f({},e),{chain:k(e.chain,this.apiClient.environment)}),t=S(r);if(t.length===0)throw new W(I(r)?"At least one recovery method is required":"A recovery method is required");let i=this.validatedRecoverySignerList(t,r.chain);if(yield(v=(c=(p=r.options)==null?void 0:p.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:v.call(c),C.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&r.owner!=null)throw C.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new h("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let n=(u=r.signers)!=null?u:[],a=((T=r.options)==null?void 0:T.deviceSignerKeyStorage)!=null&&!n.some(P=>P.type==="device"),o=a?[...n,{type:"device"}]:n,s=yield this.registerSigners(o,r.chain,($=r.options)==null?void 0:$.deviceSignerKeyStorage,(M=r.options)==null?void 0:M.passkeyProvider),l=[];for(let P of i)l.push(yield this.resolveRecoverySigner(P,r.chain,(K=r.options)==null?void 0:K.passkeyProvider));let d=this.buildRecoveryRequestConfig(r,l),g=yield this.createSmartWallet(r,d,s,a);if("error"in g)throw C.error("walletFactory.createWallet.error",{error:g.error}),O(g),new h(JSON.stringify(g));return C.info("walletFactory.createWallet.success",{address:g.address}),yield this.createWalletInstance(g,r)})}createSmartWallet(e,r,t,i){return y(this,null,function*(){let n=l=>{var d,g;return{type:"smart",chainType:this.getChainType(e.chain),config:f(f(f({},r),e.plugins?{plugins:e.plugins}:{}),l!=null?{delegatedSigners:l}:{}),owner:(d=e.owner)!=null?d:void 0,alias:(g=e.alias)!=null?g:void 0}},a=yield this.apiClient.createWallet(n(t));if(!(i&&"error"in a&&a.code===L))return a;C.info("walletFactory.createWallet.deviceSignerUnsupported.retryWithoutDeviceSigner",{chain:e.chain});let s=t.filter(l=>!this.isBuiltDeviceSigner(l));return yield this.apiClient.createWallet(n(s))})}buildRecoveryRequestConfig(e,r){return I(e)&&(e.chain==="solana"||e.chain==="stellar")?{recoveryMethods:r}:{adminSigner:r[0]}}validatedRecoverySignerList(e,r){if(e.length===0)throw new W("At least one recovery method is required");if(e.length>1&&r!=="solana"&&r!=="stellar")throw new N(`Multiple recovery methods are not supported on ${r} yet. Pass a single recovery method.`);for(let t of e)if(!J(t.type))throw new W(`A "${t.type}" signer cannot be a recovery method on ${r}. Register it under \`signers\` instead.`);return e}resolveRecoverySigner(e,r,t){return y(this,null,function*(){if(e.type==="passkey"&&e.id==null)return yield this.createPasskeySigner(e,t);if(e.type==="server"){let{derivedAddress:i}=b(e,r,this.apiClient.projectId,this.apiClient.environment);return{type:"server",address:i}}return e})}isBuiltDeviceSigner(e){let r=e.signer;return typeof r=="object"&&r!=null&&r.type==="device"}mergePhoneChannel(e,r){return e.type!=="phone"||(r==null?void 0:r.type)!=="phone"||r.channel==null?e:w(f({},e),{channel:r.channel})}createWalletInstance(e,r){return y(this,null,function*(){var p;this.validateExistingWalletConfig(e,r);let t=r,i=e.config,n=(p=i.recoveryMethods)!=null?p:[i.adminSigner],a=this.mergeRecoverySigners(n,S(t),r.chain),o=i.delegatedSigners,s=o;if(s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet"))s=t.signers;else if(s!=null){let c=t.signers;s=s.map(v=>this.mergePhoneChannel(v,c==null?void 0:c.find(u=>u.type==="phone"&&v.type==="phone"&&R(u)===v.locator)))}let l=n.filter(c=>c.type==="server"&&"address"in c&&!("secret"in c)).map(c=>c.address),d=(o!=null?o:[]).filter(c=>c.type==="server"&&"address"in c&&!("secret"in c)).map(c=>c.address),g=new _({chain:r.chain,address:e.address,owner:e.owner,options:r.options,alias:r.alias,recovery:a,apiRecoveryServerSignerAddresses:l,apiDelegatedServerSignerAddresses:d,signers:s!=null?s:[]},this.apiClient);return yield g.waitForInit(),g})}mergeRecoverySigners(e,r,t){let i=[...r],n=new Map,a=[(o,s)=>this.matchesRecoverySigner(o,s,t),(o,s)=>o.type===s.type];for(let o of a)e.forEach((s,l)=>{if(n.has(l))return;let d=i.findIndex(g=>o(g,s));d!==-1&&n.set(l,i.splice(d,1)[0])});return e.map((o,s)=>{let l=n.get(s);return l==null?o:l.type==="server"||l.type==="external-wallet"?l:this.mergePhoneChannel(o,l)})}matchesRecoverySigner(e,r,t){if(e.type!==r.type)return!1;if(e.type==="email"&&"email"in r)return m(e.email)===m(r.email);if(e.type==="phone"&&"phone"in r)return e.phone===r.phone;if(e.type==="external-wallet"&&"address"in r)return e.address===r.address;if(e.type==="server"&&"address"in r){if(!("secret"in e))return e.address===r.address;let{primary:i,legacy:n}=E(e,t,this.apiClient.projectId,this.apiClient.environment);return i.derivedAddress===r.address||(n==null?void 0:n.derivedAddress)===r.address}return!0}getWalletLocator(e){return`me:${this.getChainType(e.chain)}:smart`+(e.alias!=null?`:alias:${e.alias}`:"")}createPasskeySigner(e,r){return y(this,null,function*(){var a,o;if(e.type!=="passkey")throw new Error("Signer is not a passkey");let t=(a=e.name)!=null?a:`Crossmint Wallet ${Date.now()}`,i=(o=e.onCreatePasskey)!=null?o:r==null?void 0:r.createPasskey,n=i?yield i(t):yield B.createCredential({name:t});return{type:"passkey",id:n.id,name:t,publicKey:{x:n.publicKey.x.toString(),y:n.publicKey.y.toString()}}})}validateExistingWalletConfig(e,r){var n;if(r.owner!=null&&e.owner!=null&&m(r.owner)!==m(e.owner))throw new h("Wallet owner does not match existing wallet's linked user");if(r.chain==="solana"&&e.chainType!=="solana"||r.chain!=="solana"&&e.chainType==="solana"||r.chain==="stellar"&&e.chainType!=="stellar"||r.chain!=="stellar"&&e.chainType==="stellar")throw new h(`Wallet chain does not match existing wallet's chain. You must use chain: ${e.chainType}.`);if(e.type!=="smart")return;let t=r,i=S(t);if(t.recovery!=null||t.recoveryMethods!=null||t.signers!=null){let a=e.config,o=(n=a==null?void 0:a.recoveryMethods)!=null?n:(a==null?void 0:a.adminSigner)!=null?[a.adminSigner]:[],s=[...o];for(let d of i){if(o.length===0)break;let g=s.findIndex(c=>this.matchesRecoverySigner(d,c,r.chain)),p=g===-1?s.find(c=>c.type===d.type):s[g];if(p==null)throw new h("The wallet recovery signer type does not match the existing wallet's recovery signer type");x(d,p),g!==-1&&s.splice(g,1)}let l=t.signers;l!=null&&this.validateSigners(e,l,r.chain)}}validateSigners(e,r,t){let i=e.config,n=i==null?void 0:i.delegatedSigners;if(r.length!==0){if(n==null||n.length===0)throw new h(`${r.length} signer(s) specified, but wallet "${e.address}" has no signers. ${U}`);for(let a of r){let o=n.find(s=>{if(this.isMatchingPasskeySigner(a,s,i)||s.type==="device"&&a.type==="device")return!0;if(a.type==="server"){let{primary:l,legacy:d}=E(a,t,this.apiClient.projectId,this.apiClient.environment);return s.locator===`server:${l.derivedAddress}`||d!=null&&s.locator===`server:${d.derivedAddress}`}return s.locator===R(a)});if(o==null){let s=n.map(l=>l.locator).join(", ");throw new h(`Signer '${a.type}' does not exist in wallet "${e.address}". Available signers: ${s}. ${U}`)}x(a,o)}}}isMatchingPasskeySigner(e,r,t){var n,a;let i=((a=(n=t.delegatedSigners)==null?void 0:n.filter(o=>o.type==="passkey").length)!=null?a:0)+(t.adminSigner.type==="passkey"?1:0);if(e.type==="passkey"){if(e.id==null&&i===1)return r.type==="passkey";if(e.id==null&&i>1)throw new h("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(e,r,t,i){return y(this,null,function*(){let n=[];for(let a of e!=null?e:[])n.push(yield this.registerSigner(a,r,t,i));return n})}registerSigner(e,r,t,i){return y(this,null,function*(){if(e.type==="passkey")return e.id==null?{signer:yield this.createPasskeySigner(e,i)}:{signer:e};if(e.type==="device"){if(e.publicKey!=null)return{signer:{type:"device",publicKey:e.publicKey,name:e.name}};if(e.locator!=null)return{signer:e.locator};if(t==null)throw new h("Device signer key storage is required for device signers");let n=yield j(t);return{signer:{type:"device",publicKey:n.publicKey,name:n.name}}}if(e.type==="server"&&r!=null){let{derivedAddress:n}=b(e,r,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${n}`}}return{signer:R(e)}})}getChainType(e){return e==="solana"?"solana":e==="stellar"?"stellar":"evm"}};F([G({logger:C,methodName:"walletFactory.getWallet",buildContext(e,r){if(typeof r[0]=="string"){let i=r[1];return{walletLocator:r[0],chain:i==null?void 0:i.chain}}let t=r[0];return{chain:t==null?void 0:t.chain}}})],A.prototype,"getWallet",1),F([G({logger:C,methodName:"walletFactory.createWallet",buildContext(e,r){return{chain:r[0].chain}}})],A.prototype,"createWallet",1);export{A as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFWPLRK7Scjs = require('./chunk-FWPLRK7S.cjs');var _chunk5T2BUXCFcjs = require('./chunk-5T2BUXCF.cjs');var _chunkCPXJHFSRcjs = require('./chunk-CPXJHFSR.cjs');var _chunk5YNL2XREcjs = require('./chunk-5YNL2XRE.cjs');var _chunk3E3JUVWLcjs = require('./chunk-3E3JUVWL.cjs');var _chunkXTYSMO67cjs = require('./chunk-XTYSMO67.cjs');var _chunkWSDMIQNGcjs = require('./chunk-WSDMIQNG.cjs');var _chunkBJJXTZJBcjs = require('./chunk-BJJXTZJB.cjs');var _chunkMQEPGBWNcjs = require('./chunk-MQEPGBWN.cjs');var _chunk664ATEWTcjs = require('./chunk-664ATEWT.cjs');var _chunkFY4JJ3QZcjs = require('./chunk-FY4JJ3QZ.cjs');var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkXIO3CEXHcjs = require('./chunk-XIO3CEXH.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var O,d,F,T,o,S,W,M,L,b,fe,we,j,H,w= exports.a =class{constructor(e,r){_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,O);_chunkDSIFRRBScjs.e.call(void 0, this,d);_chunkDSIFRRBScjs.e.call(void 0, this,F);_chunkDSIFRRBScjs.e.call(void 0, this,T);_chunkDSIFRRBScjs.e.call(void 0, this,o);_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,W,[]);_chunkDSIFRRBScjs.e.call(void 0, this,M);_chunkDSIFRRBScjs.e.call(void 0, this,L,null);let{chain:t,address:n,owner:a,options:c,alias:g,recovery:v,apiRecoveryServerSignerAddresses:y,apiDelegatedServerSignerAddresses:h,signers:C,signer:f}=e;_chunkDSIFRRBScjs.f.call(void 0, this,d,r),this.chain=t,this.address=n,this.owner=a,_chunkDSIFRRBScjs.f.call(void 0, this,O,c),this.alias=g;let m=Array.isArray(v)?v:[v],U=y!=null?y:m.filter(p=>p.type==="server"&&_chunk664ATEWTcjs.g.call(void 0, p)).map(p=>p.address);_chunkDSIFRRBScjs.f.call(void 0, this,W,h!=null?h:[]),_chunkDSIFRRBScjs.f.call(void 0, this,F,C!=null?C:[]),_chunkDSIFRRBScjs.f.call(void 0, this,T,new (0, _chunk3E3JUVWLcjs.a)({chain:t,projectId:_chunkDSIFRRBScjs.d.call(void 0, this,d).projectId,environment:_chunkDSIFRRBScjs.d.call(void 0, this,d).environment,apiRecoveryAddresses:U,apiDelegatedAddresses:_chunkDSIFRRBScjs.d.call(void 0, this,W),knownOnChainAddresses:()=>[..._chunkDSIFRRBScjs.d.call(void 0, this,F).filter(p=>p.type==="server"&&_chunk664ATEWTcjs.g.call(void 0, p)).map(p=>p.address),..._chunkDSIFRRBScjs.d.call(void 0, this,W)]})),_chunkDSIFRRBScjs.f.call(void 0, this,o,new (0, _chunkFWPLRK7Scjs.a)({apiClient:r,options:c,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,T),recoverySigners:m,initialSigners:_chunkDSIFRRBScjs.d.call(void 0, this,F),signers:()=>this.signers(),signer:f})),m.forEach((p,Ce)=>{p.type==="server"&&!_chunk664ATEWTcjs.g.call(void 0, p)&&_chunkDSIFRRBScjs.d.call(void 0, this,o).stripSecretFromRecovery(Ce,_chunkDSIFRRBScjs.d.call(void 0, this,T).resolveRecovery(p))}),_chunkDSIFRRBScjs.f.call(void 0, this,S,new (0, _chunkCPXJHFSRcjs.a)({chain:t,walletAddress:this.address,options:c,signerManager:_chunkDSIFRRBScjs.d.call(void 0, this,o),serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,T),signers:()=>this.signers(),addSigner:p=>this.addSigner(p),removeSigner:p=>this.removeSigner({type:"device",locator:p}),approveSignature:p=>this.approveSignatureAndWait(p),approveTransaction:p=>this.approveTransactionAndWait(p)})),_chunkDSIFRRBScjs.f.call(void 0, this,M,this.initDefaultSigner())}get signer(){return _chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner}waitForInit(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,M)})}initDefaultSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner!=null||(yield _chunkDSIFRRBScjs.d.call(void 0, this,S).initDeviceSigner(),_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner!=null||_chunkDSIFRRBScjs.d.call(void 0, this,S).needsRecovery))return;let e=_chunkDSIFRRBScjs.d.call(void 0, this,F).length===0?_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery:_chunkDSIFRRBScjs.d.call(void 0, this,F).length===1?_chunkDSIFRRBScjs.d.call(void 0, this,F)[0]:null;if(e==null)return;let r=_chunkXTYSMO67cjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery;try{let a=r.buildInternalConfig(e,t);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(a,{isAdminSigner:n}))}catch(a){_chunkM2AM4CBTcjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery.type,signerCount:_chunkDSIFRRBScjs.d.call(void 0, this,F).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecoverySigners(e){return e.recoveryMethods}static getInitialSigners(e){return _chunkDSIFRRBScjs.d.call(void 0, e,F)}static getApiRecoveryServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,T).apiRecoveryAddresses}static getApiDelegatedServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,W)}get apiClient(){return _chunkDSIFRRBScjs.d.call(void 0, this,d)}get options(){return _chunkDSIFRRBScjs.d.call(void 0, this,O)}get chainAdapter(){return _chunkFY4JJ3QZcjs.a.call(void 0, this.chain)}resolveServerSignerApiLocator(e){return _chunkDSIFRRBScjs.d.call(void 0, this,T).apiLocator(e)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,o).recovery}get recoveryMethods(){return _chunkDSIFRRBScjs.d.call(void 0, this,o).recoverySigners}balances(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkM2AM4CBTcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw _chunkM2AM4CBTcjs.a.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return _chunkM2AM4CBTcjs.a.info("wallet.balances.success"),_chunk5T2BUXCFcjs.a.call(void 0, a,this.chain,t,e)})}stagingFund(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkM2AM4CBTcjs.a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw _chunkM2AM4CBTcjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunkM2AM4CBTcjs.a.info("wallet.stagingFund.success"),t})}nfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getNfts(_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw _chunkM2AM4CBTcjs.a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new (0, _chunkD2S37DJ5cjs.H)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let c=_chunkBJJXTZJBcjs.a.call(void 0, e),g=this.resolveChainForEnvironment(),v=_chunkBJJXTZJBcjs.b.call(void 0, r,g);_chunkM2AM4CBTcjs.a.info("wallet.send.start",_chunkDSIFRRBScjs.a.call(void 0, {recipient:c,token:v,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let y=_chunkDSIFRRBScjs.d.call(void 0, this,o).require(),h;(n==null?void 0:n.signer)==null?h=y.locator():typeof n.signer=="string"?h=n.signer:h=this.resolveServerSignerApiLocator(n.signer);let C=_chunkDSIFRRBScjs.a.call(void 0, {recipient:c,amount:t,signer:h},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),f=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).send(this.walletLocator,v,C);if("message"in f)throw _chunkM2AM4CBTcjs.a.error("wallet.send.error",{error:f}),new (0, _chunkD2S37DJ5cjs.I)(`Failed to send token: ${JSON.stringify(f.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return _chunkM2AM4CBTcjs.a.info("wallet.send.prepared",{transactionId:f.id}),{hash:void 0,explorerLink:void 0,transactionId:f.id};let m=yield this.approveTransactionAndWait(f.id);return _chunkM2AM4CBTcjs.a.info("wallet.send.success",{transactionId:f.id,hash:m.hash}),m})}approveTransaction(e){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkM2AM4CBTcjs.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 _chunkM2AM4CBTcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkM2AM4CBTcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkM2AM4CBTcjs.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkM2AM4CBTcjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return _chunkDSIFRRBScjs.d.call(void 0, this,o).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var m;let a=typeof t=="string"?t:_chunkWSDMIQNGcjs.b.call(void 0, t),c=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).getSignerState(a);if(c.signer!=null){if(_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(c.signer.status))return(r==null?void 0:r.scopes)!=null&&_chunkM2AM4CBTcjs.a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:a}),_chunkM2AM4CBTcjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(c.signer,null,r);if(c.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return _chunkM2AM4CBTcjs.a.info("wallet.addSigner.resuming",{operationType:c.pendingOperation.type,operationId:c.pendingOperation.id}),this.completeSignerRegistration(c.signer,c.pendingOperation,r)}}let g=typeof t=="string"?t:_chunkXTYSMO67cjs.a.call(void 0, t.type).addSignerPayload(t,_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext()),y=this.chain!=="solana"&&this.chain!=="stellar"?(m=r==null?void 0:r.deployImmediately)!=null?m:!0:void 0,h=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).registerSigner(this.walletLocator,_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {signer:g,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),y!=null&&{deployImmediately:y}),n!=null&&{approver:n}));if("error"in h)throw _chunkM2AM4CBTcjs.a.error("wallet.addSigner.error",{error:h}),h.code===_chunkD2S37DJ5cjs.l?new (0, _chunkD2S37DJ5cjs.m)(h.message):new (0, _chunkD2S37DJ5cjs.j)(`Failed to register signer: ${JSON.stringify(h.message)}`);let C=_chunkJNKTRQPScjs.b.call(void 0, h,this.chain);if(C==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let f=this.chainAdapter.extractAddSignerOperation(h,this.chain,{locator:a,type:e.type});return this.completeSignerRegistration(C,f,r)}))})}completeSignerRegistration(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return _chunkDSIFRRBScjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return _chunkM2AM4CBTcjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}case"signature":{let n={signatureId:r.id};return _chunkM2AM4CBTcjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),_chunkM2AM4CBTcjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkM2AM4CBTcjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else _chunkM2AM4CBTcjs.a.info("wallet.addSigner.success");return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=this.resolveSignerLocator(e);return _chunkM2AM4CBTcjs.a.info("wallet.removeSigner.start",{signerLocator:t}),_chunkDSIFRRBScjs.d.call(void 0, this,o).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).removeSigner(this.walletLocator,t,_chunkDSIFRRBScjs.a.call(void 0, {chain:this.chainAdapter.addSignerChain(this.chain)},n!=null&&{approver:n}));if("error"in a)throw _chunkM2AM4CBTcjs.a.error("wallet.removeSigner.error",{error:a}),new Error(`Failed to remove signer: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(_chunkM2AM4CBTcjs.a.info("wallet.removeSigner.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),_chunkM2AM4CBTcjs.a.info("wallet.removeSigner.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}addRecoveryMethod(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){this.assertRecoveryMethodManagementSupported(),_chunkM2AM4CBTcjs.a.info("wallet.addRecoveryMethod.start");let t=e.type==="server"?this.resolveServerSignerApiLocator(e):e;return _chunkDSIFRRBScjs.d.call(void 0, this,o).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=typeof t=="string"?t:_chunkXTYSMO67cjs.a.call(void 0, t.type).addSignerPayload(t,_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext()),c=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).registerRecoveryMethod(this.walletLocator,{recoveryMethods:a,approver:this.resolveRecoveryApprover(n)});if("error"in c)throw _chunkM2AM4CBTcjs.a.error("wallet.addRecoveryMethod.error",{error:c}),new (0, _chunkD2S37DJ5cjs.j)(`Failed to add recovery method: ${JSON.stringify(c.message)}`);let g=c.tx.id;return r!=null&&r.prepareOnly?(_chunkM2AM4CBTcjs.a.info("wallet.addRecoveryMethod.prepared",{transactionId:g}),{transactionId:g,status:void 0}):(yield this.approveTransactionAndWait(g),_chunkDSIFRRBScjs.d.call(void 0, this,o).addRecoverySigner(typeof t=="string"?{type:"server",address:t.slice(7)}:t),_chunkM2AM4CBTcjs.a.info("wallet.addRecoveryMethod.success",{transactionId:g}),{transactionId:g,status:"success"})}))})}removeRecoveryMethod(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){this.assertRecoveryMethodManagementSupported();let t=this.resolveSignerLocator(e);return _chunkM2AM4CBTcjs.a.info("wallet.removeRecoveryMethod.start",{recoveryMethodLocator:t}),_chunkDSIFRRBScjs.d.call(void 0, this,o).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).removeRecoveryMethod(this.walletLocator,t,{approver:this.resolveRecoveryApprover(n)});if("error"in a)throw _chunkM2AM4CBTcjs.a.error("wallet.removeRecoveryMethod.error",{error:a}),new Error(`Failed to remove recovery method: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(_chunkM2AM4CBTcjs.a.info("wallet.removeRecoveryMethod.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),_chunkDSIFRRBScjs.d.call(void 0, this,o).removeRecoverySigner(t),_chunkM2AM4CBTcjs.a.info("wallet.removeRecoveryMethod.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}assertRecoveryMethodManagementSupported(){if(this.chain!=="solana"&&this.chain!=="stellar")throw new (0, _chunkD2S37DJ5cjs.u)(`Adding and removing recovery methods is not supported on ${this.chain} yet. It is available on Solana and Stellar.`)}resolveRecoveryApprover(e){return e!=null?e:_chunkDSIFRRBScjs.d.call(void 0, this,o).require().locator()}useSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkM2AM4CBTcjs.a.info("wallet.useSigner.start"),e.type==="server"&&_chunkDSIFRRBScjs.d.call(void 0, this,T).resetDelegatedCache(),_chunkXTYSMO67cjs.a.call(void 0, e.type).validateConfig(e);let r=!1;e.type==="device"?yield _chunkDSIFRRBScjs.d.call(void 0, this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=_chunkXTYSMO67cjs.a.call(void 0, e.type).buildInternalConfig(e,_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext()),n=_chunkWSDMIQNGcjs.b.call(void 0, e);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(t,{isAdminSigner:r})),_chunkM2AM4CBTcjs.a.info("wallet.useSigner.success",{signerLocator:n})})}useRecoveryMethod(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkM2AM4CBTcjs.a.info("wallet.useRecoveryMethod.start"),_chunkXTYSMO67cjs.a.call(void 0, e.type).validateConfig(e);let r=this.matchRecoverySigner(e);if(r==null){let n=this.recoveryMethods.map(a=>_chunkDSIFRRBScjs.d.call(void 0, this,o).recoveryLocator(a)).filter(a=>a!=null).join(", ");throw new (0, _chunkD2S37DJ5cjs.o)(`Signer "${this.resolveSignerLocator(e)}" is not one of this wallet's recovery methods (${n}).`)}e.type==="server"&&_chunkDSIFRRBScjs.d.call(void 0, this,o).stripSecretFromRecovery(r,_chunkDSIFRRBScjs.d.call(void 0, this,T).resolveRecovery(e));let t=_chunkXTYSMO67cjs.a.call(void 0, e.type).adoptsRecoveryConfigOnMatch?this.recoveryMethods[r]:e.type==="passkey"?this.withPasskeyRecoveryCredentialId(e,r):e;_chunkDSIFRRBScjs.d.call(void 0, this,o).selectRecovery(r,t),_chunkM2AM4CBTcjs.a.info("wallet.useRecoveryMethod.success",{recoveryMethodLocator:_chunkDSIFRRBScjs.d.call(void 0, this,o).recoveryLocator(t)})})}resolveNonDeviceSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).map(c=>c.locator),n={recoveryIndex:null},a=_chunkDSIFRRBScjs.d.call(void 0, this,T).resolveForUseSigner(e,t,()=>(n.recoveryIndex=this.matchRecoverySigner(e),n.recoveryIndex!=null));switch(a.kind){case"delegated":return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!1;case"recovery":return n.recoveryIndex!=null&&_chunkDSIFRRBScjs.d.call(void 0, this,o).stripSecretFromRecovery(n.recoveryIndex,a.address),_chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;case"unregistered":throw new Error(a.message)}})}withPasskeyRecoveryCredentialId(e,r){if(_chunkWSDMIQNGcjs.a.call(void 0, e)!=null)return e;if(this.recoveryMethods.filter(a=>a.type==="passkey").length>1)throw new (0, _chunkD2S37DJ5cjs.o)('Multiple passkey recovery methods are registered on this wallet. Please specify the credential id: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');let n=_chunkWSDMIQNGcjs.a.call(void 0, this.recoveryMethods[r]);if(n==null)throw new (0, _chunkD2S37DJ5cjs.o)('The passkey recovery method has no credential id. Please specify it: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{id:n})}tryAutoSelectPasskey(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):_chunkWSDMIQNGcjs.b.call(void 0, e)}isPasskeyMissingId(e){return _chunkWSDMIQNGcjs.a.call(void 0, e)==null}signerIsRegistered(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,o).signerIsRegistered(e)})}isSignerApproved(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,o).isSignerApproved(e)})}needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,S).needsRecovery}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,S).recover()})}signers(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a,c;_chunkM2AM4CBTcjs.a.info("wallet.signers.start");let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getWallet(this.walletLocator);if("error"in e)throw _chunkM2AM4CBTcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkD2S37DJ5cjs.e)(JSON.stringify(e));if(!me(e)){let g=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw _chunkM2AM4CBTcjs.a.error("wallet.signers.error",{error:g}),new (0, _chunkD2S37DJ5cjs.d)(g)}let r=(c=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?c:[],n=(yield Promise.all(r.map(g=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{return(yield _chunkDSIFRRBScjs.d.call(void 0, this,o).getSignerState(g.locator)).signer}catch(v){return _chunkM2AM4CBTcjs.a.warn("wallet.signers.mapSigner.failed",{locator:g.locator,error:v}),null}})))).filter(g=>g!=null);return _chunkM2AM4CBTcjs.a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(_chunkDSIFRRBScjs.d.call(void 0, this,d).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return _chunkDSIFRRBScjs.d.call(void 0, this,o)}preAuthIfNeeded(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,M),_chunkDSIFRRBScjs.d.call(void 0, this,L)==null&&_chunkDSIFRRBScjs.f.call(void 0, this,L,this.recover());try{yield _chunkDSIFRRBScjs.d.call(void 0, this,L)}finally{_chunkDSIFRRBScjs.f.call(void 0, this,L,null)}let e=_chunkDSIFRRBScjs.d.call(void 0, this,o).require();e instanceof _chunkMQEPGBWNcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){return this.matchRecoverySigner(e)!=null}matchRecoverySigner(e){let r=_chunkXTYSMO67cjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext(),n=this.recoveryMethods.findIndex(a=>a.type===e.type&&r.matchesRecovery(e,a,t));return n===-1?null:(r.adoptsRecoveryConfigOnMatch&&_chunkDSIFRRBScjs.d.call(void 0, this,o).adoptRecoveryConfig(n,e),n)}resolveChainForEnvironment(){let e=_chunkXIO3CEXHcjs.f.call(void 0, this.chain,_chunkDSIFRRBScjs.d.call(void 0, this,d).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var v,y;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=_chunkDSIFRRBScjs.d.call(void 0, this,o).require(),n=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getSignature(this.walletLocator,e);if("error"in n)throw _chunkD2S37DJ5cjs.R.call(void 0, n),new (0, _chunkD2S37DJ5cjs.E)(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let h=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,h)}let a=(v=n.approvals)==null?void 0:v.pending;if(a==null||a.length===0)return n;let c=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],t],g=yield _chunkDSIFRRBScjs.g.call(void 0, this,b,H).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,b,j).call(this,a),c,(h,C)=>h.signMessage(C.message));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var v,y,h,C,f;let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getTransaction(this.walletLocator,e);if("error"in t)throw _chunkD2S37DJ5cjs.R.call(void 0, t),new (0, _chunkD2S37DJ5cjs.J)(JSON.stringify(t));yield(h=(y=(v=_chunkDSIFRRBScjs.d.call(void 0, this,O))==null?void 0:v.callbacks)==null?void 0:y.onTransactionStart)==null?void 0:h.call(y);let n=_chunkDSIFRRBScjs.d.call(void 0, this,o).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let a=(C=t.approvals)==null?void 0:C.pending;if(a==null||a.length===0)return t;let c=[...(f=r==null?void 0:r.additionalSigners)!=null?f:[],n],g=yield _chunkDSIFRRBScjs.g.call(void 0, this,b,H).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,b,j).call(this,a),c,(m,U)=>_chunkFY4JJ3QZcjs.c.call(void 0, t.chainType,this.chainAdapter).signApproval(m,t,U.message));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkM2AM4CBTcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkD2S37DJ5cjs.R.call(void 0, t),new (0, _chunkD2S37DJ5cjs.O)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkD2S37DJ5cjs.R.call(void 0, t),new (0, _chunkD2S37DJ5cjs.F)(JSON.stringify(t));return t})}waitForSignature(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunk5YNL2XREcjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,d),this.walletLocator,e)})}waitForTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e,r=6e4,t={}){return yield _chunk5YNL2XREcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,d),this.walletLocator,e,_chunkDSIFRRBScjs.a.call(void 0, {timeoutMs:r},t))})}sleep(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};O=new WeakMap,d=new WeakMap,F=new WeakMap,T=new WeakMap,o=new WeakMap,S=new WeakMap,W=new WeakMap,M=new WeakMap,L=new WeakMap,b=new WeakSet,fe=function(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,S).tryResolveLocallyAvailableSigner(e);return r!=null&&_chunkM2AM4CBTcjs.a.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},we=function(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var n;let t=e.find(a=>a.locator()===r);if(t==null&&(t=(n=yield _chunkDSIFRRBScjs.g.call(void 0, this,b,fe).call(this,r))!=null?n:void 0),t==null)throw new (0, _chunkD2S37DJ5cjs.j)(`Signer ${r} not found in pending approvals`);return t})},j=function(e){return e.map(r=>{if(r.signer.type==="quorum")throw new (0, _chunkD2S37DJ5cjs.n)(`This wallet requires approval from a quorum signer (${r.signer.locator}), which is not yet supported by this SDK version`);return r})},H=function(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.all(e.map(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.g.call(void 0, this,b,we).call(this,r,n.signer.locator),c=yield t(a,n);return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},c),{signer:a.locator()})})))})},_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"balances",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"stagingFund",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"send",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"approve",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.addRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addRecoveryMethod",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.removeRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeRecoveryMethod",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.useRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useRecoveryMethod",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"recover",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"signers",1);function me(G){return G.type==="smart"&&_chunkFY4JJ3QZcjs.b.call(void 0, G.chainType)}exports.a = w;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVRA6S3DJcjs = require('./chunk-VRA6S3DJ.cjs');var _chunkOAFFHV5Gcjs = require('./chunk-OAFFHV5G.cjs');var _chunkIHIJ7G64cjs = require('./chunk-IHIJ7G64.cjs');var _chunkR3CAXQLJcjs = require('./chunk-R3CAXQLJ.cjs');var _chunk3E3JUVWLcjs = require('./chunk-3E3JUVWL.cjs');var _chunkXTYSMO67cjs = require('./chunk-XTYSMO67.cjs');var _chunkWSDMIQNGcjs = require('./chunk-WSDMIQNG.cjs');var _chunkBJJXTZJBcjs = require('./chunk-BJJXTZJB.cjs');var _chunkA4F6GFJCcjs = require('./chunk-A4F6GFJC.cjs');var _chunkZ6CVEP22cjs = require('./chunk-Z6CVEP22.cjs');var _chunk664ATEWTcjs = require('./chunk-664ATEWT.cjs');var _chunkVUCADC63cjs = require('./chunk-VUCADC63.cjs');var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var O,d,F,T,o,S,W,M,L,b,fe,we,j,H,w= exports.a =class{constructor(e,r){_chunkDSIFRRBScjs.e.call(void 0, this,b);_chunkDSIFRRBScjs.e.call(void 0, this,O);_chunkDSIFRRBScjs.e.call(void 0, this,d);_chunkDSIFRRBScjs.e.call(void 0, this,F);_chunkDSIFRRBScjs.e.call(void 0, this,T);_chunkDSIFRRBScjs.e.call(void 0, this,o);_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,W,[]);_chunkDSIFRRBScjs.e.call(void 0, this,M);_chunkDSIFRRBScjs.e.call(void 0, this,L,null);let{chain:t,address:n,owner:a,options:c,alias:g,recovery:v,apiRecoveryServerSignerAddresses:y,apiDelegatedServerSignerAddresses:h,signers:C,signer:f}=e;_chunkDSIFRRBScjs.f.call(void 0, this,d,r),this.chain=t,this.address=n,this.owner=a,_chunkDSIFRRBScjs.f.call(void 0, this,O,c),this.alias=g;let m=Array.isArray(v)?v:[v],U=y!=null?y:m.filter(p=>p.type==="server"&&_chunk664ATEWTcjs.g.call(void 0, p)).map(p=>p.address);_chunkDSIFRRBScjs.f.call(void 0, this,W,h!=null?h:[]),_chunkDSIFRRBScjs.f.call(void 0, this,F,C!=null?C:[]),_chunkDSIFRRBScjs.f.call(void 0, this,T,new (0, _chunk3E3JUVWLcjs.a)({chain:t,projectId:_chunkDSIFRRBScjs.d.call(void 0, this,d).projectId,environment:_chunkDSIFRRBScjs.d.call(void 0, this,d).environment,apiRecoveryAddresses:U,apiDelegatedAddresses:_chunkDSIFRRBScjs.d.call(void 0, this,W),knownOnChainAddresses:()=>[..._chunkDSIFRRBScjs.d.call(void 0, this,F).filter(p=>p.type==="server"&&_chunk664ATEWTcjs.g.call(void 0, p)).map(p=>p.address),..._chunkDSIFRRBScjs.d.call(void 0, this,W)]})),_chunkDSIFRRBScjs.f.call(void 0, this,o,new (0, _chunkVRA6S3DJcjs.a)({apiClient:r,options:c,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,T),recoverySigners:m,initialSigners:_chunkDSIFRRBScjs.d.call(void 0, this,F),signers:()=>this.signers(),signer:f})),m.forEach((p,Ce)=>{p.type==="server"&&!_chunk664ATEWTcjs.g.call(void 0, p)&&_chunkDSIFRRBScjs.d.call(void 0, this,o).stripSecretFromRecovery(Ce,_chunkDSIFRRBScjs.d.call(void 0, this,T).resolveRecovery(p))}),_chunkDSIFRRBScjs.f.call(void 0, this,S,new (0, _chunkIHIJ7G64cjs.a)({chain:t,walletAddress:this.address,options:c,signerManager:_chunkDSIFRRBScjs.d.call(void 0, this,o),serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,T),signers:()=>this.signers(),addSigner:p=>this.addSigner(p),removeSigner:p=>this.removeSigner({type:"device",locator:p}),approveSignature:p=>this.approveSignatureAndWait(p),approveTransaction:p=>this.approveTransactionAndWait(p)})),_chunkDSIFRRBScjs.f.call(void 0, this,M,this.initDefaultSigner())}get signer(){return _chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner}waitForInit(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,M)})}initDefaultSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner!=null||(yield _chunkDSIFRRBScjs.d.call(void 0, this,S).initDeviceSigner(),_chunkDSIFRRBScjs.d.call(void 0, this,o).activeSigner!=null||_chunkDSIFRRBScjs.d.call(void 0, this,S).needsRecovery))return;let e=_chunkDSIFRRBScjs.d.call(void 0, this,F).length===0?_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery:_chunkDSIFRRBScjs.d.call(void 0, this,F).length===1?_chunkDSIFRRBScjs.d.call(void 0, this,F)[0]:null;if(e==null)return;let r=_chunkXTYSMO67cjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery;try{let a=r.buildInternalConfig(e,t);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(a,{isAdminSigner:n}))}catch(a){_chunkO673DZDXcjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunkDSIFRRBScjs.d.call(void 0, this,o).recovery.type,signerCount:_chunkDSIFRRBScjs.d.call(void 0, this,F).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecoverySigners(e){return e.recoveryMethods}static getInitialSigners(e){return _chunkDSIFRRBScjs.d.call(void 0, e,F)}static getApiRecoveryServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,T).apiRecoveryAddresses}static getApiDelegatedServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,W)}get apiClient(){return _chunkDSIFRRBScjs.d.call(void 0, this,d)}get options(){return _chunkDSIFRRBScjs.d.call(void 0, this,O)}get chainAdapter(){return _chunkVUCADC63cjs.a.call(void 0, this.chain)}resolveServerSignerApiLocator(e){return _chunkDSIFRRBScjs.d.call(void 0, this,T).apiLocator(e)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,o).recovery}get recoveryMethods(){return _chunkDSIFRRBScjs.d.call(void 0, this,o).recoverySigners}balances(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw _chunkO673DZDXcjs.a.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return _chunkO673DZDXcjs.a.info("wallet.balances.success"),_chunkOAFFHV5Gcjs.a.call(void 0, a,this.chain,t,e)})}stagingFund(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw _chunkO673DZDXcjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunkO673DZDXcjs.a.info("wallet.stagingFund.success"),t})}nfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getNfts(_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw _chunkO673DZDXcjs.a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new (0, _chunkD2S37DJ5cjs.H)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let c=_chunkBJJXTZJBcjs.a.call(void 0, e),g=this.resolveChainForEnvironment(),v=_chunkBJJXTZJBcjs.b.call(void 0, r,g);_chunkO673DZDXcjs.a.info("wallet.send.start",_chunkDSIFRRBScjs.a.call(void 0, {recipient:c,token:v,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let y=_chunkDSIFRRBScjs.d.call(void 0, this,o).require(),h;(n==null?void 0:n.signer)==null?h=y.locator():typeof n.signer=="string"?h=n.signer:h=this.resolveServerSignerApiLocator(n.signer);let C=_chunkDSIFRRBScjs.a.call(void 0, {recipient:c,amount:t,signer:h},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),f=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).send(this.walletLocator,v,C);if("message"in f)throw _chunkO673DZDXcjs.a.error("wallet.send.error",{error:f}),new (0, _chunkD2S37DJ5cjs.I)(`Failed to send token: ${JSON.stringify(f.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return _chunkO673DZDXcjs.a.info("wallet.send.prepared",{transactionId:f.id}),{hash:void 0,explorerLink:void 0,transactionId:f.id};let m=yield this.approveTransactionAndWait(f.id);return _chunkO673DZDXcjs.a.info("wallet.send.success",{transactionId:f.id,hash:m.hash}),m})}approveTransaction(e){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkO673DZDXcjs.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 _chunkO673DZDXcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkO673DZDXcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkO673DZDXcjs.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return _chunkDSIFRRBScjs.d.call(void 0, this,o).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var m;let a=typeof t=="string"?t:_chunkWSDMIQNGcjs.b.call(void 0, t),c=yield _chunkDSIFRRBScjs.d.call(void 0, this,o).getSignerState(a);if(c.signer!=null){if(_chunkDSIFRRBScjs.d.call(void 0, this,o).isApprovedSignerStatus(c.signer.status))return(r==null?void 0:r.scopes)!=null&&_chunkO673DZDXcjs.a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:a}),_chunkO673DZDXcjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(c.signer,null,r);if(c.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return _chunkO673DZDXcjs.a.info("wallet.addSigner.resuming",{operationType:c.pendingOperation.type,operationId:c.pendingOperation.id}),this.completeSignerRegistration(c.signer,c.pendingOperation,r)}}let g=typeof t=="string"?t:_chunkXTYSMO67cjs.a.call(void 0, t.type).addSignerPayload(t,_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext()),y=this.chain!=="solana"&&this.chain!=="stellar"?(m=r==null?void 0:r.deployImmediately)!=null?m:!0:void 0,h=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).registerSigner(this.walletLocator,_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {signer:g,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),y!=null&&{deployImmediately:y}),n!=null&&{approver:n}));if("error"in h)throw _chunkO673DZDXcjs.a.error("wallet.addSigner.error",{error:h}),h.code===_chunkD2S37DJ5cjs.l?new (0, _chunkD2S37DJ5cjs.m)(h.message):new (0, _chunkD2S37DJ5cjs.j)(`Failed to register signer: ${JSON.stringify(h.message)}`);let C=_chunkJNKTRQPScjs.b.call(void 0, h,this.chain);if(C==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let f=this.chainAdapter.extractAddSignerOperation(h,this.chain,{locator:a,type:e.type});return this.completeSignerRegistration(C,f,r)}))})}completeSignerRegistration(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return _chunkDSIFRRBScjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return _chunkO673DZDXcjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}case"signature":{let n={signatureId:r.id};return _chunkO673DZDXcjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),_chunkO673DZDXcjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkO673DZDXcjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else _chunkO673DZDXcjs.a.info("wallet.addSigner.success");return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=this.resolveSignerLocator(e);return _chunkO673DZDXcjs.a.info("wallet.removeSigner.start",{signerLocator:t}),_chunkDSIFRRBScjs.d.call(void 0, this,o).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).removeSigner(this.walletLocator,t,_chunkDSIFRRBScjs.a.call(void 0, {chain:this.chainAdapter.addSignerChain(this.chain)},n!=null&&{approver:n}));if("error"in a)throw _chunkO673DZDXcjs.a.error("wallet.removeSigner.error",{error:a}),new Error(`Failed to remove signer: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(_chunkO673DZDXcjs.a.info("wallet.removeSigner.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),_chunkO673DZDXcjs.a.info("wallet.removeSigner.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}addRecoveryMethod(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){this.assertRecoveryMethodManagementSupported(),_chunkO673DZDXcjs.a.info("wallet.addRecoveryMethod.start");let t=e.type==="server"?this.resolveServerSignerApiLocator(e):e;return _chunkDSIFRRBScjs.d.call(void 0, this,o).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=typeof t=="string"?t:_chunkXTYSMO67cjs.a.call(void 0, t.type).addSignerPayload(t,_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext()),c=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).registerRecoveryMethod(this.walletLocator,{recoveryMethods:a,approver:this.resolveRecoveryApprover(n)});if("error"in c)throw _chunkO673DZDXcjs.a.error("wallet.addRecoveryMethod.error",{error:c}),new (0, _chunkD2S37DJ5cjs.j)(`Failed to add recovery method: ${JSON.stringify(c.message)}`);let g=c.tx.id;return r!=null&&r.prepareOnly?(_chunkO673DZDXcjs.a.info("wallet.addRecoveryMethod.prepared",{transactionId:g}),{transactionId:g,status:void 0}):(yield this.approveTransactionAndWait(g),_chunkDSIFRRBScjs.d.call(void 0, this,o).addRecoverySigner(typeof t=="string"?{type:"server",address:t.slice(7)}:t),_chunkO673DZDXcjs.a.info("wallet.addRecoveryMethod.success",{transactionId:g}),{transactionId:g,status:"success"})}))})}removeRecoveryMethod(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){this.assertRecoveryMethodManagementSupported();let t=this.resolveSignerLocator(e);return _chunkO673DZDXcjs.a.info("wallet.removeRecoveryMethod.start",{recoveryMethodLocator:t}),_chunkDSIFRRBScjs.d.call(void 0, this,o).withRecoverySigner(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).removeRecoveryMethod(this.walletLocator,t,{approver:this.resolveRecoveryApprover(n)});if("error"in a)throw _chunkO673DZDXcjs.a.error("wallet.removeRecoveryMethod.error",{error:a}),new Error(`Failed to remove recovery method: ${JSON.stringify(a)}`);let c=a.id;return r!=null&&r.prepareOnly?(_chunkO673DZDXcjs.a.info("wallet.removeRecoveryMethod.prepared",{transactionId:c}),{transactionId:c,status:void 0}):(yield this.approveTransactionAndWait(c),_chunkDSIFRRBScjs.d.call(void 0, this,o).removeRecoverySigner(t),_chunkO673DZDXcjs.a.info("wallet.removeRecoveryMethod.success",{transactionId:c}),{transactionId:c,status:"success"})}))})}assertRecoveryMethodManagementSupported(){if(this.chain!=="solana"&&this.chain!=="stellar")throw new (0, _chunkD2S37DJ5cjs.u)(`Adding and removing recovery methods is not supported on ${this.chain} yet. It is available on Solana and Stellar.`)}resolveRecoveryApprover(e){return e!=null?e:_chunkDSIFRRBScjs.d.call(void 0, this,o).require().locator()}useSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.a.info("wallet.useSigner.start"),e.type==="server"&&_chunkDSIFRRBScjs.d.call(void 0, this,T).resetDelegatedCache(),_chunkXTYSMO67cjs.a.call(void 0, e.type).validateConfig(e);let r=!1;e.type==="device"?yield _chunkDSIFRRBScjs.d.call(void 0, this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=_chunkXTYSMO67cjs.a.call(void 0, e.type).buildInternalConfig(e,_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext()),n=_chunkWSDMIQNGcjs.b.call(void 0, e);_chunkDSIFRRBScjs.d.call(void 0, this,o).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,o).assemble(t,{isAdminSigner:r})),_chunkO673DZDXcjs.a.info("wallet.useSigner.success",{signerLocator:n})})}useRecoveryMethod(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.a.info("wallet.useRecoveryMethod.start"),_chunkXTYSMO67cjs.a.call(void 0, e.type).validateConfig(e);let r=this.matchRecoverySigner(e);if(r==null){let n=this.recoveryMethods.map(a=>_chunkDSIFRRBScjs.d.call(void 0, this,o).recoveryLocator(a)).filter(a=>a!=null).join(", ");throw new (0, _chunkD2S37DJ5cjs.o)(`Signer "${this.resolveSignerLocator(e)}" is not one of this wallet's recovery methods (${n}).`)}e.type==="server"&&_chunkDSIFRRBScjs.d.call(void 0, this,o).stripSecretFromRecovery(r,_chunkDSIFRRBScjs.d.call(void 0, this,T).resolveRecovery(e));let t=_chunkXTYSMO67cjs.a.call(void 0, e.type).adoptsRecoveryConfigOnMatch?this.recoveryMethods[r]:e.type==="passkey"?this.withPasskeyRecoveryCredentialId(e,r):e;_chunkDSIFRRBScjs.d.call(void 0, this,o).selectRecovery(r,t),_chunkO673DZDXcjs.a.info("wallet.useRecoveryMethod.success",{recoveryMethodLocator:_chunkDSIFRRBScjs.d.call(void 0, this,o).recoveryLocator(t)})})}resolveNonDeviceSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).map(c=>c.locator),n={recoveryIndex:null},a=_chunkDSIFRRBScjs.d.call(void 0, this,T).resolveForUseSigner(e,t,()=>(n.recoveryIndex=this.matchRecoverySigner(e),n.recoveryIndex!=null));switch(a.kind){case"delegated":return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!1;case"recovery":return n.recoveryIndex!=null&&_chunkDSIFRRBScjs.d.call(void 0, this,o).stripSecretFromRecovery(n.recoveryIndex,a.address),_chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;case"unregistered":throw new Error(a.message)}})}withPasskeyRecoveryCredentialId(e,r){if(_chunkWSDMIQNGcjs.a.call(void 0, e)!=null)return e;if(this.recoveryMethods.filter(a=>a.type==="passkey").length>1)throw new (0, _chunkD2S37DJ5cjs.o)('Multiple passkey recovery methods are registered on this wallet. Please specify the credential id: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');let n=_chunkWSDMIQNGcjs.a.call(void 0, this.recoveryMethods[r]);if(n==null)throw new (0, _chunkD2S37DJ5cjs.o)('The passkey recovery method has no credential id. Please specify it: wallet.useRecoveryMethod({ type: "passkey", id: "<credential-id>" })');return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{id:n})}tryAutoSelectPasskey(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):_chunkWSDMIQNGcjs.b.call(void 0, e)}isPasskeyMissingId(e){return _chunkWSDMIQNGcjs.a.call(void 0, e)==null}signerIsRegistered(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,o).signerIsRegistered(e)})}isSignerApproved(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,o).isSignerApproved(e)})}needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,S).needsRecovery}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,S).recover()})}signers(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a,c;_chunkO673DZDXcjs.a.info("wallet.signers.start");let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getWallet(this.walletLocator);if("error"in e)throw _chunkO673DZDXcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkD2S37DJ5cjs.e)(JSON.stringify(e));if(!me(e)){let g=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw _chunkO673DZDXcjs.a.error("wallet.signers.error",{error:g}),new (0, _chunkD2S37DJ5cjs.d)(g)}let r=(c=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?c:[],n=(yield Promise.all(r.map(g=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{return(yield _chunkDSIFRRBScjs.d.call(void 0, this,o).getSignerState(g.locator)).signer}catch(v){return _chunkO673DZDXcjs.a.warn("wallet.signers.mapSigner.failed",{locator:g.locator,error:v}),null}})))).filter(g=>g!=null);return _chunkO673DZDXcjs.a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(_chunkDSIFRRBScjs.d.call(void 0, this,d).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return _chunkDSIFRRBScjs.d.call(void 0, this,o)}preAuthIfNeeded(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,M),_chunkDSIFRRBScjs.d.call(void 0, this,L)==null&&_chunkDSIFRRBScjs.f.call(void 0, this,L,this.recover());try{yield _chunkDSIFRRBScjs.d.call(void 0, this,L)}finally{_chunkDSIFRRBScjs.f.call(void 0, this,L,null)}let e=_chunkDSIFRRBScjs.d.call(void 0, this,o).require();e instanceof _chunkZ6CVEP22cjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){return this.matchRecoverySigner(e)!=null}matchRecoverySigner(e){let r=_chunkXTYSMO67cjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,o).descriptorContext(),n=this.recoveryMethods.findIndex(a=>a.type===e.type&&r.matchesRecovery(e,a,t));return n===-1?null:(r.adoptsRecoveryConfigOnMatch&&_chunkDSIFRRBScjs.d.call(void 0, this,o).adoptRecoveryConfig(n,e),n)}resolveChainForEnvironment(){let e=_chunkA4F6GFJCcjs.f.call(void 0, this.chain,_chunkDSIFRRBScjs.d.call(void 0, this,d).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var v,y;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=_chunkDSIFRRBScjs.d.call(void 0, this,o).require(),n=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getSignature(this.walletLocator,e);if("error"in n)throw _chunkD2S37DJ5cjs.R.call(void 0, n),new (0, _chunkD2S37DJ5cjs.E)(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let h=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,h)}let a=(v=n.approvals)==null?void 0:v.pending;if(a==null||a.length===0)return n;let c=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],t],g=yield _chunkDSIFRRBScjs.g.call(void 0, this,b,H).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,b,j).call(this,a),c,(h,C)=>h.signMessage(C.message));return yield this.executeApproveSignatureWithErrorHandling(e,g)})}approveTransactionInternal(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var v,y,h,C,f;let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getTransaction(this.walletLocator,e);if("error"in t)throw _chunkD2S37DJ5cjs.R.call(void 0, t),new (0, _chunkD2S37DJ5cjs.J)(JSON.stringify(t));yield(h=(y=(v=_chunkDSIFRRBScjs.d.call(void 0, this,O))==null?void 0:v.callbacks)==null?void 0:y.onTransactionStart)==null?void 0:h.call(y);let n=_chunkDSIFRRBScjs.d.call(void 0, this,o).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let a=(C=t.approvals)==null?void 0:C.pending;if(a==null||a.length===0)return t;let c=[...(f=r==null?void 0:r.additionalSigners)!=null?f:[],n],g=yield _chunkDSIFRRBScjs.g.call(void 0, this,b,H).call(this,_chunkDSIFRRBScjs.g.call(void 0, this,b,j).call(this,a),c,(m,U)=>_chunkVUCADC63cjs.c.call(void 0, t.chainType,this.chainAdapter).signApproval(m,t,U.message));return yield this.executeApproveTransactionWithErrorHandling(e,g)})}executeApproveTransactionWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkO673DZDXcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkD2S37DJ5cjs.R.call(void 0, t),new (0, _chunkD2S37DJ5cjs.O)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkD2S37DJ5cjs.R.call(void 0, t),new (0, _chunkD2S37DJ5cjs.F)(JSON.stringify(t));return t})}waitForSignature(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkR3CAXQLJcjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,d),this.walletLocator,e)})}waitForTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e,r=6e4,t={}){return yield _chunkR3CAXQLJcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,d),this.walletLocator,e,_chunkDSIFRRBScjs.a.call(void 0, {timeoutMs:r},t))})}sleep(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};O=new WeakMap,d=new WeakMap,F=new WeakMap,T=new WeakMap,o=new WeakMap,S=new WeakMap,W=new WeakMap,M=new WeakMap,L=new WeakMap,b=new WeakSet,fe=function(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,S).tryResolveLocallyAvailableSigner(e);return r!=null&&_chunkO673DZDXcjs.a.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},we=function(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var n;let t=e.find(a=>a.locator()===r);if(t==null&&(t=(n=yield _chunkDSIFRRBScjs.g.call(void 0, this,b,fe).call(this,r))!=null?n:void 0),t==null)throw new (0, _chunkD2S37DJ5cjs.j)(`Signer ${r} not found in pending approvals`);return t})},j=function(e){return e.map(r=>{if(r.signer.type==="quorum")throw new (0, _chunkD2S37DJ5cjs.n)(`This wallet requires approval from a quorum signer (${r.signer.locator}), which is not yet supported by this SDK version`);return r})},H=function(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.all(e.map(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=yield _chunkDSIFRRBScjs.g.call(void 0, this,b,we).call(this,r,n.signer.locator),c=yield t(a,n);return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},c),{signer:a.locator()})})))})},_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"balances",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"stagingFund",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"send",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"approve",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.addRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"addRecoveryMethod",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.removeRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"removeRecoveryMethod",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.useRecoveryMethod",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"useRecoveryMethod",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"recover",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],w.prototype,"signers",1);function me(G){return G.type==="smart"&&_chunkVUCADC63cjs.b.call(void 0, G.chainType)}exports.a = w;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGSNFNRH2cjs = require('./chunk-GSNFNRH2.cjs');var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var R={[_commonsdkbase.APIKeyEnvironmentPrefix.DEVELOPMENT]:"https://development.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.STAGING]:"https://staging.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION]:"https://devicekey.store"},E=6e4,L="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;if(typeof window!="undefined"&&!_chunkGSNFNRH2cjs.a.call(void 0, ))throw new (0, _chunkD2S37DJ5cjs.x)("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=_commonsdkbase.getEnvironmentForKey.call(void 0, e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){_chunkM2AM4CBTcjs.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 _chunkDSIFRRBScjs.h.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 ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.reloading!=null)return this.reloading;let e=_chunkDSIFRRBScjs.h.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=>_chunkDSIFRRBScjs.h.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}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);exports.a = c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGSNFNRH2cjs = require('./chunk-GSNFNRH2.cjs');var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var R={[_commonsdkbase.APIKeyEnvironmentPrefix.DEVELOPMENT]:"https://development.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.STAGING]:"https://staging.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION]:"https://devicekey.store"},E=6e4,L="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;if(typeof window!="undefined"&&!_chunkGSNFNRH2cjs.a.call(void 0, ))throw new (0, _chunkD2S37DJ5cjs.x)("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=_commonsdkbase.getEnvironmentForKey.call(void 0, e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){_chunkO673DZDXcjs.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 _chunkDSIFRRBScjs.h.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 ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.reloading!=null)return this.reloading;let e=_chunkDSIFRRBScjs.h.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=>_chunkDSIFRRBScjs.h.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}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);exports.a = c;
@@ -0,0 +1 @@
1
+ var s="@crossmint/wallets-sdk",t="1.20.1";var c="WALLETS_SDK",r=t,a=s,d=200;export{c as a,r as b,a as c,d};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkUNAH34G2cjs = require('./chunk-UNAH34G2.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkUNAH34G2cjs.c,packageVersion:_chunkUNAH34G2cjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkH52MPNZPcjs = require('./chunk-H52MPNZP.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkH52MPNZPcjs.c,packageVersion:_chunkH52MPNZPcjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkFY4JJ3QZcjs = require('./chunk-FY4JJ3QZ.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function d(e,s){var l,t,r,i,a;let n=(l=e.chains)==null?void 0:l[s],c=_chunkFY4JJ3QZcjs.a.call(void 0, s).balanceTokenFields(n);return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {symbol:(t=e.symbol)!=null?t:"",name:(r=e.name)!=null?r:"",amount:(i=e.amount)!=null?i:"0",decimals:e.decimals,rawAmount:(a=e.rawAmount)!=null?a:"0"},(n==null?void 0:n.available)!=null?{available:n.available}:{}),(n==null?void 0:n.locked)!=null?{locked:n.locked}:{}),(n==null?void 0:n.accounts)!=null?{accounts:n.accounts}:{}),c)}function B(e,s){let n={symbol:e,name:e,amount:"0",decimals:0,rawAmount:"0"},c=_chunkFY4JJ3QZcjs.a.call(void 0, s).emptyBalanceTokenFields();return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},n),c)}function b(e,s,n){var r,i,a,f,p;if(s==null)return!0;let c=((r=e.symbol)!=null?r:"").toLowerCase();if(s.has(c))return!0;let l=(i=e.chains)==null?void 0:i[n];if(l==null)return!1;let t=_chunkENU3EKBGcjs.a.call(void 0, n);if(t==="solana"&&"mintHash"in l){let o=(a=l.mintHash)==null?void 0:a.toLowerCase();return o!=null&&(s.has(o)||s.has(`solana:${o}`))}if(t==="stellar"&&"contractId"in l){let o=(f=l.contractId)==null?void 0:f.toLowerCase();return o!=null&&(s.has(o)||s.has(`stellar:${o}`))}if("contractAddress"in l){let o=(p=l.contractAddress)==null?void 0:p.toLowerCase();return o!=null&&(s.has(o)||s.has(`${n}:${o}`))}return!1}function T(e,s,n,c){let l=e.find(a=>a.symbol===n),t=e.find(a=>a.symbol==="usdc"),r=c!=null?new Set(c.map(a=>a.toLowerCase())):null,i=e.filter(a=>a.symbol!==n&&a.symbol!=="usdc"&&b(a,r,s));return{nativeToken:l!=null?d(l,s):B(n,s),usdc:t!=null?d(t,s):B("usdc",s),tokens:i.map(a=>d(a,s))}}exports.a = T;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkVUCADC63cjs = require('./chunk-VUCADC63.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function d(e,s){var l,t,r,i,a;let n=(l=e.chains)==null?void 0:l[s],c=_chunkVUCADC63cjs.a.call(void 0, s).balanceTokenFields(n);return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {symbol:(t=e.symbol)!=null?t:"",name:(r=e.name)!=null?r:"",amount:(i=e.amount)!=null?i:"0",decimals:e.decimals,rawAmount:(a=e.rawAmount)!=null?a:"0"},(n==null?void 0:n.available)!=null?{available:n.available}:{}),(n==null?void 0:n.locked)!=null?{locked:n.locked}:{}),(n==null?void 0:n.accounts)!=null?{accounts:n.accounts}:{}),c)}function B(e,s){let n={symbol:e,name:e,amount:"0",decimals:0,rawAmount:"0"},c=_chunkVUCADC63cjs.a.call(void 0, s).emptyBalanceTokenFields();return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},n),c)}function b(e,s,n){var r,i,a,f,p;if(s==null)return!0;let c=((r=e.symbol)!=null?r:"").toLowerCase();if(s.has(c))return!0;let l=(i=e.chains)==null?void 0:i[n];if(l==null)return!1;let t=_chunkENU3EKBGcjs.a.call(void 0, n);if(t==="solana"&&"mintHash"in l){let o=(a=l.mintHash)==null?void 0:a.toLowerCase();return o!=null&&(s.has(o)||s.has(`solana:${o}`))}if(t==="stellar"&&"contractId"in l){let o=(f=l.contractId)==null?void 0:f.toLowerCase();return o!=null&&(s.has(o)||s.has(`stellar:${o}`))}if("contractAddress"in l){let o=(p=l.contractAddress)==null?void 0:p.toLowerCase();return o!=null&&(s.has(o)||s.has(`${n}:${o}`))}return!1}function T(e,s,n,c){let l=e.find(a=>a.symbol===n),t=e.find(a=>a.symbol==="usdc"),r=c!=null?new Set(c.map(a=>a.toLowerCase())):null,i=e.filter(a=>a.symbol!==n&&a.symbol!=="usdc"&&b(a,r,s));return{nativeToken:l!=null?d(l,s):B(n,s),usdc:t!=null?d(t,s):B("usdc",s),tokens:i.map(a=>d(a,s))}}exports.a = T;
@@ -1 +1 @@
1
- import{B as M,E as m,G as b,J as C,K as x,L as A,M as y,N as k,R as w}from"./chunk-4I3EXM4B.js";import{a as E}from"./chunk-YIUOOMT4.js";import{d as S}from"./chunk-7TVBGFKY.js";import{h as l}from"./chunk-NU7VF7MC.js";function W(i,o,a,r){return l(this,null,function*(){var h,d;let{timeoutMs:e=6e4,initialBackoffMs:u=500,backoffMultiplier:n=1.5,maxBackoffMs:f=2e3,fastWindowMs:L=5e3}=r!=null?r:{};E.info("wallet.approve: waiting for transaction confirmation",{transactionId:a,timeoutMs:e});let p=Date.now(),c=u,t;do{if(Date.now()-p>e)throw new x("Transaction confirmation timeout");let s=Date.now();if(t=yield i.getTransaction(o,a),t.error)throw w(t),new C(JSON.stringify(t));if(t.status!=="pending")break;let T=Date.now()-p;T>L&&(c=Math.min(Math.round(c*n),f));let v=Date.now()-s;yield D(Math.max(1,Math.min(c-v,e-T)))}while(!0);if(t.status==="failed")throw new A(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new y("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let P="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(h=t.onChain.txId)!=null?h:P;if(g==null)throw new k("Transaction hash not found on transaction response");return{hash:g,explorerLink:(d=t.onChain.explorerLink)!=null?d:"",transactionId:t.id}})}function B(i,o,a,r){return l(this,null,function*(){let{timeoutMs:e=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>e)throw new b("Signature confirmation timeout");if(yield new Promise(f=>setTimeout(f,S)),n=yield i.getSignature(o,a),"error"in n)throw w(n),new m(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new M("Signature signing failed");if(!n.outputSignature)throw new m("Signature not available");return{signature:n.outputSignature,signatureId:a}})}function D(i){return l(this,null,function*(){return new Promise(o=>setTimeout(o,i))})}export{W as a,B as b};
1
+ import{B as M,E as m,G as b,J as C,K as x,L as A,M as y,N as k,R as w}from"./chunk-4I3EXM4B.js";import{a as E}from"./chunk-QNNWOOHI.js";import{d as S}from"./chunk-NULQLE3D.js";import{h as l}from"./chunk-NU7VF7MC.js";function W(i,o,a,r){return l(this,null,function*(){var h,d;let{timeoutMs:e=6e4,initialBackoffMs:u=500,backoffMultiplier:n=1.5,maxBackoffMs:f=2e3,fastWindowMs:L=5e3}=r!=null?r:{};E.info("wallet.approve: waiting for transaction confirmation",{transactionId:a,timeoutMs:e});let p=Date.now(),c=u,t;do{if(Date.now()-p>e)throw new x("Transaction confirmation timeout");let s=Date.now();if(t=yield i.getTransaction(o,a),t.error)throw w(t),new C(JSON.stringify(t));if(t.status!=="pending")break;let T=Date.now()-p;T>L&&(c=Math.min(Math.round(c*n),f));let v=Date.now()-s;yield D(Math.max(1,Math.min(c-v,e-T)))}while(!0);if(t.status==="failed")throw new A(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new y("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let P="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(h=t.onChain.txId)!=null?h:P;if(g==null)throw new k("Transaction hash not found on transaction response");return{hash:g,explorerLink:(d=t.onChain.explorerLink)!=null?d:"",transactionId:t.id}})}function B(i,o,a,r){return l(this,null,function*(){let{timeoutMs:e=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>e)throw new b("Signature confirmation timeout");if(yield new Promise(f=>setTimeout(f,S)),n=yield i.getSignature(o,a),"error"in n)throw w(n),new m(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new M("Signature signing failed");if(!n.outputSignature)throw new m("Signature not available");return{signature:n.outputSignature,signatureId:a}})}function D(i){return l(this,null,function*(){return new Promise(o=>setTimeout(o,i))})}export{W as a,B as b};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkMQEPGBWNcjs = require('./chunk-MQEPGBWN.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class d extends _chunkMQEPGBWNcjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(_bs582.default.decode(e))})}signTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.signMessage(e)})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var r;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkM2AM4CBTcjs.a.info("sign: sending request",{keyType:"ed25519"});let u=Date.now(),n=yield(r=this.config.clientTEEConnection)==null?void 0:r.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(e)),encoding:"base58",authId:this.getAuthId()}},options:_chunkMQEPGBWNcjs.b});if(_chunkM2AM4CBTcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-u}),(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 payload");return d.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="base58"||e.keyType!=="ed25519"||e.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(e))}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 _chunkZ6CVEP22cjs = require('./chunk-Z6CVEP22.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class d extends _chunkZ6CVEP22cjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(_bs582.default.decode(e))})}signTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.signMessage(e)})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var r;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkO673DZDXcjs.a.info("sign: sending request",{keyType:"ed25519"});let u=Date.now(),n=yield(r=this.config.clientTEEConnection)==null?void 0:r.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(e)),encoding:"base58",authId:this.getAuthId()}},options:_chunkZ6CVEP22cjs.b});if(_chunkO673DZDXcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-u}),(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 payload");return d.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="base58"||e.keyType!=="ed25519"||e.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk5DVT5DB6cjs = require('./chunk-5DVT5DB6.cjs');var _chunk5GYSXH4Xcjs = require('./chunk-5GYSXH4X.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkM2AM4CBTcjs = require('./chunk-M2AM4CBT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _tweetnacl = require('tweetnacl'); var _tweetnacl2 = _interopRequireDefault(_tweetnacl);var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunk5DVT5DB6cjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk5DVT5DB6cjs.a.getOptions(e),alias:e.alias,recovery:_chunk5DVT5DB6cjs.a.getRecoverySigners(e),apiRecoveryServerSignerAddresses:_chunk5DVT5DB6cjs.a.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:_chunk5DVT5DB6cjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk5DVT5DB6cjs.a.getInitialSigners(e)},_chunk5DVT5DB6cjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, e.address))throw new Error("Wallet is not a Solana wallet");return new c(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g,S;_chunkM2AM4CBTcjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((g=e.options)!=null&&g.prepareOnly)return _chunkM2AM4CBTcjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(S=e.additionalSigners)==null?void 0:S.map(o=>new (0, _chunk5GYSXH4Xcjs.a)({type:"external-wallet",address:o.publicKey.toString(),locator:`external-wallet:${o.publicKey.toString()}`,onSign:d=>(d.sign([o]),Promise.resolve(d)),onSignBytes:d=>Promise.resolve(_bs582.default.encode(_tweetnacl2.default.sign.detached(_bs582.default.decode(d),o.secretKey)))}))},a=yield this.approveTransactionAndWait(n.id,i);return _chunkM2AM4CBTcjs.a.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.signerManager.require().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=_bs582.default.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new (0, _chunkD2S37DJ5cjs.I)(JSON.stringify(i));return i})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkM2AM4CBTcjs.a,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1);var T=c;exports.a = T;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkNBZEWJUHcjs = require('./chunk-NBZEWJUH.cjs');var _chunk5GYSXH4Xcjs = require('./chunk-5GYSXH4X.cjs');var _chunkD2S37DJ5cjs = require('./chunk-D2S37DJ5.cjs');var _chunkO673DZDXcjs = require('./chunk-O673DZDX.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _tweetnacl = require('tweetnacl'); var _tweetnacl2 = _interopRequireDefault(_tweetnacl);var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkNBZEWJUHcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkNBZEWJUHcjs.a.getOptions(e),alias:e.alias,recovery:_chunkNBZEWJUHcjs.a.getRecoverySigners(e),apiRecoveryServerSignerAddresses:_chunkNBZEWJUHcjs.a.getApiRecoveryServerSignerAddresses(e),apiDelegatedServerSignerAddresses:_chunkNBZEWJUHcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkNBZEWJUHcjs.a.getInitialSigners(e)},_chunkNBZEWJUHcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, e.address))throw new Error("Wallet is not a Solana wallet");return new c(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g,S;_chunkO673DZDXcjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((g=e.options)!=null&&g.prepareOnly)return _chunkO673DZDXcjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(S=e.additionalSigners)==null?void 0:S.map(o=>new (0, _chunk5GYSXH4Xcjs.a)({type:"external-wallet",address:o.publicKey.toString(),locator:`external-wallet:${o.publicKey.toString()}`,onSign:d=>(d.sign([o]),Promise.resolve(d)),onSignBytes:d=>Promise.resolve(_bs582.default.encode(_tweetnacl2.default.sign.detached(_bs582.default.decode(d),o.secretKey)))}))},a=yield this.approveTransactionAndWait(n.id,i);return _chunkO673DZDXcjs.a.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.signerManager.require().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=_bs582.default.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new (0, _chunkD2S37DJ5cjs.I)(JSON.stringify(i));return i})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkO673DZDXcjs.a,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1);var T=c;exports.a = T;
@@ -1 +1 @@
1
- import{b as n,c as i}from"./chunk-7TVBGFKY.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
1
+ import{b as n,c as i}from"./chunk-NULQLE3D.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};