@crossmint/wallets-sdk 1.12.0 → 1.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (128) 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.js +1 -1
  17. package/dist/{chunk-M3IEG5GA.js → chunk-2Q4WYCJK.js} +1 -1
  18. package/dist/{chunk-QVE2LOBH.js → chunk-36ZZPH5C.js} +1 -1
  19. package/dist/{chunk-N7Z3C5RJ.js → chunk-4NQ7C2F3.js} +1 -1
  20. package/dist/{chunk-GIYB3U37.cjs → chunk-52DSGFRG.cjs} +1 -1
  21. package/dist/{chunk-PSK7FYV7.cjs → chunk-5NHL2AW6.cjs} +1 -1
  22. package/dist/{chunk-SZXFHFA5.js → chunk-5RXSFMFU.js} +1 -1
  23. package/dist/{chunk-TZGYISF7.js → chunk-5W37U67F.js} +1 -1
  24. package/dist/chunk-6EWYCV4P.cjs +1 -0
  25. package/dist/chunk-6ZMBFE4T.js +1 -0
  26. package/dist/{chunk-J2C3XP4Z.cjs → chunk-7GJLRYUQ.cjs} +1 -1
  27. package/dist/{chunk-HSLCNCPW.cjs → chunk-AVX5ICB6.cjs} +1 -1
  28. package/dist/{chunk-5BRX4CFK.cjs → chunk-BHMBFV5Z.cjs} +1 -1
  29. package/dist/{chunk-J5CHOVJL.cjs → chunk-BZA3LQT4.cjs} +1 -1
  30. package/dist/{chunk-JJVNOMYX.cjs → chunk-CUP4XXMT.cjs} +1 -1
  31. package/dist/{chunk-4ILFMPNK.js → chunk-CXR3NH2D.js} +1 -1
  32. package/dist/chunk-DDSCINJX.js +1 -0
  33. package/dist/{chunk-S3PBSOOZ.cjs → chunk-DHY24KCS.cjs} +1 -1
  34. package/dist/{chunk-CB3YEJ7F.js → chunk-DXBNYAF3.js} +1 -1
  35. package/dist/{chunk-ECHVBCCM.js → chunk-FL5XTA2Z.js} +1 -1
  36. package/dist/chunk-GKQXMDRT.js +1 -0
  37. package/dist/{chunk-N7DIMQBP.cjs → chunk-HGQTXQ5K.cjs} +1 -1
  38. package/dist/{chunk-UTZP5A65.js → chunk-HIZL7OME.js} +1 -1
  39. package/dist/{chunk-YRX44YXB.js → chunk-HO7VI37F.js} +1 -1
  40. package/dist/chunk-JCNQFYND.js +1 -0
  41. package/dist/{chunk-WTLEFDHS.cjs → chunk-JEST5DJZ.cjs} +1 -1
  42. package/dist/{chunk-NL4MRKYW.cjs → chunk-KCR63V4C.cjs} +1 -1
  43. package/dist/{chunk-LJNSIXGN.cjs → chunk-LKQX44ZD.cjs} +1 -1
  44. package/dist/{chunk-WQDLMGEG.js → chunk-LMCLD76H.js} +1 -1
  45. package/dist/{chunk-MGQGQXRP.cjs → chunk-NVKEVEOY.cjs} +1 -1
  46. package/dist/{chunk-2277DKO3.js → chunk-PJQCOLKL.js} +1 -1
  47. package/dist/{chunk-P3SMYLDM.cjs → chunk-QCJA5FJL.cjs} +1 -1
  48. package/dist/chunk-QTWUABUJ.js +1 -0
  49. package/dist/{chunk-LKEPKOKU.cjs → chunk-R2GZ5L4Q.cjs} +1 -1
  50. package/dist/{chunk-BM6GYJSE.cjs → chunk-RCQMAOU6.cjs} +1 -1
  51. package/dist/{chunk-NUGL76QG.js → chunk-RDXPOGIO.js} +1 -1
  52. package/dist/{chunk-KJNGLQC7.js → chunk-REFPDFQ6.js} +1 -1
  53. package/dist/{chunk-OUZECW5T.js → chunk-RSEM7IWN.js} +1 -1
  54. package/dist/{chunk-XN7S5JJY.cjs → chunk-S26A5F6S.cjs} +1 -1
  55. package/dist/{chunk-IX5TSD73.cjs → chunk-S73R7VRQ.cjs} +1 -1
  56. package/dist/{chunk-26DL7XRG.js → chunk-ST63L4FD.js} +1 -1
  57. package/dist/chunk-T5OX7TEH.cjs +1 -0
  58. package/dist/{chunk-ZF4ENDFP.js → chunk-TMHT7BAX.js} +1 -1
  59. package/dist/{chunk-3SHAB7GH.js → chunk-UCAOZD7R.js} +1 -1
  60. package/dist/{chunk-OHTCLNE3.cjs → chunk-UGGVGFV2.cjs} +1 -1
  61. package/dist/{chunk-MYIY3CX7.cjs → chunk-VILSUI3M.cjs} +1 -1
  62. package/dist/chunk-VYX2NH35.cjs +1 -0
  63. package/dist/{chunk-3WJUXFU2.cjs → chunk-W72CDNMU.cjs} +1 -1
  64. package/dist/{chunk-53JN7AMK.js → chunk-WL3H2D3J.js} +1 -1
  65. package/dist/chunk-X24IHG7P.cjs +1 -0
  66. package/dist/{chunk-BDCQ4HVW.js → chunk-ZA6CCBFR.js} +1 -1
  67. package/dist/index.cjs +1 -1
  68. package/dist/index.js +1 -1
  69. package/dist/logger/index.cjs +1 -1
  70. package/dist/logger/index.js +1 -1
  71. package/dist/logger/init.cjs +1 -1
  72. package/dist/logger/init.js +1 -1
  73. package/dist/sdk.cjs +1 -1
  74. package/dist/sdk.js +1 -1
  75. package/dist/signers/index.cjs +1 -1
  76. package/dist/signers/index.js +1 -1
  77. package/dist/signers/non-custodial/index.cjs +1 -1
  78. package/dist/signers/non-custodial/index.js +1 -1
  79. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  80. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  81. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  82. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  83. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  84. package/dist/signers/non-custodial/ncs-solana-signer.d.cts +8 -1
  85. package/dist/signers/non-custodial/ncs-solana-signer.d.ts +8 -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/signers/passkey.cjs +1 -1
  90. package/dist/signers/passkey.js +1 -1
  91. package/dist/utils/constants.cjs +1 -1
  92. package/dist/utils/constants.js +1 -1
  93. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  94. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  95. package/dist/utils/device-signers/index.cjs +1 -1
  96. package/dist/utils/device-signers/index.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.d.cts +2 -1
  117. package/dist/wallets/wallet.d.ts +2 -1
  118. package/dist/wallets/wallet.js +1 -1
  119. package/package.json +4 -4
  120. package/dist/chunk-5VUIA6TB.cjs +0 -1
  121. package/dist/chunk-FJYRJSKU.cjs +0 -1
  122. package/dist/chunk-L5X5RA7E.cjs +0 -1
  123. package/dist/chunk-LMHH6ODX.cjs +0 -1
  124. package/dist/chunk-OQN2SFDC.js +0 -1
  125. package/dist/chunk-SCEZVF7J.js +0 -1
  126. package/dist/chunk-T2R4SPKJ.js +0 -1
  127. package/dist/chunk-TMOWGJ5Z.js +0 -1
  128. package/dist/chunk-XHANQPKI.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var o={nativeToken:"xlm",walletLocatorPrefix:"me:stellar:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,r,t){if(!("transaction"in n)||n.transaction==null)throw _chunkPSK7FYV7cjs.a.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&&"contractId"in n?{contractId:n.contractId}:n!=null&&"contractAddress"in n?{contractAddress:n.contractAddress}:{}},emptyBalanceTokenFields(){return{contractId:void 0}}};exports.a = o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.cjs');var o={nativeToken:"xlm",walletLocatorPrefix:"me:stellar:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,r,t){if(!("transaction"in n)||n.transaction==null)throw _chunk5NHL2AW6cjs.a.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&&"contractId"in n?{contractId:n.contractId}:n!=null&&"contractAddress"in n?{contractAddress:n.contractAddress}:{}},emptyBalanceTokenFields(){return{contractId:void 0}}};exports.a = o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkLJNSIXGNcjs = require('./chunk-LJNSIXGN.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkLJNSIXGNcjs.c,version:_chunkLJNSIXGNcjs.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`;_chunkPSK7FYV7cjs.a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let n=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in n?_chunkPSK7FYV7cjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkPSK7FYV7cjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkPSK7FYV7cjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkPSK7FYV7cjs.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 n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.json()})}getSignature(e,s){return _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 n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?_chunkPSK7FYV7cjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkPSK7FYV7cjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkXZ4NKVEBcjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkXZ4NKVEBcjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.cjs');var _chunkLKQX44ZDcjs = require('./chunk-LKQX44ZD.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkLKQX44ZDcjs.c,version:_chunkLKQX44ZDcjs.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`;_chunk5NHL2AW6cjs.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?_chunk5NHL2AW6cjs.a.error("wallets.api.createWallet.error",{error:t.error,chainType:e.chainType}):"address"in t&&_chunk5NHL2AW6cjs.a.info("wallets.api.createWallet.success",{address:t.address,chainType:e.chainType}),t})}getWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunk5NHL2AW6cjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunk5NHL2AW6cjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunk5NHL2AW6cjs.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);let p=`${this.apiPrefix}/${e}/signers/${t}${a.size>0?`?${a.toString()}`:""}`;return(yield this.delete(p,{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(p){}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*(){_chunk5NHL2AW6cjs.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?_chunk5NHL2AW6cjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:a.error}):"id"in a&&_chunk5NHL2AW6cjs.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, _chunkXZ4NKVEBcjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkXZ4NKVEBcjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHSLCNCPWcjs = require('./chunk-HSLCNCPW.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkJ5CHOVJLcjs = require('./chunk-J5CHOVJL.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkPSK7FYV7cjs.b.call(void 0, e.apiKey);let t=new (0, _chunkJ5CHOVJLcjs.a)(e);this.walletFactory=new (0, _chunkHSLCNCPWcjs.a)(t),_chunkPSK7FYV7cjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkGMU3ZYLScjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkAVX5ICB6cjs = require('./chunk-AVX5ICB6.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkBZA3LQT4cjs = require('./chunk-BZA3LQT4.cjs');var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunk5NHL2AW6cjs.b.call(void 0, e.apiKey);let t=new (0, _chunkBZA3LQT4cjs.a)(e);this.walletFactory=new (0, _chunkAVX5ICB6cjs.a)(t),_chunk5NHL2AW6cjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkGMU3ZYLScjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
@@ -1 +1 @@
1
- import{b as n,c as i}from"./chunk-SCEZVF7J.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-JCNQFYND.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};
@@ -0,0 +1 @@
1
+ import{s as n}from"./chunk-7FEY62ID.js";import{h as e}from"./chunk-NU7VF7MC.js";import{Hex as g,WebAuthnP256 as c}from"ox";var u=37,h=32,f=4;function A(i){let t=g.toBytes(i);return t.length<u?!1:(t[h]&f)!==0}var a=class{constructor(t){this.config=t;this.type="passkey";this.id=t.id}locator(){return this.config.locator}signMessage(t){return e(this,null,function*(){if(this.config.onSignWithPasskey){let r=yield this.config.onSignWithPasskey(t);if(!A(r.metadata.authenticatorData))throw new n('The passkey assertion was created without user verification, and the on-chain verifier requires it. Request the assertion with `userVerification: "required"` so the authenticator prompts for biometrics or a PIN.');return r}let{signature:s,metadata:o}=yield c.sign({credentialId:this.id,challenge:t});return{signature:{r:`0x${s.r.toString(16)}`,s:`0x${s.s.toString(16)}`},metadata:o}})}signTransaction(t){return e(this,null,function*(){return yield this.signMessage(t)})}};export{a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkATIC4ENGcjs = require('./chunk-ATIC4ENG.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=class{constructor(n){this.config=n;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let n=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:n.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("TEE connection not initialized, initializing now");let n=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:n.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkPSK7FYV7cjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;let n=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);_chunkPSK7FYV7cjs.a.info("get-status: sending request");let t=Date.now(),e=yield n.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),s=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw _chunkPSK7FYV7cjs.a.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:s}),new (0, _chunkQPCZFIUVcjs.c)(c,p)}if(_chunkPSK7FYV7cjs.a.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:s}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkPSK7FYV7cjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:i,resolve:a,reject:r}=this.createAuthPromise();if(this._authPromise={promise:i,resolve:a,reject:r},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new _chunkQPCZFIUVcjs.a)})),r(new _chunkQPCZFIUVcjs.a)}))}catch(c){_chunkPSK7FYV7cjs.a.error("handleAuthRequired error",{error:c}),r(c)}try{yield i}catch(c){throw _chunkPSK7FYV7cjs.a.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let n=this.config.crossmint.jwt;if(n==null)throw new Error("JWT is required");return n}createAuthPromise(){let n,t;return{promise:new Promise((s,i)=>{n=s,t=i}),resolve:n,reject:t}}sendMessageWithOtp(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var r;let n=yield this.getTEEConnection(),t=this.getAuthId();_chunkPSK7FYV7cjs.a.info("start-onboarding: sending request");let e=Date.now(),s=this.config.type==="phone"?this.config.channel:void 0,i=yield n.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(r=this.config.crossmint.jwt)!=null?r:"",apiKey:this.config.crossmint.apiKey},data:_chunkDSIFRRBScjs.a.call(void 0, {authId:t},s!=null?{channel:s}:{})},options:l}),a=Date.now()-e;if(this._onboardingConnectionGeneration=n.connectionGeneration,_chunkPSK7FYV7cjs.a.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:a}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error")throw _chunkPSK7FYV7cjs.a.error("start-onboarding: failed",{error:i.error,code:i.code}),new (0, _chunkQPCZFIUVcjs.b)(i.error||"Failed to initiate OTP process.",i.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i,a;let t;try{let r=yield this.getTEEConnection();_chunkPSK7FYV7cjs.a.info("complete-onboarding: sending request");let d=Date.now();t=yield r.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(i=this.config.crossmint.jwt)!=null?i:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:n}}},options:l}),_chunkPSK7FYV7cjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(r){return _chunkPSK7FYV7cjs.a.error("complete-onboarding: error",{error:r}),yield this.handleOnboardingVerificationFailure(r)}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),r=>this.verifyOtp(r),()=>{var r;return(r=this._authPromise)==null?void 0:r.reject(new _chunkQPCZFIUVcjs.a)})),(a=this._authPromise)==null||a.resolve();return}_chunkPSK7FYV7cjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",s=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new (0, _chunkQPCZFIUVcjs.b)(e,s))})}handleOnboardingVerificationFailure(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var s,i,a;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){_chunkPSK7FYV7cjs.a.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(r){throw(s=this._authPromise)==null||s.reject(r),r}if(!this._needsAuth){(i=this._authPromise)==null||i.resolve();return}throw new _chunkQPCZFIUVcjs.e}throw(a=this._authPromise)==null||a.reject(n),n})}_exportPrivateKey(n,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:s,encoding:i}=this.getChainKeyParams();if(t!=null){let r=n.on("event:key-exported",d=>{n.off(r),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let a=yield n.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:s,encoding:i,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((a==null?void 0:a.status)==="error")throw _chunkPSK7FYV7cjs.a.error("export-signer: failed",{error:a.error,code:a.code}),new (0, _chunkQPCZFIUVcjs.d)(a.error||"Failed to export private key",a.code)})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};exports.a = m; exports.b = l;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkATIC4ENGcjs = require('./chunk-ATIC4ENG.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=class{constructor(n){this.config=n;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let n=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:n.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunk5NHL2AW6cjs.a.info("TEE connection not initialized, initializing now");let n=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:n.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunk5NHL2AW6cjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;let n=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);_chunk5NHL2AW6cjs.a.info("get-status: sending request");let t=Date.now(),e=yield n.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),s=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw _chunk5NHL2AW6cjs.a.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:s}),new (0, _chunkQPCZFIUVcjs.c)(c,p)}if(_chunk5NHL2AW6cjs.a.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:s}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunk5NHL2AW6cjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:i,resolve:a,reject:r}=this.createAuthPromise();if(this._authPromise={promise:i,resolve:a,reject:r},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunk5NHL2AW6cjs.a.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new _chunkQPCZFIUVcjs.a)})),r(new _chunkQPCZFIUVcjs.a)}))}catch(c){_chunk5NHL2AW6cjs.a.error("handleAuthRequired error",{error:c}),r(c)}try{yield i}catch(c){throw _chunk5NHL2AW6cjs.a.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let n=this.config.crossmint.jwt;if(n==null)throw new Error("JWT is required");return n}createAuthPromise(){let n,t;return{promise:new Promise((s,i)=>{n=s,t=i}),resolve:n,reject:t}}sendMessageWithOtp(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var r;let n=yield this.getTEEConnection(),t=this.getAuthId();_chunk5NHL2AW6cjs.a.info("start-onboarding: sending request");let e=Date.now(),s=this.config.type==="phone"?this.config.channel:void 0,i=yield n.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(r=this.config.crossmint.jwt)!=null?r:"",apiKey:this.config.crossmint.apiKey},data:_chunkDSIFRRBScjs.a.call(void 0, {authId:t},s!=null?{channel:s}:{})},options:l}),a=Date.now()-e;if(this._onboardingConnectionGeneration=n.connectionGeneration,_chunk5NHL2AW6cjs.a.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:a}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error")throw _chunk5NHL2AW6cjs.a.error("start-onboarding: failed",{error:i.error,code:i.code}),new (0, _chunkQPCZFIUVcjs.b)(i.error||"Failed to initiate OTP process.",i.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i,a;let t;try{let r=yield this.getTEEConnection();_chunk5NHL2AW6cjs.a.info("complete-onboarding: sending request");let d=Date.now();t=yield r.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(i=this.config.crossmint.jwt)!=null?i:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:n}}},options:l}),_chunk5NHL2AW6cjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(r){return _chunk5NHL2AW6cjs.a.error("complete-onboarding: error",{error:r}),yield this.handleOnboardingVerificationFailure(r)}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),r=>this.verifyOtp(r),()=>{var r;return(r=this._authPromise)==null?void 0:r.reject(new _chunkQPCZFIUVcjs.a)})),(a=this._authPromise)==null||a.resolve();return}_chunk5NHL2AW6cjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",s=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new (0, _chunkQPCZFIUVcjs.b)(e,s))})}handleOnboardingVerificationFailure(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var s,i,a;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){_chunk5NHL2AW6cjs.a.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(r){throw(s=this._authPromise)==null||s.reject(r),r}if(!this._needsAuth){(i=this._authPromise)==null||i.resolve();return}throw new _chunkQPCZFIUVcjs.e}throw(a=this._authPromise)==null||a.reject(n),n})}_exportPrivateKey(n,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:s,encoding:i}=this.getChainKeyParams();if(t!=null){let r=n.on("event:key-exported",d=>{n.off(r),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let a=yield n.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:s,encoding:i,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((a==null?void 0:a.status)==="error")throw _chunk5NHL2AW6cjs.a.error("export-signer: failed",{error:a.error,code:a.code}),new (0, _chunkQPCZFIUVcjs.d)(a.error||"Failed to export private key",a.code)})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk5NHL2AW6cjs.a,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};exports.a = m; exports.b = l;
@@ -1 +1 @@
1
- import{a as j}from"./chunk-5LNDUSMZ.js";import{a as R}from"./chunk-JEKHYLBB.js";import{a as T,b as M}from"./chunk-3SHAB7GH.js";import{a as W,b as E,f as O}from"./chunk-DCKFFFPG.js";import{m as I}from"./chunk-7FEY62ID.js";import{a as s}from"./chunk-4ILFMPNK.js";import{d as e,e as d,f as o,g as w,h as f}from"./chunk-NU7VF7MC.js";var l,m,C,p,y,n,b,A,k,L,K,P,u,V,F,q,B,$,N=class{constructor(r){d(this,u);d(this,l,"unknown");d(this,m,!1);d(this,C);d(this,p);d(this,y);d(this,n);d(this,b);d(this,A);d(this,k);d(this,L);d(this,K);d(this,P);o(this,C,r.chain),o(this,p,r.walletAddress),o(this,y,r.options),o(this,n,r.signerManager),o(this,b,r.serverSignerResolver),o(this,A,r.signers),o(this,k,r.addSigner),o(this,L,r.removeSigner),o(this,K,r.approveSignature),o(this,P,r.approveTransaction)}get needsRecovery(){return e(this,l)==="needs-recovery"}onSignerSelected(){e(this,l)==="needs-recovery"&&o(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(S){s.error("wallet.initDeviceSigner.error",{error:S}),o(this,l,"needs-recovery");return}if(e(this,l)==="needs-recovery")return;let a=R(i.type).buildInternalConfig(i,e(this,n).descriptorContext()),t=yield e(this,n).assemble(a);e(this,n).setActiveSigner(t),e(this,n).isApprovedSignerStatus(t.status)||(s.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),o(this,l,"needs-recovery"))})}recover(){return f(this,null,function*(){var D;if(s.info("wallet.recover.start"),e(this,l)==="resolved"){s.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(e(this,m)){s.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),o(this,l,"resolved");return}let r=e(this,n).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield w(this,u,F).call(this,r))){o(this,l,"resolved");return}if(r!=null&&r.type!=="device"){s.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),o(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 a=yield e(this,A).call(this),t=yield w(this,u,B).call(this,i,a);if(t!=null&&(yield w(this,u,F).call(this,t))){e(this,n).setActiveSigner(t),o(this,l,"resolved");let c=t.locator().replace("device:","");try{yield i.mapAddressToKey(e(this,p),c)}catch(z){s.warn("wallet.recover.mapAddressToKey.error",{error:z})}return}let g=a.filter(c=>c.type==="device"),S=w(this,u,V).call(this,g,i),v=yield j(i,e(this,p));try{yield e(this,k).call(this,v)}catch(c){if(c instanceof I){s.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(e(this,p)),o(this,m,!0),o(this,l,"resolved"),yield w(this,u,$).call(this);return}else if(G(c))s.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw c instanceof W||c instanceof Error&&c.name==="AuthRejectedError"?(s.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),c):c instanceof E||c instanceof Error&&c.name==="OtpValidationError"?(s.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:c instanceof E?c.code:void 0}),c):(s.error("wallet.recover.device.error",{error:c}),yield i.deleteKey(e(this,p)),c)}let h=yield e(this,n).assemble({type:"device",locator:v.locator,address:e(this,p)});if(e(this,n).setActiveSigner(h),h.type==="device"&&(h.status="success"),s.info("wallet.recover.device.success",{signerLocator:v.locator}),o(this,l,"resolved"),S!=null)try{yield e(this,L).call(this,S),s.info("wallet.recover.staleSignerRemoved",{signerLocator:S})}catch(c){s.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:S,error:c})}})}resolveAvailability(r){return f(this,null,function*(){var S;let i=(S=e(this,y))==null?void 0:S.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let a=yield i.getKey(e(this,p));if(a!=null){r.locator=`device:${a}`,o(this,l,"unknown");return}let g=(yield e(this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let h=v.locator.replace("device:","");if(yield i.hasKey(h)){yield i.mapAddressToKey(e(this,p),h),r.locator=v.locator,o(this,l,"unknown");return}}o(this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return f(this,arguments,function*(r,i=(a=>(a=e(this,y))==null?void 0:a.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield M(e(this,C),r,e(this,p),i)}catch(g){return s.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,p=new WeakMap,y=new WeakMap,n=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,V=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let a=i.getDeviceName(),t=r.filter(g=>g.name===a);return t.length===1?t[0].locator:void 0},F=function(r){return f(this,null,function*(){var a;if(e(this,n).isApprovedSignerStatus(r.status))return s.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield e(this,n).getSignerState(r.locator());return r.status=(a=i.signer)==null?void 0:a.status,i.pendingOperation!=null?(yield w(this,u,q).call(this,r,i.pendingOperation),!0):e(this,n).isApprovedSignerStatus(r.status)?(s.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},q=function(r,i){return f(this,null,function*(){var h;let a=e(this,n).activeSigner,t=e(this,n).recovery;if(O(t)&&!e(this,b).hasRecoveryResolution)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),S=e(this,n).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,S))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,S);e(this,n).setActiveSigner(T(e(this,C),v,(h=e(this,y))==null?void 0:h.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,n).setActiveSigner(r),D}finally{e(this,n).activeSigner!==r&&e(this,n).setActiveSigner(a)}r.status="success",s.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},B=function(r,i){return f(this,null,function*(){let a=i.filter(t=>t.locator.startsWith("device:"));for(let t of a){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return s.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},$=function(){return f(this,null,function*(){let r=e(this,n).recovery,i=R(r.type),a=e(this,n).descriptorContext();if(i.canAutoAssemble(r,a))try{let t=i.buildInternalConfig(r,a);e(this,n).setActiveSigner(yield e(this,n).assemble(t,{isAdminSigner:!0}))}catch(t){s.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function G(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}export{N as a};
1
+ import{a as j}from"./chunk-5LNDUSMZ.js";import{a as R}from"./chunk-JEKHYLBB.js";import{a as T,b as M}from"./chunk-UCAOZD7R.js";import{a as W,b as E,f as O}from"./chunk-DCKFFFPG.js";import{m as I}from"./chunk-7FEY62ID.js";import{a as s}from"./chunk-CXR3NH2D.js";import{d as e,e as d,f as o,g as w,h as f}from"./chunk-NU7VF7MC.js";var l,m,C,p,y,n,b,A,k,L,K,P,u,V,F,q,B,$,N=class{constructor(r){d(this,u);d(this,l,"unknown");d(this,m,!1);d(this,C);d(this,p);d(this,y);d(this,n);d(this,b);d(this,A);d(this,k);d(this,L);d(this,K);d(this,P);o(this,C,r.chain),o(this,p,r.walletAddress),o(this,y,r.options),o(this,n,r.signerManager),o(this,b,r.serverSignerResolver),o(this,A,r.signers),o(this,k,r.addSigner),o(this,L,r.removeSigner),o(this,K,r.approveSignature),o(this,P,r.approveTransaction)}get needsRecovery(){return e(this,l)==="needs-recovery"}onSignerSelected(){e(this,l)==="needs-recovery"&&o(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(S){s.error("wallet.initDeviceSigner.error",{error:S}),o(this,l,"needs-recovery");return}if(e(this,l)==="needs-recovery")return;let a=R(i.type).buildInternalConfig(i,e(this,n).descriptorContext()),t=yield e(this,n).assemble(a);e(this,n).setActiveSigner(t),e(this,n).isApprovedSignerStatus(t.status)||(s.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:t.locator(),status:t.status}),o(this,l,"needs-recovery"))})}recover(){return f(this,null,function*(){var D;if(s.info("wallet.recover.start"),e(this,l)==="resolved"){s.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(e(this,m)){s.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),o(this,l,"resolved");return}let r=e(this,n).activeSigner;if((r==null?void 0:r.type)==="device"&&(yield w(this,u,F).call(this,r))){o(this,l,"resolved");return}if(r!=null&&r.type!=="device"){s.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),o(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 a=yield e(this,A).call(this),t=yield w(this,u,B).call(this,i,a);if(t!=null&&(yield w(this,u,F).call(this,t))){e(this,n).setActiveSigner(t),o(this,l,"resolved");let c=t.locator().replace("device:","");try{yield i.mapAddressToKey(e(this,p),c)}catch(z){s.warn("wallet.recover.mapAddressToKey.error",{error:z})}return}let g=a.filter(c=>c.type==="device"),S=w(this,u,V).call(this,g,i),v=yield j(i,e(this,p));try{yield e(this,k).call(this,v)}catch(c){if(c instanceof I){s.info("wallet.recover.device.unsupportedFallback",{signerLocator:v.locator}),yield i.deleteKey(e(this,p)),o(this,m,!0),o(this,l,"resolved"),yield w(this,u,$).call(this);return}else if(G(c))s.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:v.locator});else throw c instanceof W||c instanceof Error&&c.name==="AuthRejectedError"?(s.info("wallet.recover.device.authRejected",{signerLocator:v.locator}),c):c instanceof E||c instanceof Error&&c.name==="OtpValidationError"?(s.warn("wallet.recover.device.otpValidationFailed",{signerLocator:v.locator,code:c instanceof E?c.code:void 0}),c):(s.error("wallet.recover.device.error",{error:c}),yield i.deleteKey(e(this,p)),c)}let h=yield e(this,n).assemble({type:"device",locator:v.locator,address:e(this,p)});if(e(this,n).setActiveSigner(h),h.type==="device"&&(h.status="success"),s.info("wallet.recover.device.success",{signerLocator:v.locator}),o(this,l,"resolved"),S!=null)try{yield e(this,L).call(this,S),s.info("wallet.recover.staleSignerRemoved",{signerLocator:S})}catch(c){s.warn("wallet.recover.staleSignerRemovalFailed",{signerLocator:S,error:c})}})}resolveAvailability(r){return f(this,null,function*(){var S;let i=(S=e(this,y))==null?void 0:S.deviceSignerKeyStorage;if(i==null)throw new Error("Device signer key storage is required for device signers");let a=yield i.getKey(e(this,p));if(a!=null){r.locator=`device:${a}`,o(this,l,"unknown");return}let g=(yield e(this,A).call(this)).filter(v=>v.locator.startsWith("device:"));for(let v of g){let h=v.locator.replace("device:","");if(yield i.hasKey(h)){yield i.mapAddressToKey(e(this,p),h),r.locator=v.locator,o(this,l,"unknown");return}}o(this,l,"needs-recovery")})}tryResolveLocallyAvailableSigner(t){return f(this,arguments,function*(r,i=(a=>(a=e(this,y))==null?void 0:a.deviceSignerKeyStorage)()){if(i==null)return null;try{return yield M(e(this,C),r,e(this,p),i)}catch(g){return s.warn("wallet.deviceRecovery.tryResolveLocallyAvailableSigner.failed",{signerLocator:r,error:g}),null}})}};l=new WeakMap,m=new WeakMap,C=new WeakMap,p=new WeakMap,y=new WeakMap,n=new WeakMap,b=new WeakMap,A=new WeakMap,k=new WeakMap,L=new WeakMap,K=new WeakMap,P=new WeakMap,u=new WeakSet,V=function(r,i){if(r.length===0)return;if(r.length===1)return r[0].locator;let a=i.getDeviceName(),t=r.filter(g=>g.name===a);return t.length===1?t[0].locator:void 0},F=function(r){return f(this,null,function*(){var a;if(e(this,n).isApprovedSignerStatus(r.status))return s.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let i=yield e(this,n).getSignerState(r.locator());return r.status=(a=i.signer)==null?void 0:a.status,i.pendingOperation!=null?(yield w(this,u,q).call(this,r,i.pendingOperation),!0):e(this,n).isApprovedSignerStatus(r.status)?(s.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})},q=function(r,i){return f(this,null,function*(){var h;let a=e(this,n).activeSigner,t=e(this,n).recovery;if(O(t)&&!e(this,b).hasRecoveryResolution)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),S=e(this,n).descriptorContext();if(t.type==="external-wallet"&&!g.canAutoAssemble(t,S))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,S);e(this,n).setActiveSigner(T(e(this,C),v,(h=e(this,y))==null?void 0:h.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,n).setActiveSigner(r),D}finally{e(this,n).activeSigner!==r&&e(this,n).setActiveSigner(a)}r.status="success",s.info("wallet.recover.device.success",{signerLocator:r.locator(),resumed:!0})})},B=function(r,i){return f(this,null,function*(){let a=i.filter(t=>t.locator.startsWith("device:"));for(let t of a){let g=yield this.tryResolveLocallyAvailableSigner(t.locator,r);if(g!=null)return s.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:t.locator}),g}return null})},$=function(){return f(this,null,function*(){let r=e(this,n).recovery,i=R(r.type),a=e(this,n).descriptorContext();if(i.canAutoAssemble(r,a))try{let t=i.buildInternalConfig(r,a);e(this,n).setActiveSigner(yield e(this,n).assemble(t,{isAdminSigner:!0}))}catch(t){s.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:r.type,error:t})}})};function G(x){if(!(x instanceof Error))return!1;let r=x.message.toLowerCase();return r.includes("delegated signer")&&r.includes("already")&&r.includes("approved")}export{N as a};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-TZGYISF7.js";import{a as E}from"./chunk-5LNDUSMZ.js";import{a as S}from"./chunk-VCOKK7C2.js";import{b as k,c as R}from"./chunk-STRSYJNY.js";import{b as A,c as x}from"./chunk-TSJUK3ED.js";import{f as P}from"./chunk-N7Z3C5RJ.js";import{e as F,g,l as b}from"./chunk-7FEY62ID.js";import{a as p}from"./chunk-4ILFMPNK.js";import{a as f,b as v,c as W,h}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as T}from"@crossmint/common-sdk-base";import{WebAuthnP256 as I}from"ox";var $="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",w=class{constructor(t){this.apiClient=t}getWallet(t,e){return h(this,null,function*(){let r,i;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new g("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new g("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");r=t,i=e}else{if(this.apiClient.isServerSide)throw new g("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");i=t,r=this.getWalletLocator(i)}let n=v(f({},i),{chain:P(i.chain,this.apiClient.environment)});p.info("walletFactory.getWallet.start");let a=yield this.apiClient.getWallet(r);if("error"in a)throw p.warn("walletFactory.getWallet.notFound",{error:a.error}),new F(JSON.stringify(a));return p.info("walletFactory.getWallet.success",{address:a.address}),yield this.createWalletInstance(a,n)})}createWallet(t){return h(this,null,function*(){var o,c,y,u,d,C;let e=v(f({},t),{chain:P(t.chain,this.apiClient.environment)});if(yield(y=(c=(o=e.options)==null?void 0:o.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:y.call(c),p.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw p.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new g("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let r=(u=e.signers)!=null?u:[],i=((d=e.options)==null?void 0:d.deviceSignerKeyStorage)!=null&&!r.some(m=>m.type==="device"),n=i?[...r,{type:"device"}]:r,a=yield this.registerSigners(n,e.chain,(C=e.options)==null?void 0:C.deviceSignerKeyStorage),s;if(e.recovery.type==="passkey"&&e.recovery.id==null)s=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:m}=A(e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);s={type:"server",address:m}}else s=e.recovery;let l=yield this.createSmartWallet(e,s,a,i);if("error"in l)throw p.error("walletFactory.createWallet.error",{error:l.error}),new g(JSON.stringify(l));return p.info("walletFactory.createWallet.success",{address:l.address}),yield this.createWalletInstance(l,e)})}createSmartWallet(t,e,r,i){return h(this,null,function*(){let n=o=>{var c,y;return{type:"smart",chainType:this.getChainType(t.chain),config:f(f({adminSigner:e},t.plugins?{plugins:t.plugins}:{}),o!=null?{delegatedSigners:o}:{}),owner:(c=t.owner)!=null?c:void 0,alias:(y=t.alias)!=null?y:void 0}},a=yield this.apiClient.createWallet(n(r));if(!(i&&"error"in a&&a.code===b))return a;p.info("walletFactory.createWallet.deviceSignerUnsupported.retryWithoutDeviceSigner",{chain:t.chain});let l=r.filter(o=>!this.isBuiltDeviceSigner(o));return yield this.apiClient.createWallet(n(l))})}isBuiltDeviceSigner(t){let e=t.signer;return typeof e=="object"&&e!=null&&e.type==="device"}mergePhoneChannel(t,e){return t.type!=="phone"||(e==null?void 0:e.type)!=="phone"||e.channel==null?t:v(f({},t),{channel:e.channel})}createWalletInstance(t,e){return h(this,null,function*(){var y,u;this.validateExistingWalletConfig(t,e);let r=e,i=t.config.adminSigner,n=((y=r.recovery)==null?void 0:y.type)==="server"||((u=r.recovery)==null?void 0:u.type)==="external-wallet"?r.recovery:this.mergePhoneChannel(i,r.recovery),a=t.config.delegatedSigners,s=a;if(s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet"))s=r.signers;else if(s!=null){let d=r.signers;s=s.map(C=>this.mergePhoneChannel(C,d==null?void 0:d.find(m=>m.type==="phone"&&C.type==="phone"&&S(m)===C.locator)))}let l=i.type==="server"&&"address"in i&&!("secret"in i)?i.address:void 0,o=(a!=null?a:[]).filter(d=>d.type==="server"&&"address"in d&&!("secret"in d)).map(d=>d.address),c=new D({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:n,apiRecoveryServerSignerAddress:l,apiDelegatedServerSignerAddresses:o,signers:s!=null?s:[]},this.apiClient);return yield c.waitForInit(),c})}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return h(this,null,function*(){var i;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(i=t.name)!=null?i:`Crossmint Wallet ${Date.now()}`,r=t.onCreatePasskey?yield t.onCreatePasskey(e):yield I.createCredential({name:e});return{type:"passkey",id:r.id,name:e,publicKey:{x:r.publicKey.x.toString(),y:r.publicKey.y.toString()}}})}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&k(e.owner)!==k(t.owner))throw new g("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&t.chainType!=="solana"||e.chain!=="solana"&&t.chainType==="solana"||e.chain==="stellar"&&t.chainType!=="stellar"||e.chain!=="stellar"&&t.chainType==="stellar")throw new g(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let r=e;if(r.recovery!=null||r.signers!=null){let i=t.config,n=i==null?void 0:i.adminSigner;if(r.recovery!=null&&n!=null){if(r.recovery.type!==n.type)throw new g("The wallet recovery signer type does not match the existing wallet's recovery signer type");R(r.recovery,n)}let a=r.signers;a!=null&&this.validateSigners(t,a,e.chain)}}validateSigners(t,e,r){let i=t.config,n=i==null?void 0:i.delegatedSigners;if(e.length!==0){if(n==null||n.length===0)throw new g(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${$}`);for(let a of e){let s=n.find(l=>{if(this.isMatchingPasskeySigner(a,l,i)||l.type==="device"&&a.type==="device")return!0;if(a.type==="server"){let{primary:o,legacy:c}=x(a,r,this.apiClient.projectId,this.apiClient.environment);return l.locator===`server:${o.derivedAddress}`||c!=null&&l.locator===`server:${c.derivedAddress}`}return l.locator===S(a)});if(s==null){let l=n.map(o=>o.locator).join(", ");throw new g(`Signer '${a.type}' does not exist in wallet "${t.address}". Available signers: ${l}. ${$}`)}R(a,s)}}}isMatchingPasskeySigner(t,e,r){var n,a;let i=((a=(n=r.delegatedSigners)==null?void 0:n.filter(s=>s.type==="passkey").length)!=null?a:0)+(r.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&i===1)return e.type==="passkey";if(t.id==null&&i>1)throw new g("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,r){return h(this,null,function*(){var i;return yield Promise.all((i=t==null?void 0:t.map(n=>h(this,null,function*(){if(n.type==="passkey")return n.id==null?{signer:yield this.createPasskeySigner(n)}:{signer:n};if(n.type==="device"){if(n.publicKey!=null)return{signer:{type:"device",publicKey:n.publicKey,name:n.name}};if(n.locator!=null)return{signer:n.locator};if(r==null)throw new g("Device signer key storage is required for device signers");let a=yield E(r);return{signer:{type:"device",publicKey:a.publicKey,name:a.name}}}if(n.type==="server"&&e!=null){let{derivedAddress:a}=A(n,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${a}`}}return{signer:S(n)}})))!=null?i:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};W([T({logger:p,methodName:"walletFactory.getWallet",buildContext(t,e){if(typeof e[0]=="string"){let i=e[1];return{walletLocator:e[0],chain:i==null?void 0:i.chain}}let r=e[0];return{chain:r==null?void 0:r.chain}}})],w.prototype,"getWallet",1),W([T({logger:p,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],w.prototype,"createWallet",1);export{w as a};
1
+ import{a as D}from"./chunk-5W37U67F.js";import{a as E}from"./chunk-5LNDUSMZ.js";import{a as S}from"./chunk-VCOKK7C2.js";import{b as k,c as R}from"./chunk-STRSYJNY.js";import{b as A,c as x}from"./chunk-TSJUK3ED.js";import{f as P}from"./chunk-4NQ7C2F3.js";import{e as F,g,l as b}from"./chunk-7FEY62ID.js";import{a as p}from"./chunk-CXR3NH2D.js";import{a as f,b as v,c as W,h}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as T}from"@crossmint/common-sdk-base";import{WebAuthnP256 as I}from"ox";var $="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",w=class{constructor(t){this.apiClient=t}getWallet(t,e){return h(this,null,function*(){let r,i;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new g("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new g("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");r=t,i=e}else{if(this.apiClient.isServerSide)throw new g("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");i=t,r=this.getWalletLocator(i)}let n=v(f({},i),{chain:P(i.chain,this.apiClient.environment)});p.info("walletFactory.getWallet.start");let a=yield this.apiClient.getWallet(r);if("error"in a)throw p.warn("walletFactory.getWallet.notFound",{error:a.error}),new F(JSON.stringify(a));return p.info("walletFactory.getWallet.success",{address:a.address}),yield this.createWalletInstance(a,n)})}createWallet(t){return h(this,null,function*(){var o,c,y,u,d,C;let e=v(f({},t),{chain:P(t.chain,this.apiClient.environment)});if(yield(y=(c=(o=e.options)==null?void 0:o.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:y.call(c),p.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw p.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new g("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let r=(u=e.signers)!=null?u:[],i=((d=e.options)==null?void 0:d.deviceSignerKeyStorage)!=null&&!r.some(m=>m.type==="device"),n=i?[...r,{type:"device"}]:r,a=yield this.registerSigners(n,e.chain,(C=e.options)==null?void 0:C.deviceSignerKeyStorage),s;if(e.recovery.type==="passkey"&&e.recovery.id==null)s=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:m}=A(e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);s={type:"server",address:m}}else s=e.recovery;let l=yield this.createSmartWallet(e,s,a,i);if("error"in l)throw p.error("walletFactory.createWallet.error",{error:l.error}),new g(JSON.stringify(l));return p.info("walletFactory.createWallet.success",{address:l.address}),yield this.createWalletInstance(l,e)})}createSmartWallet(t,e,r,i){return h(this,null,function*(){let n=o=>{var c,y;return{type:"smart",chainType:this.getChainType(t.chain),config:f(f({adminSigner:e},t.plugins?{plugins:t.plugins}:{}),o!=null?{delegatedSigners:o}:{}),owner:(c=t.owner)!=null?c:void 0,alias:(y=t.alias)!=null?y:void 0}},a=yield this.apiClient.createWallet(n(r));if(!(i&&"error"in a&&a.code===b))return a;p.info("walletFactory.createWallet.deviceSignerUnsupported.retryWithoutDeviceSigner",{chain:t.chain});let l=r.filter(o=>!this.isBuiltDeviceSigner(o));return yield this.apiClient.createWallet(n(l))})}isBuiltDeviceSigner(t){let e=t.signer;return typeof e=="object"&&e!=null&&e.type==="device"}mergePhoneChannel(t,e){return t.type!=="phone"||(e==null?void 0:e.type)!=="phone"||e.channel==null?t:v(f({},t),{channel:e.channel})}createWalletInstance(t,e){return h(this,null,function*(){var y,u;this.validateExistingWalletConfig(t,e);let r=e,i=t.config.adminSigner,n=((y=r.recovery)==null?void 0:y.type)==="server"||((u=r.recovery)==null?void 0:u.type)==="external-wallet"?r.recovery:this.mergePhoneChannel(i,r.recovery),a=t.config.delegatedSigners,s=a;if(s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet"))s=r.signers;else if(s!=null){let d=r.signers;s=s.map(C=>this.mergePhoneChannel(C,d==null?void 0:d.find(m=>m.type==="phone"&&C.type==="phone"&&S(m)===C.locator)))}let l=i.type==="server"&&"address"in i&&!("secret"in i)?i.address:void 0,o=(a!=null?a:[]).filter(d=>d.type==="server"&&"address"in d&&!("secret"in d)).map(d=>d.address),c=new D({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:n,apiRecoveryServerSignerAddress:l,apiDelegatedServerSignerAddresses:o,signers:s!=null?s:[]},this.apiClient);return yield c.waitForInit(),c})}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return h(this,null,function*(){var i;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(i=t.name)!=null?i:`Crossmint Wallet ${Date.now()}`,r=t.onCreatePasskey?yield t.onCreatePasskey(e):yield I.createCredential({name:e});return{type:"passkey",id:r.id,name:e,publicKey:{x:r.publicKey.x.toString(),y:r.publicKey.y.toString()}}})}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&k(e.owner)!==k(t.owner))throw new g("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&t.chainType!=="solana"||e.chain!=="solana"&&t.chainType==="solana"||e.chain==="stellar"&&t.chainType!=="stellar"||e.chain!=="stellar"&&t.chainType==="stellar")throw new g(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let r=e;if(r.recovery!=null||r.signers!=null){let i=t.config,n=i==null?void 0:i.adminSigner;if(r.recovery!=null&&n!=null){if(r.recovery.type!==n.type)throw new g("The wallet recovery signer type does not match the existing wallet's recovery signer type");R(r.recovery,n)}let a=r.signers;a!=null&&this.validateSigners(t,a,e.chain)}}validateSigners(t,e,r){let i=t.config,n=i==null?void 0:i.delegatedSigners;if(e.length!==0){if(n==null||n.length===0)throw new g(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${$}`);for(let a of e){let s=n.find(l=>{if(this.isMatchingPasskeySigner(a,l,i)||l.type==="device"&&a.type==="device")return!0;if(a.type==="server"){let{primary:o,legacy:c}=x(a,r,this.apiClient.projectId,this.apiClient.environment);return l.locator===`server:${o.derivedAddress}`||c!=null&&l.locator===`server:${c.derivedAddress}`}return l.locator===S(a)});if(s==null){let l=n.map(o=>o.locator).join(", ");throw new g(`Signer '${a.type}' does not exist in wallet "${t.address}". Available signers: ${l}. ${$}`)}R(a,s)}}}isMatchingPasskeySigner(t,e,r){var n,a;let i=((a=(n=r.delegatedSigners)==null?void 0:n.filter(s=>s.type==="passkey").length)!=null?a:0)+(r.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&i===1)return e.type==="passkey";if(t.id==null&&i>1)throw new g("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,r){return h(this,null,function*(){var i;return yield Promise.all((i=t==null?void 0:t.map(n=>h(this,null,function*(){if(n.type==="passkey")return n.id==null?{signer:yield this.createPasskeySigner(n)}:{signer:n};if(n.type==="device"){if(n.publicKey!=null)return{signer:{type:"device",publicKey:n.publicKey,name:n.name}};if(n.locator!=null)return{signer:n.locator};if(r==null)throw new g("Device signer key storage is required for device signers");let a=yield E(r);return{signer:{type:"device",publicKey:a.publicKey,name:a.name}}}if(n.type==="server"&&e!=null){let{derivedAddress:a}=A(n,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${a}`}}return{signer:S(n)}})))!=null?i:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};W([T({logger:p,methodName:"walletFactory.getWallet",buildContext(t,e){if(typeof e[0]=="string"){let i=e[1];return{walletLocator:e[0],chain:i==null?void 0:i.chain}}let r=e[0];return{chain:r==null?void 0:r.chain}}})],w.prototype,"getWallet",1),W([T({logger:p,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],w.prototype,"createWallet",1);export{w as a};
@@ -0,0 +1 @@
1
+ import{a as g,b as c}from"./chunk-ST63L4FD.js";import{a as s}from"./chunk-CXR3NH2D.js";import{h as t}from"./chunk-NU7VF7MC.js";import{VersionedTransaction as u}from"@solana/web3.js";import o from"bs58";var d=class y extends g{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){return yield this.sign(o.decode(e))})}signTransaction(e){return t(this,null,function*(){let i=o.decode(e),r=u.deserialize(i);return yield this.sign(r.message.serialize())})}sign(e){return t(this,null,function*(){var a;yield this.handleAuthRequired();let i=this.getJwtOrThrow();s.info("sign: sending request",{keyType:"ed25519"});let r=Date.now(),n=yield(a=this.config.clientTEEConnection)==null?void 0:a.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:o.encode(new Uint8Array(e)),encoding:"base58"}},options:c});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-r}),(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 y.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"}}};export{d as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ2C3XP4Zcjs = require('./chunk-J2C3XP4Z.cjs');var _chunkOHTCLNE3cjs = require('./chunk-OHTCLNE3.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkJ2C3XP4Zcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkJ2C3XP4Zcjs.a.getOptions(e),alias:e.alias,recovery:_chunkJ2C3XP4Zcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkJ2C3XP4Zcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkJ2C3XP4Zcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkJ2C3XP4Zcjs.a.getInitialSigners(e)},_chunkJ2C3XP4Zcjs.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;_chunkPSK7FYV7cjs.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 _chunkPSK7FYV7cjs.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 _chunkPSK7FYV7cjs.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;_chunkPSK7FYV7cjs.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 _chunkPSK7FYV7cjs.a.error("evmWallet.signMessage.error",{error:r}),new (0, _chunkXZ4NKVEBcjs.u)(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return _chunkPSK7FYV7cjs.a.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return _chunkPSK7FYV7cjs.a.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var C;_chunkPSK7FYV7cjs.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 _chunkPSK7FYV7cjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkXZ4NKVEBcjs.q)("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw _chunkPSK7FYV7cjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkXZ4NKVEBcjs.q)("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 _chunkPSK7FYV7cjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunkXZ4NKVEBcjs.u)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkPSK7FYV7cjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return _chunkPSK7FYV7cjs.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:_chunkOHTCLNE3cjs.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, _chunkXZ4NKVEBcjs.z)(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:_chunkPSK7FYV7cjs.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:_chunkPSK7FYV7cjs.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:_chunkPSK7FYV7cjs.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 _chunk7GJLRYUQcjs = require('./chunk-7GJLRYUQ.cjs');var _chunkUGGVGFV2cjs = require('./chunk-UGGVGFV2.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunk7GJLRYUQcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk7GJLRYUQcjs.a.getOptions(e),alias:e.alias,recovery:_chunk7GJLRYUQcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunk7GJLRYUQcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunk7GJLRYUQcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk7GJLRYUQcjs.a.getInitialSigners(e)},_chunk7GJLRYUQcjs.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;_chunk5NHL2AW6cjs.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 _chunk5NHL2AW6cjs.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 _chunk5NHL2AW6cjs.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;_chunk5NHL2AW6cjs.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 _chunk5NHL2AW6cjs.a.error("evmWallet.signMessage.error",{error:r}),new (0, _chunkXZ4NKVEBcjs.u)(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return _chunk5NHL2AW6cjs.a.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return _chunk5NHL2AW6cjs.a.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var C;_chunk5NHL2AW6cjs.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 _chunk5NHL2AW6cjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkXZ4NKVEBcjs.q)("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw _chunk5NHL2AW6cjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkXZ4NKVEBcjs.q)("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 _chunk5NHL2AW6cjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunkXZ4NKVEBcjs.u)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunk5NHL2AW6cjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return _chunk5NHL2AW6cjs.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:_chunkUGGVGFV2cjs.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, _chunkXZ4NKVEBcjs.z)(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:_chunk5NHL2AW6cjs.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:_chunk5NHL2AW6cjs.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:_chunk5NHL2AW6cjs.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 o}from"./chunk-TZGYISF7.js";import{a as W}from"./chunk-N7Z3C5RJ.js";import{q as l,u as f,z as w}from"./chunk-7FEY62ID.js";import{a as n}from"./chunk-4ILFMPNK.js";import{c as u,h as p}from"./chunk-NU7VF7MC.js";import{createPublicClient as O,encodeFunctionData as x,http as E}from"viem";import{isValidEvmAddress as A,WithLoggerContext as h}from"@crossmint/common-sdk-base";var c=class c extends o{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:o.getOptions(e),alias:e.alias,recovery:o.getRecovery(e),apiRecoveryServerSignerAddress:o.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:o.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:o.getInitialSigners(e)},o.getApiClient(e))}static from(e){if(!A(e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return p(this,null,function*(){var i;n.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 n.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return n.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return p(this,null,function*(){var i;n.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 n.error("evmWallet.signMessage.error",{error:r}),new f(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return n.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return n.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return p(this,null,function*(){var C;n.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 n.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new l("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw n.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new l("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 n.error("evmWallet.signTypedData.error",{error:d}),new f(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return n.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return n.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return O({transport:(t=e==null?void 0:e.transport)!=null?t:E(),chain:W(this.chain)})}createTransaction(e,t){return p(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 w(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:x({abi:e.abi,functionName:e.functionName,args:e.args})}}};u([h({logger:n,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),u([h({logger:n,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),u([h({logger:n,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}export{M as a};
1
+ import{a as o}from"./chunk-5W37U67F.js";import{a as W}from"./chunk-4NQ7C2F3.js";import{q as l,u as f,z as w}from"./chunk-7FEY62ID.js";import{a as n}from"./chunk-CXR3NH2D.js";import{c as u,h as p}from"./chunk-NU7VF7MC.js";import{createPublicClient as O,encodeFunctionData as x,http as E}from"viem";import{isValidEvmAddress as A,WithLoggerContext as h}from"@crossmint/common-sdk-base";var c=class c extends o{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:o.getOptions(e),alias:e.alias,recovery:o.getRecovery(e),apiRecoveryServerSignerAddress:o.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:o.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:o.getInitialSigners(e)},o.getApiClient(e))}static from(e){if(!A(e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return p(this,null,function*(){var i;n.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 n.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return n.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return p(this,null,function*(){var i;n.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 n.error("evmWallet.signMessage.error",{error:r}),new f(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return n.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return n.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return p(this,null,function*(){var C;n.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 n.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new l("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw n.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new l("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 n.error("evmWallet.signTypedData.error",{error:d}),new f(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return n.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return n.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return O({transport:(t=e==null?void 0:e.transport)!=null?t:E(),chain:W(this.chain)})}createTransaction(e,t){return p(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 w(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:x({abi:e.abi,functionName:e.functionName,args:e.args})}}};u([h({logger:n,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),u([h({logger:n,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),u([h({logger:n,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}export{M as a};
@@ -1 +1 @@
1
- import{a}from"./chunk-M3IEG5GA.js";import{a as r}from"./chunk-QVE2LOBH.js";import{a as t}from"./chunk-SZXFHFA5.js";import{a as n}from"./chunk-OQZTL6ZG.js";var i={evm:a,solana:r,stellar:t};function g(e){return i[n(e)]}function m(e){return Object.prototype.hasOwnProperty.call(i,e)}export{g as a,m as b};
1
+ import{a}from"./chunk-2Q4WYCJK.js";import{a as r}from"./chunk-36ZZPH5C.js";import{a as t}from"./chunk-5RXSFMFU.js";import{a as n}from"./chunk-OQZTL6ZG.js";var i={evm:a,solana:r,stellar:t};function g(e){return i[n(e)]}function m(e){return Object.prototype.hasOwnProperty.call(i,e)}export{g as a,m as b};
@@ -0,0 +1 @@
1
+ var s="@crossmint/wallets-sdk",t="1.13.0";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 _chunk5VUIA6TBcjs = require('./chunk-5VUIA6TB.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=_chunk5VUIA6TBcjs.a.call(void 0, n).balanceTokenFields(t);return _chunkDSIFRRBScjs.a.call(void 0, {symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=_chunk5VUIA6TBcjs.a.call(void 0, n).emptyBalanceTokenFields();return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=_chunkENU3EKBGcjs.a.call(void 0, t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function T(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}exports.a = T;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT5OX7TEHcjs = require('./chunk-T5OX7TEH.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=_chunkT5OX7TEHcjs.a.call(void 0, n).balanceTokenFields(t);return _chunkDSIFRRBScjs.a.call(void 0, {symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=_chunkT5OX7TEHcjs.a.call(void 0, n).emptyBalanceTokenFields();return _chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=_chunkENU3EKBGcjs.a.call(void 0, t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function T(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}exports.a = T;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkKULR5B4Ocjs = require('./chunk-KULR5B4O.cjs');var _chunkLKEPKOKUcjs = require('./chunk-LKEPKOKU.cjs');var _chunkL5X5RA7Ecjs = require('./chunk-L5X5RA7E.cjs');var _chunkGIYB3U37cjs = require('./chunk-GIYB3U37.cjs');var _chunkFQZXBS7Lcjs = require('./chunk-FQZXBS7L.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 _chunkLMHH6ODXcjs = require('./chunk-LMHH6ODX.cjs');var _chunkCDHMNLZ6cjs = require('./chunk-CDHMNLZ6.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function c(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new (0, _chunkL5X5RA7Ecjs.a)(e):r==="stellar"?new (0, _chunkGIYB3U37cjs.a)(e):new (0, _chunkLKEPKOKUcjs.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, _chunkFQZXBS7Lcjs.a)(e):r==="stellar"?new (0, _chunk5FVDLMWWcjs.a)(e):new (0, _chunkHYWIWJ6Hcjs.a)(e);case"server":return _chunkKULR5B4Ocjs.a.call(void 0, r,e);case"passkey":return new (0, _chunkLMHH6ODXcjs.a)(e);case"device":if(n==null)throw new (0, _chunkXZ4NKVEBcjs.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 _chunkKULR5B4Ocjs = require('./chunk-KULR5B4O.cjs');var _chunkR2GZ5L4Qcjs = require('./chunk-R2GZ5L4Q.cjs');var _chunkVYX2NH35cjs = require('./chunk-VYX2NH35.cjs');var _chunk52DSGFRGcjs = require('./chunk-52DSGFRG.cjs');var _chunkFQZXBS7Lcjs = require('./chunk-FQZXBS7L.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 _chunkX24IHG7Pcjs = require('./chunk-X24IHG7P.cjs');var _chunkCDHMNLZ6cjs = require('./chunk-CDHMNLZ6.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function c(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new (0, _chunkVYX2NH35cjs.a)(e):r==="stellar"?new (0, _chunk52DSGFRGcjs.a)(e):new (0, _chunkR2GZ5L4Qcjs.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, _chunkFQZXBS7Lcjs.a)(e):r==="stellar"?new (0, _chunk5FVDLMWWcjs.a)(e):new (0, _chunkHYWIWJ6Hcjs.a)(e);case"server":return _chunkKULR5B4Ocjs.a.call(void 0, r,e);case"passkey":return new (0, _chunkX24IHG7Pcjs.a)(e);case"device":if(n==null)throw new (0, _chunkXZ4NKVEBcjs.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 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.12.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.13.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 +1 @@
1
- import{a as r}from"./chunk-TZGYISF7.js";import{a as h}from"./chunk-3QKB6K3J.js";import{z as S}from"./chunk-7FEY62ID.js";import{a as t}from"./chunk-4ILFMPNK.js";import{c as u,h as c}from"./chunk-NU7VF7MC.js";import T from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as m}from"@crossmint/common-sdk-base";var o=class o extends r{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:r.getOptions(e),alias:e.alias,recovery:r.getRecovery(e),apiRecoveryServerSignerAddress:r.getApiRecoveryServerSignerAddress(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 o(e)}sendTransaction(e){return c(this,null,function*(){var l,p;t.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((l=e.options)!=null&&l.prepareOnly)return t.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(p=e.additionalSigners)==null?void 0:p.map(d=>new h({type:"external-wallet",address:d.publicKey.toString(),locator:`external-wallet:${d.publicKey.toString()}`,onSign:g=>(g.sign([d]),Promise.resolve(g))}))},a=yield this.approveTransactionAndWait(n.id,i);return t.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return c(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=T.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new S(JSON.stringify(i));return i})}};u([m({logger:t,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;export{f as a};
1
+ import{a as r}from"./chunk-5W37U67F.js";import{a as h}from"./chunk-3QKB6K3J.js";import{z as S}from"./chunk-7FEY62ID.js";import{a as t}from"./chunk-CXR3NH2D.js";import{c as u,h as c}from"./chunk-NU7VF7MC.js";import T from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as m}from"@crossmint/common-sdk-base";var o=class o extends r{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:r.getOptions(e),alias:e.alias,recovery:r.getRecovery(e),apiRecoveryServerSignerAddress:r.getApiRecoveryServerSignerAddress(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 o(e)}sendTransaction(e){return c(this,null,function*(){var l,p;t.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((l=e.options)!=null&&l.prepareOnly)return t.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(p=e.additionalSigners)==null?void 0:p.map(d=>new h({type:"external-wallet",address:d.publicKey.toString(),locator:`external-wallet:${d.publicKey.toString()}`,onSign:g=>(g.sign([d]),Promise.resolve(g))}))},a=yield this.approveTransactionAndWait(n.id,i);return t.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return c(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=T.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new S(JSON.stringify(i));return i})}};u([m({logger:t,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;export{f as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var o={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,r,a){if(!("transaction"in n)||n.transaction==null)throw _chunkPSK7FYV7cjs.a.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}}};exports.a = o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.cjs');var o={nativeToken:"sol",walletLocatorPrefix:"me:solana:smart",supportsSignatures:!1,addSignerChain(n){},extractAddSignerOperation(n,r,a){if(!("transaction"in n)||n.transaction==null)throw _chunk5NHL2AW6cjs.a.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}}};exports.a = o;
@@ -1 +1 @@
1
- import{A as C,B as x,C as A,D as y,E as k,I as w,s as M,v as m,x as b}from"./chunk-7FEY62ID.js";import{a as E}from"./chunk-4ILFMPNK.js";import{d as S}from"./chunk-SCEZVF7J.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{A as C,B as x,C as A,D as y,E as k,I as w,s as M,v as m,x as b}from"./chunk-7FEY62ID.js";import{a as E}from"./chunk-CXR3NH2D.js";import{d as S}from"./chunk-JCNQFYND.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 _chunkJ2C3XP4Zcjs = require('./chunk-J2C3XP4Z.cjs');var _chunkFQZXBS7Lcjs = require('./chunk-FQZXBS7L.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunkJ2C3XP4Zcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkJ2C3XP4Zcjs.a.getOptions(e),alias:e.alias,recovery:_chunkJ2C3XP4Zcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkJ2C3XP4Zcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkJ2C3XP4Zcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkJ2C3XP4Zcjs.a.getInitialSigners(e)},_chunkJ2C3XP4Zcjs.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 o(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var l,p;_chunkPSK7FYV7cjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((l=e.options)!=null&&l.prepareOnly)return _chunkPSK7FYV7cjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(p=e.additionalSigners)==null?void 0:p.map(d=>new (0, _chunkFQZXBS7Lcjs.a)({type:"external-wallet",address:d.publicKey.toString(),locator:`external-wallet:${d.publicKey.toString()}`,onSign:g=>(g.sign([d]),Promise.resolve(g))}))},a=yield this.approveTransactionAndWait(n.id,i);return _chunkPSK7FYV7cjs.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, _chunkXZ4NKVEBcjs.z)(JSON.stringify(i));return i})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;exports.a = f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk7GJLRYUQcjs = require('./chunk-7GJLRYUQ.cjs');var _chunkFQZXBS7Lcjs = require('./chunk-FQZXBS7L.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunk7GJLRYUQcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk7GJLRYUQcjs.a.getOptions(e),alias:e.alias,recovery:_chunk7GJLRYUQcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunk7GJLRYUQcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunk7GJLRYUQcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk7GJLRYUQcjs.a.getInitialSigners(e)},_chunk7GJLRYUQcjs.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 o(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var l,p;_chunk5NHL2AW6cjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((l=e.options)!=null&&l.prepareOnly)return _chunk5NHL2AW6cjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(p=e.additionalSigners)==null?void 0:p.map(d=>new (0, _chunkFQZXBS7Lcjs.a)({type:"external-wallet",address:d.publicKey.toString(),locator:`external-wallet:${d.publicKey.toString()}`,onSign:g=>(g.sign([d]),Promise.resolve(g))}))},a=yield this.approveTransactionAndWait(n.id,i);return _chunk5NHL2AW6cjs.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, _chunkXZ4NKVEBcjs.z)(JSON.stringify(i));return i})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk5NHL2AW6cjs.a,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;exports.a = f;
@@ -0,0 +1 @@
1
+ import{a as o}from"./chunk-7FEY62ID.js";import{a as i}from"./chunk-CXR3NH2D.js";import{b as c,c as l}from"./chunk-JCNQFYND.js";import{h as n}from"./chunk-NU7VF7MC.js";import{APIKeyEnvironmentPrefix as d,APIKeyUsageOrigin as g,ApiClientError as u,CrossmintApiClient as P}from"@crossmint/common-sdk-base";var h=class extends P{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:l,version:c}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return n(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;i.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?i.error("wallets.api.createWallet.error",{error:t.error,chainType:e.chainType}):"address"in t&&i.info("wallets.api.createWallet.success",{address:t.address,chainType:e.chainType}),t})}getWallet(e){return n(this,null,function*(){i.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?i.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&i.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return n(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return n(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 n(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return n(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return n(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 n(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return n(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return n(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 n(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 n(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 n(this,null,function*(){if(this.environment===d.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 n(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return n(this,null,function*(){let t=encodeURIComponent(s),a=new URLSearchParams;r.chain&&a.append("chain",r.chain);let p=`${this.apiPrefix}/${e}/signers/${t}${a.size>0?`?${a.toString()}`:""}`;return(yield this.delete(p,{headers:this.headers})).json()})}getSigner(e,s){return n(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(p){}throw new u(`API request failed: ${t.status} ${t.statusText}`,t.status,t.statusText,a)}return t.json()})}send(e,s,r){return n(this,null,function*(){i.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?i.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:a.error}):"id"in a&&i.info("wallets.api.send.success",{walletLocator:e,transactionId:a.id}),a})}get isServerSide(){return this.parsedAPIKey.usageOrigin===g.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};export{h as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkS3PBSOOZcjs = require('./chunk-S3PBSOOZ.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkS3PBSOOZcjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkPSK7FYV7cjs.a.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:_chunkS3PBSOOZcjs.b});if(_chunkPSK7FYV7cjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};exports.a = c;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkDHY24KCScjs = require('./chunk-DHY24KCS.cjs');var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkDHY24KCScjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunk5NHL2AW6cjs.a.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:_chunkDHY24KCScjs.b});if(_chunk5NHL2AW6cjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};exports.a = c;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ2C3XP4Zcjs = require('./chunk-J2C3XP4Z.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=409,l=class l extends _chunkJ2C3XP4Zcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkJ2C3XP4Zcjs.a.getOptions(e),alias:e.alias,recovery:_chunkJ2C3XP4Zcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkJ2C3XP4Zcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkJ2C3XP4Zcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkJ2C3XP4Zcjs.a.getInitialSigners(e)},_chunkJ2C3XP4Zcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidStellarAddress.call(void 0, e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;_chunkPSK7FYV7cjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunkPSK7FYV7cjs.a.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return _chunkPSK7FYV7cjs.a.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return _chunkPSK7FYV7cjs.a.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),_chunkPSK7FYV7cjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else _chunkPSK7FYV7cjs.a.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return _chunkPSK7FYV7cjs.a.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkPSK7FYV7cjs.a.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new (0, _chunkXZ4NKVEBcjs.z)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunkPSK7FYV7cjs.a.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return _chunkPSK7FYV7cjs.a.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new (0, _chunkXZ4NKVEBcjs.z)(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:_chunkDSIFRRBScjs.a.call(void 0, {transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new (0, _chunkXZ4NKVEBcjs.z)(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk7GJLRYUQcjs = require('./chunk-7GJLRYUQ.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=409,l=class l extends _chunk7GJLRYUQcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk7GJLRYUQcjs.a.getOptions(e),alias:e.alias,recovery:_chunk7GJLRYUQcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunk7GJLRYUQcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunk7GJLRYUQcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk7GJLRYUQcjs.a.getInitialSigners(e)},_chunk7GJLRYUQcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidStellarAddress.call(void 0, e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;_chunk5NHL2AW6cjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunk5NHL2AW6cjs.a.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return _chunk5NHL2AW6cjs.a.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunk5NHL2AW6cjs.a.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return _chunk5NHL2AW6cjs.a.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),_chunk5NHL2AW6cjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else _chunk5NHL2AW6cjs.a.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return _chunk5NHL2AW6cjs.a.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunk5NHL2AW6cjs.a.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new (0, _chunkXZ4NKVEBcjs.z)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunk5NHL2AW6cjs.a.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return _chunk5NHL2AW6cjs.a.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new (0, _chunkXZ4NKVEBcjs.z)(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:_chunkDSIFRRBScjs.a.call(void 0, {transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new (0, _chunkXZ4NKVEBcjs.z)(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.signerManager.require().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk5NHL2AW6cjs.a,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk5NHL2AW6cjs.a,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk5NHL2AW6cjs.a,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}exports.a = h;
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-26DL7XRG.js";import{a as r}from"./chunk-4ILFMPNK.js";import{h as t}from"./chunk-NU7VF7MC.js";var a=class g extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();r.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};export{a};
1
+ import{a as s,b as o}from"./chunk-ST63L4FD.js";import{a as r}from"./chunk-CXR3NH2D.js";import{h as t}from"./chunk-NU7VF7MC.js";var a=class g extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();r.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};export{a};
@@ -1 +1 @@
1
- import{a,b as g}from"./chunk-26DL7XRG.js";import{a as s}from"./chunk-4ILFMPNK.js";import{h as t}from"./chunk-NU7VF7MC.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
1
+ import{a,b as g}from"./chunk-ST63L4FD.js";import{a as s}from"./chunk-CXR3NH2D.js";import{h as t}from"./chunk-NU7VF7MC.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
@@ -1 +1 @@
1
- import{a as m}from"./chunk-YRX44YXB.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=m(n).balanceTokenFields(t);return u({symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=m(n).emptyBalanceTokenFields();return u(u({},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=C(t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function g(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}export{g as a};
1
+ import{a as m}from"./chunk-HO7VI37F.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=m(n).balanceTokenFields(t);return u({symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=m(n).emptyBalanceTokenFields();return u(u({},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=C(t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function g(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}export{g as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGSNFNRH2cjs = require('./chunk-GSNFNRH2.cjs');var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.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, _chunkXZ4NKVEBcjs.o)("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){_chunkPSK7FYV7cjs.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:_chunkPSK7FYV7cjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkPSK7FYV7cjs.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 _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.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, _chunkXZ4NKVEBcjs.o)("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){_chunk5NHL2AW6cjs.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:_chunk5NHL2AW6cjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk5NHL2AW6cjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk5NHL2AW6cjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk5NHL2AW6cjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk5NHL2AW6cjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk5NHL2AW6cjs.a,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);exports.a = c;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunkPSK7FYV7cjs = require('./chunk-PSK7FYV7.cjs');var f={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw _chunkPSK7FYV7cjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw _chunkPSK7FYV7cjs.a.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new (0, _chunkXZ4NKVEBcjs.j)(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return _chunkJNKTRQPScjs.c.call(void 0, e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};exports.a = f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJNKTRQPScjs = require('./chunk-JNKTRQPS.cjs');var _chunkXZ4NKVEBcjs = require('./chunk-XZ4NKVEB.cjs');var _chunk5NHL2AW6cjs = require('./chunk-5NHL2AW6.cjs');var f={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw _chunk5NHL2AW6cjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw _chunk5NHL2AW6cjs.a.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new (0, _chunkXZ4NKVEBcjs.j)(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return _chunkJNKTRQPScjs.c.call(void 0, e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};exports.a = f;
@@ -1 +1 @@
1
- import{a as f}from"./chunk-IHMMTMFG.js";import{a as u,b as g,c as v,d as y,e as P}from"./chunk-DCKFFFPG.js";import{a as o}from"./chunk-4ILFMPNK.js";import{a as E,c as w,h}from"./chunk-NU7VF7MC.js";import{validateAPIKey as A,WithLoggerContext as T}from"@crossmint/common-sdk-base";var m=class{constructor(n){this.config=n;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return h(this,null,function*(){try{if(this.config.clientTEEConnection==null){let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return h(this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return h(this,null,function*(){o.info("TEE connection not initialized, initializing now");let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");o.info("TEE connection initialized successfully")})}handleAuthRequired(){return h(this,null,function*(){var d;let n=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);o.info("get-status: sending request");let t=Date.now(),e=yield n.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),s=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw o.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:s}),new v(c,p)}if(o.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:s}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:i,resolve:a,reject:r}=this.createAuthPromise();if(this._authPromise={promise:i,resolve:a,reject:r},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>h(this,null,function*(){o.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new u)})),r(new u)}))}catch(c){o.error("handleAuthRequired error",{error:c}),r(c)}try{yield i}catch(c){throw o.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return h(this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let n=this.config.crossmint.jwt;if(n==null)throw new Error("JWT is required");return n}createAuthPromise(){let n,t;return{promise:new Promise((s,i)=>{n=s,t=i}),resolve:n,reject:t}}sendMessageWithOtp(){return h(this,null,function*(){var r;let n=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let e=Date.now(),s=this.config.type==="phone"?this.config.channel:void 0,i=yield n.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(r=this.config.crossmint.jwt)!=null?r:"",apiKey:this.config.crossmint.apiKey},data:E({authId:t},s!=null?{channel:s}:{})},options:l}),a=Date.now()-e;if(this._onboardingConnectionGeneration=n.connectionGeneration,o.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:a}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error")throw o.error("start-onboarding: failed",{error:i.error,code:i.code}),new g(i.error||"Failed to initiate OTP process.",i.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(n){return h(this,null,function*(){var i,a;let t;try{let r=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let d=Date.now();t=yield r.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(i=this.config.crossmint.jwt)!=null?i:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:n}}},options:l}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(r){return o.error("complete-onboarding: error",{error:r}),yield this.handleOnboardingVerificationFailure(r)}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),r=>this.verifyOtp(r),()=>{var r;return(r=this._authPromise)==null?void 0:r.reject(new u)})),(a=this._authPromise)==null||a.resolve();return}o.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",s=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new g(e,s))})}handleOnboardingVerificationFailure(n){return h(this,null,function*(){var s,i,a;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){o.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(r){throw(s=this._authPromise)==null||s.reject(r),r}if(!this._needsAuth){(i=this._authPromise)==null||i.resolve();return}throw new P}throw(a=this._authPromise)==null||a.reject(n),n})}_exportPrivateKey(n,t){return h(this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:s,encoding:i}=this.getChainKeyParams();if(t!=null){let r=n.on("event:key-exported",d=>{n.off(r),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let a=yield n.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:s,encoding:i,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((a==null?void 0:a.status)==="error")throw o.error("export-signer: failed",{error:a.error,code:a.code}),new y(a.error||"Failed to export private key",a.code)})}};w([T({logger:o,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};export{m as a,l as b};
1
+ import{a as f}from"./chunk-IHMMTMFG.js";import{a as u,b as g,c as v,d as y,e as P}from"./chunk-DCKFFFPG.js";import{a as o}from"./chunk-CXR3NH2D.js";import{a as E,c as w,h}from"./chunk-NU7VF7MC.js";import{validateAPIKey as A,WithLoggerContext as T}from"@crossmint/common-sdk-base";var m=class{constructor(n){this.config=n;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return h(this,null,function*(){try{if(this.config.clientTEEConnection==null){let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return h(this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return h(this,null,function*(){o.info("TEE connection not initialized, initializing now");let n=A(this.config.crossmint.apiKey);if(!n.isValid)throw new Error("Invalid API key");let t=new f({environment:n.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");o.info("TEE connection initialized successfully")})}handleAuthRequired(){return h(this,null,function*(){var d;let n=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);o.info("get-status: sending request");let t=Date.now(),e=yield n.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),s=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw o.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:s}),new v(c,p)}if(o.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:s}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:i,resolve:a,reject:r}=this.createAuthPromise();if(this._authPromise={promise:i,resolve:a,reject:r},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>h(this,null,function*(){o.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new u)})),r(new u)}))}catch(c){o.error("handleAuthRequired error",{error:c}),r(c)}try{yield i}catch(c){throw o.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return h(this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let n=this.config.crossmint.jwt;if(n==null)throw new Error("JWT is required");return n}createAuthPromise(){let n,t;return{promise:new Promise((s,i)=>{n=s,t=i}),resolve:n,reject:t}}sendMessageWithOtp(){return h(this,null,function*(){var r;let n=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let e=Date.now(),s=this.config.type==="phone"?this.config.channel:void 0,i=yield n.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(r=this.config.crossmint.jwt)!=null?r:"",apiKey:this.config.crossmint.apiKey},data:E({authId:t},s!=null?{channel:s}:{})},options:l}),a=Date.now()-e;if(this._onboardingConnectionGeneration=n.connectionGeneration,o.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:a}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}if((i==null?void 0:i.status)==="error")throw o.error("start-onboarding: failed",{error:i.error,code:i.code}),new g(i.error||"Failed to initiate OTP process.",i.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(n){return h(this,null,function*(){var i,a;let t;try{let r=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let d=Date.now();t=yield r.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(i=this.config.crossmint.jwt)!=null?i:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:n}}},options:l}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(r){return o.error("complete-onboarding: error",{error:r}),yield this.handleOnboardingVerificationFailure(r)}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),r=>this.verifyOtp(r),()=>{var r;return(r=this._authPromise)==null?void 0:r.reject(new u)})),(a=this._authPromise)==null||a.resolve();return}o.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",s=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new g(e,s))})}handleOnboardingVerificationFailure(n){return h(this,null,function*(){var s,i,a;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){o.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(r){throw(s=this._authPromise)==null||s.reject(r),r}if(!this._needsAuth){(i=this._authPromise)==null||i.resolve();return}throw new P}throw(a=this._authPromise)==null||a.reject(n),n})}_exportPrivateKey(n,t){return h(this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:s,encoding:i}=this.getChainKeyParams();if(t!=null){let r=n.on("event:key-exported",d=>{n.off(r),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let a=yield n.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:s,encoding:i,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((a==null?void 0:a.status)==="error")throw o.error("export-signer: failed",{error:a.error,code:a.code}),new y(a.error||"Failed to export private key",a.code)})}};w([T({logger:o,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};export{m as a,l as b};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkS73R7VRQcjs = require('./chunk-S73R7VRQ.cjs');var _chunkNVKEVEOYcjs = require('./chunk-NVKEVEOY.cjs');var _chunkBHMBFV5Zcjs = require('./chunk-BHMBFV5Z.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var i={evm:_chunkS73R7VRQcjs.a,solana:_chunkNVKEVEOYcjs.a,stellar:_chunkBHMBFV5Zcjs.a};function h(e){return i[_chunkENU3EKBGcjs.a.call(void 0, e)]}function g(e){return Object.prototype.hasOwnProperty.call(i,e)}exports.a = h; exports.b = g;