@crossmint/wallets-sdk 1.0.14 → 1.1.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 (177) hide show
  1. package/dist/api/__tests__/constants.d.cts +1 -1
  2. package/dist/api/__tests__/constants.d.ts +1 -1
  3. package/dist/api/__tests__/test-utils.cjs +1 -1
  4. package/dist/api/__tests__/test-utils.d.cts +1 -1
  5. package/dist/api/__tests__/test-utils.d.ts +1 -1
  6. package/dist/api/__tests__/test-utils.js +1 -1
  7. package/dist/api/client.cjs +1 -1
  8. package/dist/api/client.d.cts +1 -1
  9. package/dist/api/client.d.ts +1 -1
  10. package/dist/api/client.js +1 -1
  11. package/dist/api/gen/sdk.gen.d.cts +1 -1
  12. package/dist/api/gen/sdk.gen.d.ts +1 -1
  13. package/dist/api/gen/types.gen.d.cts +295 -5
  14. package/dist/api/gen/types.gen.d.ts +295 -5
  15. package/dist/api/index.cjs +1 -1
  16. package/dist/api/index.d.cts +1 -1
  17. package/dist/api/index.d.ts +1 -1
  18. package/dist/api/index.js +1 -1
  19. package/dist/api/types.d.cts +1 -1
  20. package/dist/api/types.d.ts +1 -1
  21. package/dist/chains/chains.cjs +1 -1
  22. package/dist/chains/chains.js +1 -1
  23. package/dist/{chunk-EFK26RL5.cjs → chunk-2U7WGZKO.cjs} +1 -1
  24. package/dist/{chunk-SWXDKYWM.js → chunk-5FTEELGX.js} +1 -1
  25. package/dist/chunk-7GRHCD3D.js +1 -0
  26. package/dist/chunk-7N2UI3ZF.js +3 -0
  27. package/dist/{chunk-BS55OS3S.js → chunk-7PJMUI5M.js} +1 -1
  28. package/dist/{chunk-GSGBIM5E.cjs → chunk-AZQCD6KG.cjs} +1 -1
  29. package/dist/chunk-CW6D6JCN.js +1 -0
  30. package/dist/chunk-DXCJLVQZ.js +1 -0
  31. package/dist/chunk-DYJIQP7I.cjs +1 -0
  32. package/dist/{chunk-K5FNXQIQ.js → chunk-EGFMYX2J.js} +1 -1
  33. package/dist/{chunk-7EZQOS37.cjs → chunk-EPG5PWL4.cjs} +1 -1
  34. package/dist/{chunk-QWHQ5NAY.js → chunk-EUE4ZUZX.js} +1 -1
  35. package/dist/chunk-FBPSY3QL.cjs +1 -0
  36. package/dist/{chunk-CF5YIHZX.cjs → chunk-FPFNBH6I.cjs} +1 -1
  37. package/dist/chunk-HILLNWYM.js +1 -0
  38. package/dist/{chunk-LEIODNM5.js → chunk-HZVB2TS2.js} +1 -1
  39. package/dist/{chunk-HFQTOJEG.cjs → chunk-IR6H3POT.cjs} +1 -1
  40. package/dist/chunk-J7D3WVQK.cjs +1 -0
  41. package/dist/{chunk-TP7RAANC.js → chunk-J7WM724X.js} +1 -1
  42. package/dist/{chunk-4NYZ24DW.js → chunk-KTKQ6OL5.js} +1 -1
  43. package/dist/{chunk-CU332MNQ.js → chunk-M5Y7T2U7.js} +1 -1
  44. package/dist/chunk-PGAG6P4Q.cjs +1 -0
  45. package/dist/{chunk-KEEHHSIZ.cjs → chunk-R6HDN7FK.cjs} +1 -1
  46. package/dist/chunk-RFGFHHWP.cjs +1 -0
  47. package/dist/chunk-SL3R26GU.js +1 -0
  48. package/dist/chunk-TLCNLI7Z.cjs +3 -0
  49. package/dist/{chunk-VVLFMWTS.js → chunk-U6Y7VUDY.js} +1 -1
  50. package/dist/{chunk-RUD4GDRD.cjs → chunk-URCSUROA.cjs} +1 -1
  51. package/dist/{chunk-QLHOHXVZ.cjs → chunk-VXCCA7AL.cjs} +1 -1
  52. package/dist/{chunk-5QHWUYYN.js → chunk-W2RVTMBI.js} +1 -1
  53. package/dist/{chunk-PGHXTBM2.cjs → chunk-XQ4IOAFY.cjs} +1 -1
  54. package/dist/{chunk-XKKIMGTA.cjs → chunk-XRZ5RNIN.cjs} +1 -1
  55. package/dist/index.cjs +1 -1
  56. package/dist/index.d.cts +1 -1
  57. package/dist/index.d.ts +1 -1
  58. package/dist/index.js +1 -1
  59. package/dist/logger/index.cjs +1 -1
  60. package/dist/logger/index.js +1 -1
  61. package/dist/logger/init.cjs +1 -1
  62. package/dist/logger/init.js +1 -1
  63. package/dist/sdk.cjs +1 -1
  64. package/dist/sdk.d.cts +1 -1
  65. package/dist/sdk.d.ts +1 -1
  66. package/dist/sdk.js +1 -1
  67. package/dist/signers/device.d.cts +1 -1
  68. package/dist/signers/device.d.ts +1 -1
  69. package/dist/signers/evm-api-key.d.cts +1 -1
  70. package/dist/signers/evm-api-key.d.ts +1 -1
  71. package/dist/signers/evm-external-wallet.d.cts +1 -1
  72. package/dist/signers/evm-external-wallet.d.ts +1 -1
  73. package/dist/signers/external-wallet-signer.d.cts +1 -1
  74. package/dist/signers/external-wallet-signer.d.ts +1 -1
  75. package/dist/signers/index.cjs +1 -1
  76. package/dist/signers/index.d.cts +1 -1
  77. package/dist/signers/index.d.ts +1 -1
  78. package/dist/signers/index.js +1 -1
  79. package/dist/signers/non-custodial/index.cjs +1 -1
  80. package/dist/signers/non-custodial/index.d.cts +1 -1
  81. package/dist/signers/non-custodial/index.d.ts +1 -1
  82. package/dist/signers/non-custodial/index.js +1 -1
  83. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  84. package/dist/signers/non-custodial/ncs-evm-signer.d.cts +1 -1
  85. package/dist/signers/non-custodial/ncs-evm-signer.d.ts +1 -1
  86. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  87. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  88. package/dist/signers/non-custodial/ncs-signer.d.cts +2 -2
  89. package/dist/signers/non-custodial/ncs-signer.d.ts +2 -2
  90. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  91. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  92. package/dist/signers/non-custodial/ncs-solana-signer.d.cts +1 -1
  93. package/dist/signers/non-custodial/ncs-solana-signer.d.ts +1 -1
  94. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  95. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  96. package/dist/signers/non-custodial/ncs-stellar-signer.d.cts +1 -1
  97. package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +1 -1
  98. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  99. package/dist/signers/passkey.d.cts +1 -1
  100. package/dist/signers/passkey.d.ts +1 -1
  101. package/dist/signers/server/assemble-server-signer.d.cts +1 -1
  102. package/dist/signers/server/assemble-server-signer.d.ts +1 -1
  103. package/dist/signers/server/evm-server-signer.d.cts +1 -1
  104. package/dist/signers/server/evm-server-signer.d.ts +1 -1
  105. package/dist/signers/server/helpers/derive-server-signer.d.cts +1 -1
  106. package/dist/signers/server/helpers/derive-server-signer.d.ts +1 -1
  107. package/dist/signers/server/helpers/index.d.cts +1 -1
  108. package/dist/signers/server/helpers/index.d.ts +1 -1
  109. package/dist/signers/server/index.d.cts +1 -1
  110. package/dist/signers/server/index.d.ts +1 -1
  111. package/dist/signers/server/solana-server-signer.d.cts +1 -1
  112. package/dist/signers/server/solana-server-signer.d.ts +1 -1
  113. package/dist/signers/server/stellar-server-signer.d.cts +1 -1
  114. package/dist/signers/server/stellar-server-signer.d.ts +1 -1
  115. package/dist/signers/solana-api-key.d.cts +1 -1
  116. package/dist/signers/solana-api-key.d.ts +1 -1
  117. package/dist/signers/solana-external-wallet.d.cts +1 -1
  118. package/dist/signers/solana-external-wallet.d.ts +1 -1
  119. package/dist/signers/stellar-external-wallet.d.cts +1 -1
  120. package/dist/signers/stellar-external-wallet.d.ts +1 -1
  121. package/dist/signers/types.d.cts +1 -1
  122. package/dist/signers/types.d.ts +1 -1
  123. package/dist/{types-BZ83dAVx.d.ts → types-CtOIG5sn.d.ts} +8 -2
  124. package/dist/{types-fUCYdXAl.d.cts → types-DZWn68Po.d.cts} +8 -2
  125. package/dist/utils/constants.cjs +1 -1
  126. package/dist/utils/constants.js +1 -1
  127. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  128. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  129. package/dist/utils/device-signers/createDeviceSigner.d.cts +1 -1
  130. package/dist/utils/device-signers/createDeviceSigner.d.ts +1 -1
  131. package/dist/utils/device-signers/index.cjs +1 -1
  132. package/dist/utils/device-signers/index.d.cts +1 -1
  133. package/dist/utils/device-signers/index.d.ts +1 -1
  134. package/dist/utils/device-signers/index.js +1 -1
  135. package/dist/utils/signer-locator.d.cts +1 -1
  136. package/dist/utils/signer-locator.d.ts +1 -1
  137. package/dist/utils/signer-mapping.d.cts +1 -1
  138. package/dist/utils/signer-mapping.d.ts +1 -1
  139. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  140. package/dist/wallets/__tests__/test-helpers.d.cts +1 -1
  141. package/dist/wallets/__tests__/test-helpers.d.ts +1 -1
  142. package/dist/wallets/__tests__/test-helpers.js +1 -1
  143. package/dist/wallets/evm.cjs +1 -1
  144. package/dist/wallets/evm.d.cts +1 -1
  145. package/dist/wallets/evm.d.ts +1 -1
  146. package/dist/wallets/evm.js +1 -1
  147. package/dist/wallets/solana.cjs +1 -1
  148. package/dist/wallets/solana.d.cts +1 -1
  149. package/dist/wallets/solana.d.ts +1 -1
  150. package/dist/wallets/solana.js +1 -1
  151. package/dist/wallets/stellar.cjs +1 -1
  152. package/dist/wallets/stellar.d.cts +40 -1
  153. package/dist/wallets/stellar.d.ts +40 -1
  154. package/dist/wallets/stellar.js +1 -1
  155. package/dist/wallets/types.d.cts +1 -1
  156. package/dist/wallets/types.d.ts +1 -1
  157. package/dist/wallets/wallet-factory.cjs +1 -1
  158. package/dist/wallets/wallet-factory.d.cts +2 -2
  159. package/dist/wallets/wallet-factory.d.ts +2 -2
  160. package/dist/wallets/wallet-factory.js +1 -1
  161. package/dist/wallets/wallet.cjs +1 -1
  162. package/dist/wallets/wallet.d.cts +2 -2
  163. package/dist/wallets/wallet.d.ts +2 -2
  164. package/dist/wallets/wallet.js +1 -1
  165. package/package.json +4 -4
  166. package/dist/chunk-6OELZRMT.cjs +0 -1
  167. package/dist/chunk-6XGP4HMG.cjs +0 -1
  168. package/dist/chunk-6Z4EZBIA.js +0 -1
  169. package/dist/chunk-C7ZRKJGY.cjs +0 -1
  170. package/dist/chunk-LTA4BVJ2.js +0 -1
  171. package/dist/chunk-LTTG4ATS.js +0 -1
  172. package/dist/chunk-OH2QJLHX.cjs +0 -1
  173. package/dist/chunk-PTCXLH65.cjs +0 -3
  174. package/dist/chunk-QMSW23Z6.js +0 -1
  175. package/dist/chunk-XFPV6OUZ.js +0 -3
  176. package/dist/chunk-XWG5HSVL.cjs +0 -1
  177. package/dist/chunk-ZPVXC2SA.js +0 -1
@@ -1 +1 @@
1
- import{a as i}from"./chunk-XFPV6OUZ.js";import{b as T}from"./chunk-RBSMBO4T.js";import{a as f}from"./chunk-W7LJS32A.js";import{t as g}from"./chunk-EXC7TCGL.js";import{a as r}from"./chunk-LEIODNM5.js";import{c as u,g as l}from"./chunk-J3R36SGJ.js";import m from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as C}from"@crossmint/common-sdk-base";var o=class o extends i{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:i.getOptions(n),alias:n.alias,recovery:i.getRecovery(n),signer:n.signer,signers:i.getInitialSigners(n)},i.getApiClient(n))}static from(n){if(!y(n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return l(this,null,function*(){var d,p;r.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return r.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let t={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(c=>new f({type:"external-wallet",address:c.publicKey.toString(),locator:`external-wallet:${c.publicKey.toString()}`,onSign:h=>(h.sign([c]),Promise.resolve(h))}))},a=yield this.approveTransactionAndWait(e.id,t);return r.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:a.hash}),a})}createTransaction(n){return l(this,null,function*(){var a;let e;((a=n.options)==null?void 0:a.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${T(n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=m.encode(n.transaction.serialize());let t=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in t)throw new g(JSON.stringify(t));return t})}};u([C({logger:r,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;export{S as a};
1
+ import{a as i}from"./chunk-7N2UI3ZF.js";import{b as T}from"./chunk-RBSMBO4T.js";import{a as f}from"./chunk-W7LJS32A.js";import{t as g}from"./chunk-EXC7TCGL.js";import{a as r}from"./chunk-HZVB2TS2.js";import{c as u,g as l}from"./chunk-J3R36SGJ.js";import m from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as C}from"@crossmint/common-sdk-base";var o=class o extends i{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:i.getOptions(n),alias:n.alias,recovery:i.getRecovery(n),signer:n.signer,signers:i.getInitialSigners(n)},i.getApiClient(n))}static from(n){if(!y(n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return l(this,null,function*(){var d,p;r.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return r.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let t={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(c=>new f({type:"external-wallet",address:c.publicKey.toString(),locator:`external-wallet:${c.publicKey.toString()}`,onSign:h=>(h.sign([c]),Promise.resolve(h))}))},a=yield this.approveTransactionAndWait(e.id,t);return r.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:a.hash}),a})}createTransaction(n){return l(this,null,function*(){var a;let e;((a=n.options)==null?void 0:a.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${T(n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=m.encode(n.transaction.serialize());let t=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in t)throw new g(JSON.stringify(t));return t})}};u([C({logger:r,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;export{S as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6OELZRMTcjs = require('./chunk-6OELZRMT.cjs');var _chunkHFQTOJEGcjs = require('./chunk-HFQTOJEG.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var a=class g extends _chunk6OELZRMTcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkHFQTOJEGcjs.a.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:_chunk6OELZRMTcjs.b});if(_chunkHFQTOJEGcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPGAG6P4Qcjs = require('./chunk-PGAG6P4Q.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var a=class g extends _chunkPGAG6P4Qcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkIR6H3POTcjs.a.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:_chunkPGAG6P4Qcjs.b});if(_chunkIR6H3POTcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
@@ -0,0 +1 @@
1
+ import{a as s}from"./chunk-7N2UI3ZF.js";import{b as h}from"./chunk-RBSMBO4T.js";import{t as u}from"./chunk-EXC7TCGL.js";import{a as t}from"./chunk-HZVB2TS2.js";import{a as g,c,g as i}from"./chunk-J3R36SGJ.js";import{isValidStellarAddress as m,WithLoggerContext as f}from"@crossmint/common-sdk-base";var y=409,l=class l extends s{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:s.getOptions(e),alias:e.alias,recovery:s.getRecovery(e),signer:e.signer,signers:s.getInitialSigners(e)},s.getApiClient(e))}static from(e){if(!m(e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return i(this,null,function*(){var d;t.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let a=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return t.info("stellarWallet.sendTransaction.prepared",{transactionId:a.id}),{hash:void 0,explorerLink:void 0,transactionId:a.id};let r={},n=yield this.approveTransactionAndWait(a.id,r);return t.info("stellarWallet.sendTransaction.success",{transactionId:a.id,hash:n.hash}),n})}upgrade(e){return i(this,null,function*(){t.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let a=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(a!=null){if(e!=null&&e.prepareOnly)return t.info("stellarWallet.upgrade.prepared",{transactionId:a}),{hash:void 0,explorerLink:void 0,transactionId:a};yield this.approveTransactionAndWait(a),t.info("stellarWallet.upgrade.phase1.success",{transactionId:a})}else t.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let r=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return t.info("stellarWallet.upgrade.success",{transactionId:r.transactionId,hash:r.hash}),r})}migrate(e){return i(this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return i(this,null,function*(){t.info("stellarWallet.migrate.start");let a=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(a==null)throw new u("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return t.info("stellarWallet.migrate.prepared",{transactionId:a}),{hash:void 0,explorerLink:void 0,transactionId:a};let r=yield this.approveTransactionAndWait(a);return t.info("stellarWallet.migrate.success",{transactionId:a,hash:r.hash}),r})}createTransaction(e){return i(this,null,function*(){let{contractId:a,options:r}=e,n=this.resolveStellarSigner(r==null?void 0:r.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:a}:{type:"contract-call",contractId:a,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new u(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,a){return i(this,null,function*(){let r=(a==null?void 0:a.signer)!=null?this.resolveStellarSigner(a.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:g({transaction:{type:e}},r!=null?{signer:r}:{})});if("error"in n){if(e==="upgrade-wallet"&&S(n))return null;throw new u(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.requireSigner().locator():typeof e=="string"?e:`server:${h(e,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`}};c([f({logger:t,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),c([f({logger:t,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),c([f({logger:t,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var T=l;function S(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===y}export{T as a};
@@ -0,0 +1 @@
1
+ import{a as g}from"./chunk-O6VBO7KG.js";import{a as l}from"./chunk-6RX65NOA.js";import{a as o}from"./chunk-HZVB2TS2.js";import{c as m,g as h}from"./chunk-J3R36SGJ.js";import{validateAPIKey as p,WithLoggerContext as w}from"@crossmint/common-sdk-base";var f=class{constructor(i){this.config=i;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return h(this,null,function*(){try{if(this.config.clientTEEConnection==null){let i=p(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new g({environment:i.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 i=p(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new g({environment:i.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 u;let i=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);o.info("get-status: sending request");let t=Date.now(),r=yield i.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),n=Date.now()-t;if((r==null?void 0:r.status)!=="success")throw o.error("get-status: failed",{status:r==null?void 0:r.status,error:r==null?void 0:r.error,durationMs:n}),new Error(r==null?void 0:r.error);if(o.info("get-status: response received",{signerStatus:r.signerStatus,durationMs:n}),r.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:a,resolve:s,reject:c}=this.createAuthPromise();if(this._authPromise={promise:a,resolve:s,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>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(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new l)})),c(new l)}))}catch(e){o.error("handleAuthRequired error",{error:e}),c(e)}try{yield a}catch(e){throw o.error("handleAuthRequired promise error",{error:e}),e}})}ensureAuthenticated(){return h(this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null)throw new Error("JWT is required");return i}createAuthPromise(){let i,t;return{promise:new Promise((n,a)=>{i=n,t=a}),resolve:i,reject:t}}sendMessageWithOtp(){return h(this,null,function*(){var s,c;let i=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let r=Date.now(),n=yield i.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),a=Date.now()-r;if(o.info("start-onboarding: response received",{status:n==null?void 0:n.status,durationMs:a}),(n==null?void 0:n.status)==="success"&&n.signerStatus==="ready"){this._needsAuth=!1;return}(n==null?void 0:n.status)==="error"&&(o.error("start-onboarding: failed",{error:n.error}),(c=this._authPromise)==null||c.reject(new Error(n.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(i){return h(this,null,function*(){var a,s,c,u;let t;try{let e=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let E=Date.now();t=yield e.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(a=this.config.crossmint.jwt)!=null?a:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:i}}},options:d}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(e){throw o.error("complete-onboarding: error",{error:e}),this._needsAuth=!0,(s=this._authPromise)==null||s.reject(e),e}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(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new l)})),(c=this._authPromise)==null||c.resolve();return}o.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let r=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",n=new Error(r);throw(u=this._authPromise)==null||u.reject(n),n})}_exportPrivateKey(i,t){return h(this,null,function*(){yield this.handleAuthRequired();let r=this.getJwtOrThrow(),{scheme:n,encoding:a}=this.getChainKeyParams();if(t!=null){let c=i.on("event:key-exported",u=>{i.off(c),u.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let s=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:r,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:a}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};m([w({logger:o,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};export{f as a,d as b};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkK5TQ4QU3cjs = require('./chunk-K5TQ4QU3.cjs');var _chunkTLCNLI7Zcjs = require('./chunk-TLCNLI7Z.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkR6HDN7FKcjs = require('./chunk-R6HDN7FK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var E="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",h= exports.a =class{constructor(t){this.apiClient=t}getWallet(t,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let a,n;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunkT3U46LK3cjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunkT3U46LK3cjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");a=t,n=e}else{if(this.apiClient.isServerSide)throw new (0, _chunkT3U46LK3cjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");n=t,a=this.getWalletLocator(n)}let i=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},n),{chain:_chunkR6HDN7FKcjs.f.call(void 0, n.chain,this.apiClient.environment)});_chunkIR6H3POTcjs.a.info("walletFactory.getWallet.start");let r=yield this.apiClient.getWallet(a);if("error"in r)throw _chunkIR6H3POTcjs.a.warn("walletFactory.getWallet.notFound",{error:r.error}),new (0, _chunkT3U46LK3cjs.e)(JSON.stringify(r));return _chunkIR6H3POTcjs.a.info("walletFactory.getWallet.success",{address:r.address}),yield this.createWalletInstance(r,i)})}createWallet(t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o,s,g,w,W,A,k,F;let e=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{chain:_chunkR6HDN7FKcjs.f.call(void 0, t.chain,this.apiClient.environment)});if(yield(g=(s=(o=e.options)==null?void 0:o.callbacks)==null?void 0:s.onWalletCreationStart)==null?void 0:g.call(s),_chunkIR6H3POTcjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunkIR6H3POTcjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunkT3U46LK3cjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let a=((w=e.options)==null?void 0:w.deviceSignerKeyStorage)!=null?this.ensureDeviceSignerInSigners(e):(W=e.signers)!=null?W:[],n=yield this.registerSigners(a,e.chain,(A=e.options)==null?void 0:A.deviceSignerKeyStorage),i;if(e.recovery.type==="passkey"&&e.recovery.id==null)i=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:D}=_chunk3VSFHDFHcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);i={type:"server",address:D}}else i=e.recovery;let r=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {adminSigner:i},e.plugins?{plugins:e.plugins}:{}),n!=null?{delegatedSigners:n}:{}),owner:(k=e.owner)!=null?k:void 0,alias:(F=e.alias)!=null?F:void 0});if("error"in r)throw _chunkIR6H3POTcjs.a.error("walletFactory.createWallet.error",{error:r.error}),new (0, _chunkT3U46LK3cjs.g)(JSON.stringify(r));return _chunkIR6H3POTcjs.a.info("walletFactory.createWallet.success",{address:r.address}),yield this.createWalletInstance(r,e)})}createWalletInstance(t,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,g;this.validateExistingWalletConfig(t,e);let a=e,n=t.config.adminSigner,i=((s=a.recovery)==null?void 0:s.type)==="server"||((g=a.recovery)==null?void 0:g.type)==="external-wallet"?a.recovery:n,r=t.config.delegatedSigners;r!=null&&r.length===1&&(r[0].type==="server"||r[0].type==="external-wallet")&&(r=a.signers);let o=new (0, _chunkTLCNLI7Zcjs.a)({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:i,signers:r!=null?r:[]},this.apiClient);return yield o.waitForInit(),o})}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(n=t.name)!=null?n:`Crossmint Wallet ${Date.now()}`,a=t.onCreatePasskey?yield t.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(t){var n;let e=(n=t.signers)!=null?n:[];return e.some(i=>i.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&_chunkK5TQ4QU3cjs.a.call(void 0, e.owner)!==_chunkK5TQ4QU3cjs.a.call(void 0, t.owner))throw new (0, _chunkT3U46LK3cjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&t.chainType!=="solana"||e.chain!=="solana"&&t.chainType==="solana"||e.chain==="stellar"&&t.chainType!=="stellar"||e.chain!=="stellar"&&t.chainType==="stellar")throw new (0, _chunkT3U46LK3cjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let a=e;if(a.recovery!=null||a.signers!=null){let n=t.config,i=n==null?void 0:n.adminSigner;if(a.recovery!=null&&i!=null){if(a.recovery.type!==i.type)throw new (0, _chunkT3U46LK3cjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkK5TQ4QU3cjs.b.call(void 0, a.recovery,i)}let r=a.signers;r!=null&&this.validateSigners(t,r,e.chain)}}validateSigners(t,e,a){let n=t.config,i=n==null?void 0:n.delegatedSigners;if(e.length!==0){if(i==null||i.length===0)throw new (0, _chunkT3U46LK3cjs.g)(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${E}`);for(let r of e){let o=i.find(s=>{if(this.isMatchingPasskeySigner(r,s,n)||s.type==="device"&&r.type==="device")return!0;if(r.type==="server"){let{derivedAddress:g}=_chunk3VSFHDFHcjs.b.call(void 0, r,a,this.apiClient.projectId,this.apiClient.environment);return s.locator===`server:${g}`}return s.locator===_chunkNX256LAHcjs.a.call(void 0, r)});if(o==null){let s=i.map(g=>g.locator).join(", ");throw new (0, _chunkT3U46LK3cjs.g)(`Signer '${r.type}' does not exist in wallet "${t.address}". Available signers: ${s}. ${E}`)}_chunkK5TQ4QU3cjs.b.call(void 0, r,o)}}}isMatchingPasskeySigner(t,e,a){var i,r;let n=((r=(i=a.delegatedSigners)==null?void 0:i.filter(o=>o.type==="passkey").length)!=null?r:0)+(a.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&n===1)return e.type==="passkey";if(t.id==null&&n>1)throw new (0, _chunkT3U46LK3cjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,a){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;return yield Promise.all((n=t==null?void 0:t.map(i=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i.type==="passkey")return i.id==null?{signer:yield this.createPasskeySigner(i)}:{signer:i};if(i.type==="device"){if(i.publicKey!=null)return{signer:{type:"device",publicKey:i.publicKey,name:i.name}};if(i.locator!=null)return{signer:i.locator};if(a==null)throw new (0, _chunkT3U46LK3cjs.g)("Device signer key storage is required for device signers");let r=yield _chunkYHV3672Rcjs.a.call(void 0, a);return{signer:{type:"device",publicKey:r.publicKey,name:r.name}}}if(i.type==="server"&&e!=null){let{derivedAddress:r}=_chunk3VSFHDFHcjs.b.call(void 0, i,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${r}`}}return{signer:_chunkNX256LAHcjs.a.call(void 0, i)}})))!=null?n:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"walletFactory.getWallet",buildContext(t,e){if(typeof e[0]=="string"){let n=e[1];return{walletLocator:e[0],chain:n==null?void 0:n.chain}}let a=e[0];return{chain:a==null?void 0:a.chain}}})],h.prototype,"getWallet",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],h.prototype,"createWallet",1);exports.a = h;
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-QMSW23Z6.js";import{a as r}from"./chunk-LEIODNM5.js";import{g as t}from"./chunk-J3R36SGJ.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
1
+ import{a as s,b as o}from"./chunk-DXCJLVQZ.js";import{a as r}from"./chunk-HZVB2TS2.js";import{g as t}from"./chunk-J3R36SGJ.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkPTCXLH65cjs = require('./chunk-PTCXLH65.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunk6EZCCLTKcjs = require('./chunk-6EZCCLTK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkHFQTOJEGcjs = require('./chunk-HFQTOJEG.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunkPTCXLH65cjs.a{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:_chunkPTCXLH65cjs.a.getOptions(n),alias:n.alias,recovery:_chunkPTCXLH65cjs.a.getRecovery(n),signer:n.signer,signers:_chunkPTCXLH65cjs.a.getInitialSigners(n)},_chunkPTCXLH65cjs.a.getApiClient(n))}static from(n){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d,p;_chunkHFQTOJEGcjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return _chunkHFQTOJEGcjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let t={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(c=>new (0, _chunk6EZCCLTKcjs.a)({type:"external-wallet",address:c.publicKey.toString(),locator:`external-wallet:${c.publicKey.toString()}`,onSign:h=>(h.sign([c]),Promise.resolve(h))}))},a=yield this.approveTransactionAndWait(e.id,t);return _chunkHFQTOJEGcjs.a.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:a.hash}),a})}createTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a;let e;((a=n.options)==null?void 0:a.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${_chunk3VSFHDFHcjs.b.call(void 0, n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=_bs582.default.encode(n.transaction.serialize());let t=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in t)throw new (0, _chunkT3U46LK3cjs.t)(JSON.stringify(t));return t})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkHFQTOJEGcjs.a,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;exports.a = S;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkTLCNLI7Zcjs = require('./chunk-TLCNLI7Z.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunk6EZCCLTKcjs = require('./chunk-6EZCCLTK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunkTLCNLI7Zcjs.a{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:_chunkTLCNLI7Zcjs.a.getOptions(n),alias:n.alias,recovery:_chunkTLCNLI7Zcjs.a.getRecovery(n),signer:n.signer,signers:_chunkTLCNLI7Zcjs.a.getInitialSigners(n)},_chunkTLCNLI7Zcjs.a.getApiClient(n))}static from(n){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d,p;_chunkIR6H3POTcjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return _chunkIR6H3POTcjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let t={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(c=>new (0, _chunk6EZCCLTKcjs.a)({type:"external-wallet",address:c.publicKey.toString(),locator:`external-wallet:${c.publicKey.toString()}`,onSign:h=>(h.sign([c]),Promise.resolve(h))}))},a=yield this.approveTransactionAndWait(e.id,t);return _chunkIR6H3POTcjs.a.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:a.hash}),a})}createTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a;let e;((a=n.options)==null?void 0:a.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${_chunk3VSFHDFHcjs.b.call(void 0, n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=_bs582.default.encode(n.transaction.serialize());let t=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in t)throw new (0, _chunkT3U46LK3cjs.t)(JSON.stringify(t));return t})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;exports.a = S;
@@ -1 +1 @@
1
- import{a as n}from"./chunk-LTTG4ATS.js";import{a as s}from"./chunk-N4IWDL6M.js";import{a as l}from"./chunk-VVLFMWTS.js";import{a,b as i}from"./chunk-LEIODNM5.js";import{g as r}from"./chunk-J3R36SGJ.js";import{createCrossmint as C}from"@crossmint/common-sdk-base";import{WebAuthnP256 as p}from"ox";var o=class c{constructor(e){i(e.apiKey);let t=new l(e);this.walletFactory=new n(t),a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return r(this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return r(this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return r(this,null,function*(){return yield s(e,t)})}createPasskeySigner(e){return r(this,null,function*(){let t=yield p.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};export{C as a,o as b};
1
+ import{a as n}from"./chunk-HILLNWYM.js";import{a as s}from"./chunk-N4IWDL6M.js";import{a as l}from"./chunk-U6Y7VUDY.js";import{a,b as i}from"./chunk-HZVB2TS2.js";import{g as r}from"./chunk-J3R36SGJ.js";import{createCrossmint as C}from"@crossmint/common-sdk-base";import{WebAuthnP256 as p}from"ox";var o=class c{constructor(e){i(e.apiKey);let t=new l(e);this.walletFactory=new n(t),a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return r(this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return r(this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return r(this,null,function*(){return yield s(e,t)})}createPasskeySigner(e){return r(this,null,function*(){let t=yield p.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};export{C as a,o as b};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTLCNLI7Zcjs = require('./chunk-TLCNLI7Z.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkR6HDN7FKcjs = require('./chunk-R6HDN7FK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkTLCNLI7Zcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkTLCNLI7Zcjs.a.getOptions(e),alias:e.alias,recovery:_chunkTLCNLI7Zcjs.a.getRecovery(e),signer:e.signer,signers:_chunkTLCNLI7Zcjs.a.getInitialSigners(e)},_chunkTLCNLI7Zcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkIR6H3POTcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=this.buildTransaction(e),t=yield this.createTransaction(n,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkIR6H3POTcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return _chunkIR6H3POTcjs.a.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkIR6H3POTcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:n.locator(),chain:this.chain}});if("error"in t)throw _chunkIR6H3POTcjs.a.error("evmWallet.signMessage.error",{error:t}),new (0, _chunkT3U46LK3cjs.p)(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return _chunkIR6H3POTcjs.a.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return _chunkIR6H3POTcjs.a.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var S;_chunkIR6H3POTcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),{domain:t,message:a,primaryType:i,types:p,chain:m}=e;if(!t||!a||!p||!m)throw _chunkIR6H3POTcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkT3U46LK3cjs.l)("Invalid typed data");let{name:y,version:v,chainId:I,verifyingContract:C,salt:M}=t;if(!y||!v||!I||!C)throw _chunkIR6H3POTcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkT3U46LK3cjs.l)("Invalid typed data domain");let o=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:y,version:v,chainId:Number(I),verifyingContract:C,salt:M},message:T(a),primaryType:i,types:p},signer:n.locator(),chain:m}});if("error"in o)throw _chunkIR6H3POTcjs.a.error("evmWallet.signTypedData.error",{error:o}),new (0, _chunkT3U46LK3cjs.p)(JSON.stringify(o));if((S=e.options)!=null&&S.prepareOnly)return _chunkIR6H3POTcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:o.id}),{signature:void 0,signatureId:o.id};let O=yield this.approveSignatureAndWait(o.id);return _chunkIR6H3POTcjs.a.info("evmWallet.signTypedData.success",{signatureId:o.id}),O})}getViemClient(e){var n;return _viem.createPublicClient.call(void 0, {transport:(n=e==null?void 0:e.transport)!=null?n:_viem.http.call(void 0, ),chain:_chunkR6HDN7FKcjs.a.call(void 0, this.chain)})}createTransaction(e,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t;(n==null?void 0:n.signer)==null?t=this.requireSigner().locator():typeof n.signer=="string"?t=n.signer:t=`server:${_chunk3VSFHDFHcjs.b.call(void 0, n.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkT3U46LK3cjs.t)(JSON.stringify(a));return a})}buildTransaction(e){var n,t,a,i,p;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(n=e.value)==null?void 0:n.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(p=(i=e.value)==null?void 0:i.toString())!=null?p:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var D=c;function T(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(T):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,n])=>[e,T(n)])):s}exports.a = D;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6OELZRMTcjs = require('./chunk-6OELZRMT.cjs');var _chunkHFQTOJEGcjs = require('./chunk-HFQTOJEG.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunk6OELZRMTcjs.a{constructor(e){super(e)}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkHFQTOJEGcjs.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:_chunk6OELZRMTcjs.b});if(_chunkHFQTOJEGcjs.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 _chunkPGAG6P4Qcjs = require('./chunk-PGAG6P4Q.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkPGAG6P4Qcjs.a{constructor(e){super(e)}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkIR6H3POTcjs.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:_chunkPGAG6P4Qcjs.b});if(_chunkIR6H3POTcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};exports.a = c;
@@ -0,0 +1 @@
1
+ import{a as S,b as v}from"./chunk-YIO5XXQ4.js";import{a as R}from"./chunk-7N2UI3ZF.js";import{a as b}from"./chunk-N4IWDL6M.js";import{a as m}from"./chunk-GOXB2RBF.js";import{b as C}from"./chunk-RBSMBO4T.js";import{f as u}from"./chunk-KTKQ6OL5.js";import{e as P,g as l}from"./chunk-EXC7TCGL.js";import{a as c}from"./chunk-HZVB2TS2.js";import{a as y,b as d,c as f,g as p}from"./chunk-J3R36SGJ.js";import{WithLoggerContext as x}from"@crossmint/common-sdk-base";import{WebAuthnP256 as $}from"ox";var E="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",h=class{constructor(t){this.apiClient=t}getWallet(t,e){return p(this,null,function*(){let a,n;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new l("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new l("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");a=t,n=e}else{if(this.apiClient.isServerSide)throw new l("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");n=t,a=this.getWalletLocator(n)}let i=d(y({},n),{chain:u(n.chain,this.apiClient.environment)});c.info("walletFactory.getWallet.start");let r=yield this.apiClient.getWallet(a);if("error"in r)throw c.warn("walletFactory.getWallet.notFound",{error:r.error}),new P(JSON.stringify(r));return c.info("walletFactory.getWallet.success",{address:r.address}),yield this.createWalletInstance(r,i)})}createWallet(t){return p(this,null,function*(){var o,s,g,w,W,A,k,F;let e=d(y({},t),{chain:u(t.chain,this.apiClient.environment)});if(yield(g=(s=(o=e.options)==null?void 0:o.callbacks)==null?void 0:s.onWalletCreationStart)==null?void 0:g.call(s),c.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw c.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new l("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let a=((w=e.options)==null?void 0:w.deviceSignerKeyStorage)!=null?this.ensureDeviceSignerInSigners(e):(W=e.signers)!=null?W:[],n=yield this.registerSigners(a,e.chain,(A=e.options)==null?void 0:A.deviceSignerKeyStorage),i;if(e.recovery.type==="passkey"&&e.recovery.id==null)i=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:D}=C(e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);i={type:"server",address:D}}else i=e.recovery;let r=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:y(y({adminSigner:i},e.plugins?{plugins:e.plugins}:{}),n!=null?{delegatedSigners:n}:{}),owner:(k=e.owner)!=null?k:void 0,alias:(F=e.alias)!=null?F:void 0});if("error"in r)throw c.error("walletFactory.createWallet.error",{error:r.error}),new l(JSON.stringify(r));return c.info("walletFactory.createWallet.success",{address:r.address}),yield this.createWalletInstance(r,e)})}createWalletInstance(t,e){return p(this,null,function*(){var s,g;this.validateExistingWalletConfig(t,e);let a=e,n=t.config.adminSigner,i=((s=a.recovery)==null?void 0:s.type)==="server"||((g=a.recovery)==null?void 0:g.type)==="external-wallet"?a.recovery:n,r=t.config.delegatedSigners;r!=null&&r.length===1&&(r[0].type==="server"||r[0].type==="external-wallet")&&(r=a.signers);let o=new R({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:i,signers:r!=null?r:[]},this.apiClient);return yield o.waitForInit(),o})}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return p(this,null,function*(){var n;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(n=t.name)!=null?n:`Crossmint Wallet ${Date.now()}`,a=t.onCreatePasskey?yield t.onCreatePasskey(e):yield $.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(t){var n;let e=(n=t.signers)!=null?n:[];return e.some(i=>i.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&S(e.owner)!==S(t.owner))throw new l("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 l(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let a=e;if(a.recovery!=null||a.signers!=null){let n=t.config,i=n==null?void 0:n.adminSigner;if(a.recovery!=null&&i!=null){if(a.recovery.type!==i.type)throw new l("The wallet recovery signer type does not match the existing wallet's recovery signer type");v(a.recovery,i)}let r=a.signers;r!=null&&this.validateSigners(t,r,e.chain)}}validateSigners(t,e,a){let n=t.config,i=n==null?void 0:n.delegatedSigners;if(e.length!==0){if(i==null||i.length===0)throw new l(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${E}`);for(let r of e){let o=i.find(s=>{if(this.isMatchingPasskeySigner(r,s,n)||s.type==="device"&&r.type==="device")return!0;if(r.type==="server"){let{derivedAddress:g}=C(r,a,this.apiClient.projectId,this.apiClient.environment);return s.locator===`server:${g}`}return s.locator===m(r)});if(o==null){let s=i.map(g=>g.locator).join(", ");throw new l(`Signer '${r.type}' does not exist in wallet "${t.address}". Available signers: ${s}. ${E}`)}v(r,o)}}}isMatchingPasskeySigner(t,e,a){var i,r;let n=((r=(i=a.delegatedSigners)==null?void 0:i.filter(o=>o.type==="passkey").length)!=null?r:0)+(a.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&n===1)return e.type==="passkey";if(t.id==null&&n>1)throw new l("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,a){return p(this,null,function*(){var n;return yield Promise.all((n=t==null?void 0:t.map(i=>p(this,null,function*(){if(i.type==="passkey")return i.id==null?{signer:yield this.createPasskeySigner(i)}:{signer:i};if(i.type==="device"){if(i.publicKey!=null)return{signer:{type:"device",publicKey:i.publicKey,name:i.name}};if(i.locator!=null)return{signer:i.locator};if(a==null)throw new l("Device signer key storage is required for device signers");let r=yield b(a);return{signer:{type:"device",publicKey:r.publicKey,name:r.name}}}if(i.type==="server"&&e!=null){let{derivedAddress:r}=C(i,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${r}`}}return{signer:m(i)}})))!=null?n:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};f([x({logger:c,methodName:"walletFactory.getWallet",buildContext(t,e){if(typeof e[0]=="string"){let n=e[1];return{walletLocator:e[0],chain:n==null?void 0:n.chain}}let a=e[0];return{chain:a==null?void 0:a.chain}}})],h.prototype,"getWallet",1),f([x({logger:c,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],h.prototype,"createWallet",1);export{h as a};
@@ -1 +1 @@
1
- import{b as n,c as i}from"./chunk-6Z4EZBIA.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-7GRHCD3D.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6XGP4HMGcjs = require('./chunk-6XGP4HMG.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunk6XGP4HMGcjs.c,packageVersion:_chunk6XGP4HMGcjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ7D3WVQKcjs = require('./chunk-J7D3WVQK.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkJ7D3WVQKcjs.c,packageVersion:_chunkJ7D3WVQKcjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.1.0";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =500;exports.a = p; exports.b = c; exports.c = r; exports.d = a;
@@ -1 +1 @@
1
- import{a as S}from"./chunk-6X5JEJD7.js";import{a as l}from"./chunk-SWXDKYWM.js";import{a as i}from"./chunk-CU332MNQ.js";import{a as t}from"./chunk-K5FNXQIQ.js";import{a as C}from"./chunk-EE4ITUGS.js";import{a as u}from"./chunk-CKZYSQOK.js";import{a as p}from"./chunk-QVTKTDED.js";import{a as s}from"./chunk-XS5B3TUE.js";import{a as m}from"./chunk-M335XCYO.js";import{a as g}from"./chunk-YH7G2U6V.js";import{a as o}from"./chunk-W7LJS32A.js";import{g as a}from"./chunk-EXC7TCGL.js";function V(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new t(e):r==="stellar"?new l(e):new i(e);case"api-key":return r==="solana"?new g(e):new p(e);case"external-wallet":return r==="solana"?new o(e):r==="stellar"?new C(e):new s(e);case"server":return S(r,e);case"passkey":return new m(e);case"device":if(n==null)throw new a("Device signer key storage is required for device signers");return new u(e,n)}}export{V as a};
1
+ import{a as S}from"./chunk-6X5JEJD7.js";import{a as l}from"./chunk-5FTEELGX.js";import{a as i}from"./chunk-M5Y7T2U7.js";import{a as t}from"./chunk-EGFMYX2J.js";import{a as C}from"./chunk-EE4ITUGS.js";import{a as u}from"./chunk-CKZYSQOK.js";import{a as p}from"./chunk-QVTKTDED.js";import{a as s}from"./chunk-XS5B3TUE.js";import{a as m}from"./chunk-M335XCYO.js";import{a as g}from"./chunk-YH7G2U6V.js";import{a as o}from"./chunk-W7LJS32A.js";import{g as a}from"./chunk-EXC7TCGL.js";function V(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new t(e):r==="stellar"?new l(e):new i(e);case"api-key":return r==="solana"?new g(e):new p(e);case"external-wallet":return r==="solana"?new o(e):r==="stellar"?new C(e):new s(e);case"server":return S(r,e);case"passkey":return new m(e);case"device":if(n==null)throw new a("Device signer key storage is required for device signers");return new u(e,n)}}export{V as a};
@@ -1 +1 @@
1
- import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{b as i,c as s}from"./chunk-EXC7TCGL.js";import{a as E}from"./chunk-LEIODNM5.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as N,arbitrum as p,arbitrumNova as R,modeTestnet as h,mode as d,bsc as f,shape as W,zora as V,zoraSepolia as B,sepolia as U,flowMainnet as y,flowTestnet as v,plume as H,plumeTestnet as x}from"viem/chains";var b=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],w=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function X(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return N;case e.ARBITRUM:return p;case e.ARBITRUMNOVA:return R;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return f;case e.SHAPE:return W;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return U;case e.FLOW:return y;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return x;case e.PLUME:return H;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return b.includes(t)}function C(t){return w.includes(t)}var D={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function Y(t){return D[t]}function g(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function ee(t,a){if(!g(t))throw new s(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=Y(r);if(n!=null)return E.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;E.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}export{X as a,I as b,C as c,Y as d,g as e,ee as f};
1
+ import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{b as i,c as s}from"./chunk-EXC7TCGL.js";import{a as E}from"./chunk-HZVB2TS2.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as N,arbitrum as p,arbitrumNova as R,modeTestnet as h,mode as d,bsc as f,shape as W,zora as V,zoraSepolia as B,sepolia as U,flowMainnet as y,flowTestnet as v,plume as H,plumeTestnet as x}from"viem/chains";var b=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],w=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function X(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return N;case e.ARBITRUM:return p;case e.ARBITRUMNOVA:return R;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return f;case e.SHAPE:return W;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return U;case e.FLOW:return y;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return x;case e.PLUME:return H;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return b.includes(t)}function C(t){return w.includes(t)}var D={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function Y(t){return D[t]}function g(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function ee(t,a){if(!g(t))throw new s(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=Y(r);if(n!=null)return E.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;E.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}export{X as a,I as b,C as c,Y as d,g as e,ee as f};
@@ -1 +1 @@
1
- import{a,b as g}from"./chunk-QMSW23Z6.js";import{a as s}from"./chunk-LEIODNM5.js";import{g as t}from"./chunk-J3R36SGJ.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
1
+ import{a,b as g}from"./chunk-DXCJLVQZ.js";import{a as s}from"./chunk-HZVB2TS2.js";import{g as t}from"./chunk-J3R36SGJ.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJBP52JOHcjs = require('./chunk-JBP52JOH.cjs');var _chunkAS2YN2YCcjs = require('./chunk-AS2YN2YC.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var f=class{constructor(i){this.config=i;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let i=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:i.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.a.info("TEE connection not initialized, initializing now");let i=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:i.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkIR6H3POTcjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var u;let i=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);_chunkIR6H3POTcjs.a.info("get-status: sending request");let t=Date.now(),r=yield i.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),n=Date.now()-t;if((r==null?void 0:r.status)!=="success")throw _chunkIR6H3POTcjs.a.error("get-status: failed",{status:r==null?void 0:r.status,error:r==null?void 0:r.error,durationMs:n}),new Error(r==null?void 0:r.error);if(_chunkIR6H3POTcjs.a.info("get-status: response received",{signerStatus:r.signerStatus,durationMs:n}),r.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkIR6H3POTcjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:a,resolve:s,reject:c}=this.createAuthPromise();if(this._authPromise={promise:a,resolve:s,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.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(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new _chunkAS2YN2YCcjs.a)})),c(new _chunkAS2YN2YCcjs.a)}))}catch(e){_chunkIR6H3POTcjs.a.error("handleAuthRequired error",{error:e}),c(e)}try{yield a}catch(e){throw _chunkIR6H3POTcjs.a.error("handleAuthRequired promise error",{error:e}),e}})}ensureAuthenticated(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null)throw new Error("JWT is required");return i}createAuthPromise(){let i,t;return{promise:new Promise((n,a)=>{i=n,t=a}),resolve:i,reject:t}}sendMessageWithOtp(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,c;let i=yield this.getTEEConnection(),t=this.getAuthId();_chunkIR6H3POTcjs.a.info("start-onboarding: sending request");let r=Date.now(),n=yield i.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),a=Date.now()-r;if(_chunkIR6H3POTcjs.a.info("start-onboarding: response received",{status:n==null?void 0:n.status,durationMs:a}),(n==null?void 0:n.status)==="success"&&n.signerStatus==="ready"){this._needsAuth=!1;return}(n==null?void 0:n.status)==="error"&&(_chunkIR6H3POTcjs.a.error("start-onboarding: failed",{error:n.error}),(c=this._authPromise)==null||c.reject(new Error(n.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(i){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a,s,c,u;let t;try{let e=yield this.getTEEConnection();_chunkIR6H3POTcjs.a.info("complete-onboarding: sending request");let E=Date.now();t=yield e.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(a=this.config.crossmint.jwt)!=null?a:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:i}}},options:d}),_chunkIR6H3POTcjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(e){throw _chunkIR6H3POTcjs.a.error("complete-onboarding: error",{error:e}),this._needsAuth=!0,(s=this._authPromise)==null||s.reject(e),e}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(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new _chunkAS2YN2YCcjs.a)})),(c=this._authPromise)==null||c.resolve();return}_chunkIR6H3POTcjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let r=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",n=new Error(r);throw(u=this._authPromise)==null||u.reject(n),n})}_exportPrivateKey(i,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired();let r=this.getJwtOrThrow(),{scheme:n,encoding:a}=this.getChainKeyParams();if(t!=null){let c=i.on("event:key-exported",u=>{i.off(c),u.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let s=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:r,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:a}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};exports.a = f; exports.b = d;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkHFQTOJEGcjs = require('./chunk-HFQTOJEG.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var b=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],w=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT,_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.MODE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.PLUME,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function Q(t){switch(t){case _commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA:return _chains.baseSepolia;case _commonsdkbase.BlockchainIncludingTestnet.BASE:return _chains.base;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY:return _chains.polygonAmoy;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON:return _chains.polygon;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA:return _chains.optimismSepolia;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM:return _chains.optimism;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA:return _chains.arbitrumSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM:return _chains.arbitrum;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA:return _chains.arbitrumNova;case _commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA:return _chains.modeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.MODE:return _chains.mode;case _commonsdkbase.BlockchainIncludingTestnet.BSC:return _chains.bsc;case _commonsdkbase.BlockchainIncludingTestnet.SHAPE:return _chains.shape;case _commonsdkbase.BlockchainIncludingTestnet.ZORA:return _chains.zora;case _commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA:return _chains.zoraSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA:return _chains.sepolia;case _commonsdkbase.BlockchainIncludingTestnet.FLOW:return _chains.flowMainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET:return _chains.flowTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET:return _chains.plumeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME:return _chains.plume;case _commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET:return _chunkHRUMWG2Fcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO:return _chunkUE3WVHTMcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET:return _chunk5X4EOJFGcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT:case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.APECHAIN:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1:case _commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.CURTIS:case _commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN:case _commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return b.includes(t)}function C(t){return w.includes(t)}var D={[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT]:_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.MODE]:_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.PLUME]:_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_commonsdkbase.BlockchainIncludingTestnet.SCROLL]:_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1]:_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.STORY]:_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN]:_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET};function Y(t){return D[t]}function g(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function X(t,a){if(!g(t))throw new (0, _chunkT3U46LK3cjs.c)(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(T&&I(r))throw new (0, _chunkT3U46LK3cjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=Y(r);if(n!=null)return _chunkHFQTOJEGcjs.a.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;_chunkHFQTOJEGcjs.a.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}exports.a = Q; exports.b = I; exports.c = C; exports.d = Y; exports.e = g; exports.f = X;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var b=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],w=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT,_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.MODE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.PLUME,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function Q(t){switch(t){case _commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA:return _chains.baseSepolia;case _commonsdkbase.BlockchainIncludingTestnet.BASE:return _chains.base;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY:return _chains.polygonAmoy;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON:return _chains.polygon;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA:return _chains.optimismSepolia;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM:return _chains.optimism;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA:return _chains.arbitrumSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM:return _chains.arbitrum;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA:return _chains.arbitrumNova;case _commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA:return _chains.modeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.MODE:return _chains.mode;case _commonsdkbase.BlockchainIncludingTestnet.BSC:return _chains.bsc;case _commonsdkbase.BlockchainIncludingTestnet.SHAPE:return _chains.shape;case _commonsdkbase.BlockchainIncludingTestnet.ZORA:return _chains.zora;case _commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA:return _chains.zoraSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA:return _chains.sepolia;case _commonsdkbase.BlockchainIncludingTestnet.FLOW:return _chains.flowMainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET:return _chains.flowTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET:return _chains.plumeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME:return _chains.plume;case _commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET:return _chunkHRUMWG2Fcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO:return _chunkUE3WVHTMcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET:return _chunk5X4EOJFGcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT:case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.APECHAIN:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1:case _commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.CURTIS:case _commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN:case _commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return b.includes(t)}function C(t){return w.includes(t)}var D={[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT]:_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.MODE]:_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.PLUME]:_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_commonsdkbase.BlockchainIncludingTestnet.SCROLL]:_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1]:_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.STORY]:_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN]:_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET};function Y(t){return D[t]}function g(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function X(t,a){if(!g(t))throw new (0, _chunkT3U46LK3cjs.c)(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(T&&I(r))throw new (0, _chunkT3U46LK3cjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=Y(r);if(n!=null)return _chunkIR6H3POTcjs.a.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;_chunkIR6H3POTcjs.a.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}exports.a = Q; exports.b = I; exports.c = C; exports.d = Y; exports.e = g; exports.f = X;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTLCNLI7Zcjs = require('./chunk-TLCNLI7Z.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var y=409,l=class l extends _chunkTLCNLI7Zcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkTLCNLI7Zcjs.a.getOptions(e),alias:e.alias,recovery:_chunkTLCNLI7Zcjs.a.getRecovery(e),signer:e.signer,signers:_chunkTLCNLI7Zcjs.a.getInitialSigners(e)},_chunkTLCNLI7Zcjs.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 _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d;_chunkIR6H3POTcjs.a.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let a=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return _chunkIR6H3POTcjs.a.info("stellarWallet.sendTransaction.prepared",{transactionId:a.id}),{hash:void 0,explorerLink:void 0,transactionId:a.id};let r={},n=yield this.approveTransactionAndWait(a.id,r);return _chunkIR6H3POTcjs.a.info("stellarWallet.sendTransaction.success",{transactionId:a.id,hash:n.hash}),n})}upgrade(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.a.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let a=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(a!=null){if(e!=null&&e.prepareOnly)return _chunkIR6H3POTcjs.a.info("stellarWallet.upgrade.prepared",{transactionId:a}),{hash:void 0,explorerLink:void 0,transactionId:a};yield this.approveTransactionAndWait(a),_chunkIR6H3POTcjs.a.info("stellarWallet.upgrade.phase1.success",{transactionId:a})}else _chunkIR6H3POTcjs.a.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let r=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return _chunkIR6H3POTcjs.a.info("stellarWallet.upgrade.success",{transactionId:r.transactionId,hash:r.hash}),r})}migrate(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.a.info("stellarWallet.migrate.start");let a=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(a==null)throw new (0, _chunkT3U46LK3cjs.t)("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return _chunkIR6H3POTcjs.a.info("stellarWallet.migrate.prepared",{transactionId:a}),{hash:void 0,explorerLink:void 0,transactionId:a};let r=yield this.approveTransactionAndWait(a);return _chunkIR6H3POTcjs.a.info("stellarWallet.migrate.success",{transactionId:a,hash:r.hash}),r})}createTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let{contractId:a,options:r}=e,n=this.resolveStellarSigner(r==null?void 0:r.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:a}:{type:"contract-call",contractId:a,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, _chunkT3U46LK3cjs.t)(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,a){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=(a==null?void 0:a.signer)!=null?this.resolveStellarSigner(a.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:_chunk2GKPWQBQcjs.a.call(void 0, {transaction:{type:e}},r!=null?{signer:r}:{})});if("error"in n){if(e==="upgrade-wallet"&&S(n))return null;throw new (0, _chunkT3U46LK3cjs.t)(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.requireSigner().locator():typeof e=="string"?e:`server:${_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var T=l;function S(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===y}exports.a = T;
@@ -0,0 +1 @@
1
+ import{a as d}from"./chunk-7N2UI3ZF.js";import{b}from"./chunk-RBSMBO4T.js";import{a as W}from"./chunk-KTKQ6OL5.js";import{l,p as h,t as w}from"./chunk-EXC7TCGL.js";import{a as r}from"./chunk-HZVB2TS2.js";import{c as g,g as u}from"./chunk-J3R36SGJ.js";import{createPublicClient as x,encodeFunctionData as E,http as N}from"viem";import{isValidEvmAddress as P,WithLoggerContext as f}from"@crossmint/common-sdk-base";var c=class c extends d{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:d.getOptions(e),alias:e.alias,recovery:d.getRecovery(e),signer:e.signer,signers:d.getInitialSigners(e)},d.getApiClient(e))}static from(e){if(!P(e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return u(this,null,function*(){var i;r.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=this.buildTransaction(e),t=yield this.createTransaction(n,e.options);if((i=e.options)!=null&&i.prepareOnly)return r.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return r.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return u(this,null,function*(){var i;r.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:n.locator(),chain:this.chain}});if("error"in t)throw r.error("evmWallet.signMessage.error",{error:t}),new h(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return r.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return r.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return u(this,null,function*(){var S;r.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),{domain:t,message:a,primaryType:i,types:p,chain:m}=e;if(!t||!a||!p||!m)throw r.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new l("Invalid typed data");let{name:y,version:v,chainId:I,verifyingContract:C,salt:M}=t;if(!y||!v||!I||!C)throw r.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new l("Invalid typed data domain");let o=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:y,version:v,chainId:Number(I),verifyingContract:C,salt:M},message:T(a),primaryType:i,types:p},signer:n.locator(),chain:m}});if("error"in o)throw r.error("evmWallet.signTypedData.error",{error:o}),new h(JSON.stringify(o));if((S=e.options)!=null&&S.prepareOnly)return r.info("evmWallet.signTypedData.prepared",{signatureId:o.id}),{signature:void 0,signatureId:o.id};let O=yield this.approveSignatureAndWait(o.id);return r.info("evmWallet.signTypedData.success",{signatureId:o.id}),O})}getViemClient(e){var n;return x({transport:(n=e==null?void 0:e.transport)!=null?n:N(),chain:W(this.chain)})}createTransaction(e,n){return u(this,null,function*(){let t;(n==null?void 0:n.signer)==null?t=this.requireSigner().locator():typeof n.signer=="string"?t=n.signer:t=`server:${b(n.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new w(JSON.stringify(a));return a})}buildTransaction(e){var n,t,a,i,p;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(n=e.value)==null?void 0:n.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(p=(i=e.value)==null?void 0:i.toString())!=null?p:"0",data:E({abi:e.abi,functionName:e.functionName,args:e.args})}}};g([f({logger:r,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),g([f({logger:r,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),g([f({logger:r,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var D=c;function T(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(T):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,n])=>[e,T(n)])):s}export{D as a};
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunkD6SLJ5C2cjs = require('./chunk-D6SLJ5C2.cjs');var _chunk2U7WGZKOcjs = require('./chunk-2U7WGZKO.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkPGAG6P4Qcjs = require('./chunk-PGAG6P4Q.cjs');var _chunkAS2YN2YCcjs = require('./chunk-AS2YN2YC.cjs');var _chunkR6HDN7FKcjs = require('./chunk-R6HDN7FK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunkJ7D3WVQKcjs = require('./chunk-J7D3WVQK.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var S,C,h,w,R,A,L,O,F,T= exports.a =class{constructor(e,r){_chunk2GKPWQBQcjs.e.call(void 0, this,S);_chunk2GKPWQBQcjs.e.call(void 0, this,C);_chunk2GKPWQBQcjs.e.call(void 0, this,h);_chunk2GKPWQBQcjs.e.call(void 0, this,w);_chunk2GKPWQBQcjs.e.call(void 0, this,R);_chunk2GKPWQBQcjs.e.call(void 0, this,A,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,L,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,O);_chunk2GKPWQBQcjs.e.call(void 0, this,F,null);let{chain:t,address:n,owner:s,options:d,alias:o,recovery:l,signers:g,signer:u}=e;_chunk2GKPWQBQcjs.f.call(void 0, this,h,r),this.chain=t,this.address=n,this.owner=s,_chunk2GKPWQBQcjs.f.call(void 0, this,C,d),this.alias=o,_chunk2GKPWQBQcjs.f.call(void 0, this,w,l),_chunk2GKPWQBQcjs.f.call(void 0, this,R,g!=null?g:[]),_chunk2GKPWQBQcjs.f.call(void 0, this,S,u),_chunk2GKPWQBQcjs.f.call(void 0, this,O,this.initDefaultSigner())}get signer(){return _chunk2GKPWQBQcjs.d.call(void 0, this,S)}waitForInit(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,O)})}initDeviceSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;let e=(n=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:n.deviceSignerKeyStorage;if(e==null)return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(s){_chunkIR6H3POTcjs.a.error("wallet.initDeviceSigner.error",{error:s}),_chunk2GKPWQBQcjs.f.call(void 0, this,A,!0);return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,A))return;let t=this.buildInternalSignerConfig(r);_chunk2GKPWQBQcjs.f.call(void 0, this,S,yield this.assembleFullSigner(t,e))})}initDefaultSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,S)!=null||(yield this.initDeviceSigner(),_chunk2GKPWQBQcjs.d.call(void 0, this,S)!=null||_chunk2GKPWQBQcjs.d.call(void 0, this,A)))return;let e=_chunk2GKPWQBQcjs.d.call(void 0, this,R).length===0?_chunk2GKPWQBQcjs.d.call(void 0, this,w):_chunk2GKPWQBQcjs.d.call(void 0, this,R).length===1?_chunk2GKPWQBQcjs.d.call(void 0, this,R)[0]:null;if(e==null||!this.isAutoAssemblableSignerConfig(e))return;let r=e===_chunk2GKPWQBQcjs.d.call(void 0, this,w);try{let t=this.buildInternalSignerConfig(e);_chunk2GKPWQBQcjs.f.call(void 0, this,S,yield this.assembleFullSigner(t,void 0,{isAdminSigner:r}))}catch(t){_chunkIR6H3POTcjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunk2GKPWQBQcjs.d.call(void 0, this,w).type,signerCount:_chunk2GKPWQBQcjs.d.call(void 0, this,R).length,error:t})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,w)}static getInitialSigners(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,R)}get apiClient(){return _chunk2GKPWQBQcjs.d.call(void 0, this,h)}get options(){return _chunk2GKPWQBQcjs.d.call(void 0, this,C)}get recovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,w)}balances(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t;switch(this.chain){case"solana":t="sol";break;case"stellar":t="xlm";break;default:t="eth";break}let n=[t,"usdc",...e!=null?e:[]],s=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).getBalance(this.address,{chains:[r],tokens:n});if("error"in s)throw _chunkIR6H3POTcjs.a.error("wallet.balances.error",{error:s}),new Error(`Failed to get balances for wallet: ${JSON.stringify(s.message)}`);return _chunkIR6H3POTcjs.a.info("wallet.balances.success"),this.transformBalanceResponse(s,t,e)})}stagingFund(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw _chunkIR6H3POTcjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunkIR6H3POTcjs.a.info("wallet.stagingFund.success"),t})}transformBalanceResponse(e,r,t){let n=g=>{var y,m,I,K,B;let u=(y=g.chains)==null?void 0:y[this.chain],f={};return this.chain==="solana"&&u!=null&&"mintHash"in u?f={mintHash:u.mintHash}:this.chain==="stellar"&&u!=null&&"contractId"in u?f={contractId:u.contractId}:u!=null&&"contractAddress"in u&&(f={contractAddress:u.contractAddress}),_chunk2GKPWQBQcjs.a.call(void 0, {symbol:(m=g.symbol)!=null?m:"",name:(I=g.name)!=null?I:"",amount:(K=g.amount)!=null?K:"0",decimals:g.decimals,rawAmount:(B=g.rawAmount)!=null?B:"0"},f)},s=e.find(g=>g.symbol===r),d=e.find(g=>g.symbol==="usdc"),o=e.filter(g=>{var u;return g.symbol!==r&&g.symbol!=="usdc"&&(t==null||t.includes((u=g.symbol)!=null?u:""))}),l=g=>{let u={symbol:g,name:g,amount:"0",decimals:0,rawAmount:"0"},f={};return this.chain==="solana"?f={mintHash:void 0}:this.chain==="stellar"?f={contractId:void 0}:f={contractAddress:void 0},_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},u),f)};return{nativeToken:s!=null?n(s):l(r),usdc:d!=null?n(d):l("usdc"),tokens:o.map(n)}}nfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).getNfts(_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{chain:this.chain,address:this.address}))})}transactions(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=this.resolveChainForEnvironment(),d=de(e),o=ue(r,s),l=Number(t);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new (0, _chunkT3U46LK3cjs.s)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);_chunkIR6H3POTcjs.a.info("wallet.send.start",_chunk2GKPWQBQcjs.a.call(void 0, {recipient:d,token:o,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let g=this.requireSigner(),u;(n==null?void 0:n.signer)==null?u=g.locator():typeof n.signer=="string"?u=n.signer:u=`server:${_chunk3VSFHDFHcjs.b.call(void 0, n.signer,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,h).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,h).environment).derivedAddress}`;let f=_chunk2GKPWQBQcjs.a.call(void 0, {recipient:d,amount:t,signer:u},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),y=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).send(this.walletLocator,o,f);if("message"in y)throw _chunkIR6H3POTcjs.a.error("wallet.send.error",{error:y}),new (0, _chunkT3U46LK3cjs.t)(`Failed to send token: ${JSON.stringify(y.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return _chunkIR6H3POTcjs.a.info("wallet.send.prepared",{transactionId:y.id}),{hash:void 0,explorerLink:void 0,transactionId:y.id};let m=yield this.approveTransactionAndWait(y.id);return _chunkIR6H3POTcjs.a.info("wallet.send.success",{transactionId:y.id,hash:m.hash}),m})}approveTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return console.warn("approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."),yield this.approve(e)})}approve(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(_chunkIR6H3POTcjs.a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return _chunkIR6H3POTcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkIR6H3POTcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkIR6H3POTcjs.a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?`server:${_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,h).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,h).environment).derivedAddress}`:e;return this.withRecoverySigner(()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var u,f;let n=typeof t=="string"?t:_chunkNX256LAHcjs.a.call(void 0, t),s=yield this.getSignerState(n);if(s.signer!=null){if(this.isApprovedSignerStatus(s.signer.status))return _chunkIR6H3POTcjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(s.signer,null,r);if(s.pendingOperation!=null)return _chunkIR6H3POTcjs.a.info("wallet.addSigner.resuming",{operationType:s.pendingOperation.type,operationId:s.pendingOperation.id}),this.completeSignerRegistration(s.signer,s.pendingOperation,r)}let d=typeof t=="string"||t.type==="passkey"?t:t.type==="device"&&"publicKey"in t&&t.publicKey!=null?{type:"device",publicKey:t.publicKey,name:t.name}:_chunkNX256LAHcjs.a.call(void 0, t),o=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).registerSigner(this.walletLocator,{signer:d,chain:this.getSignerRegistrationChain()});if("error"in o)throw _chunkIR6H3POTcjs.a.error("wallet.addSigner.error",{error:o}),new (0, _chunkT3U46LK3cjs.j)(`Failed to register signer: ${JSON.stringify(o.message)}`);let l=_chunkD6SLJ5C2cjs.b.call(void 0, o,this.chain);if(l==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let g=null;if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in o)||o.transaction==null)throw _chunkIR6H3POTcjs.a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");g={type:"transaction",id:o.transaction.id}}else{if(!("chains"in o))throw _chunkIR6H3POTcjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((f=(u=o.chains)==null?void 0:u[this.chain])==null?void 0:f.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);g=_chunkD6SLJ5C2cjs.c.call(void 0, o,this.chain)}return this.completeSignerRegistration(l,g,r)}))})}completeSignerRegistration(e,r,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return _chunk2GKPWQBQcjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return _chunkIR6H3POTcjs.a.info("wallet.addSigner.prepared",n),_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),n)}case"signature":{let n={signatureId:r.id};return _chunkIR6H3POTcjs.a.info("wallet.addSigner.prepared",n),_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),_chunkIR6H3POTcjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkIR6H3POTcjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else _chunkIR6H3POTcjs.a.info("wallet.addSigner.success");return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=this.resolveSignerLocator(e);return _chunkIR6H3POTcjs.a.info("wallet.removeSigner.start",{signerLocator:t}),this.withRecoverySigner(()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).removeSigner(this.walletLocator,t,{chain:this.getSignerRegistrationChain()});if("error"in n)throw _chunkIR6H3POTcjs.a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let s=n.id;return r!=null&&r.prepareOnly?(_chunkIR6H3POTcjs.a.info("wallet.removeSigner.prepared",{transactionId:s}),{transactionId:s,status:void 0}):(yield this.approveTransactionAndWait(s),_chunkIR6H3POTcjs.a.info("wallet.removeSigner.success",{transactionId:s}),{transactionId:s,status:"success"})}))})}useSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.a.info("wallet.useSigner.start"),this.validateSignerInput(e);let r=!1;e.type==="device"?yield this.resolveDeviceSignerAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=this.buildInternalSignerConfig(e),n=_chunkNX256LAHcjs.a.call(void 0, e);_chunk2GKPWQBQcjs.f.call(void 0, this,S,yield this.assembleFullSigner(t,void 0,{isAdminSigner:r})),_chunkIR6H3POTcjs.a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(e.type!=="passkey"&&this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,A,!1),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,A,!1),!0;throw new Error("No passkey signer is registered on this wallet.")}let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return _chunk2GKPWQBQcjs.f.call(void 0, this,A,!1),!1;if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,A,!1),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){if(e.type==="server"){let{derivedAddress:r}=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,h).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,h).environment);return`server:${r}`}return _chunkNX256LAHcjs.a.call(void 0, e)}getSignerRegistrationChain(){if(!(this.chain==="solana"||this.chain==="stellar"))return this.chain}withRecoverySigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;let r=this.signer;if(_chunkAS2YN2YCcjs.b.call(void 0, _chunk2GKPWQBQcjs.d.call(void 0, this,w)))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(_chunk2GKPWQBQcjs.d.call(void 0, this,w)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,w).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,w)))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let t=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,w));_chunk2GKPWQBQcjs.f.call(void 0, this,S,_chunk2U7WGZKOcjs.a.call(void 0, this.chain,t,(n=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:n.deviceSignerKeyStorage));try{return yield e()}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,S,r)}})}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.signers()).some(t=>t.locator===e)})}isSignerApproved(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;let r=yield this.getSignerState(e);return this.isApprovedSignerStatus((t=r.signer)==null?void 0:t.status)})}isApprovedSignerStatus(e){return e==="success"||e==="active"}needsRecovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,A)}recover(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,d;if(_chunkIR6H3POTcjs.a.info("wallet.recover.start"),_chunk2GKPWQBQcjs.d.call(void 0, this,L)){_chunkIR6H3POTcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}let e=()=>{_chunk2GKPWQBQcjs.f.call(void 0, this,A,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,L,!0)};if(((s=_chunk2GKPWQBQcjs.d.call(void 0, this,S))==null?void 0:s.type)==="device"&&(yield this.checkAndResumeDeviceSigner(_chunk2GKPWQBQcjs.d.call(void 0, this,S)))){e();return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,S)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,S).type!=="device"){_chunkIR6H3POTcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunk2GKPWQBQcjs.f.call(void 0, this,A,!1);return}let r=(d=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:d.deviceSignerKeyStorage;if(r==null){if(!_chunk2GKPWQBQcjs.d.call(void 0, this,A))return;throw new Error("Device signer key storage is required to recover a device signer")}let t=yield this.findLocalDeviceSigner(r);if(t!=null&&(yield this.checkAndResumeDeviceSigner(t))){_chunk2GKPWQBQcjs.f.call(void 0, this,S,t),e();let o=t.locator().replace("device:","");try{yield r.mapAddressToKey(this.address,o)}catch(l){_chunkIR6H3POTcjs.a.warn("wallet.recover.mapAddressToKey.error",{error:l})}return}let n=yield _chunkYHV3672Rcjs.a.call(void 0, r,this.address);try{yield this.addSigner(n)}catch(o){if(o instanceof Error&&o.message.toLowerCase().includes("delegated signer")&&o.message.toLowerCase().includes("already")&&o.message.toLowerCase().includes("approved"))_chunkIR6H3POTcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:n.locator});else throw o instanceof _chunkAS2YN2YCcjs.a||o instanceof Error&&o.name==="AuthRejectedError"?(_chunkIR6H3POTcjs.a.info("wallet.recover.device.authRejected",{signerLocator:n.locator}),o):(_chunkIR6H3POTcjs.a.error("wallet.recover.device.error",{error:o}),yield r.deleteKey(this.address),_chunk2GKPWQBQcjs.f.call(void 0, this,A,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,L,!0),o)}_chunk2GKPWQBQcjs.f.call(void 0, this,S,yield this.assembleFullSigner({type:"device",locator:n.locator,address:this.address},r)),_chunk2GKPWQBQcjs.d.call(void 0, this,S).type==="device"&&(_chunk2GKPWQBQcjs.d.call(void 0, this,S).status="success"),_chunkIR6H3POTcjs.a.info("wallet.recover.device.success",{signerLocator:n.locator}),e()})}checkAndResumeDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var t;if(this.isApprovedSignerStatus(e.status))return _chunkIR6H3POTcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let r=yield this.getSignerState(e.locator());return e.status=(t=r.signer)==null?void 0:t.status,r.pendingOperation!=null?(yield this.resumePendingDeviceSignerApproval(e,r.pendingOperation),!0):this.isApprovedSignerStatus(e.status)?(_chunkIR6H3POTcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})}resumePendingDeviceSignerApproval(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s;let t=_chunk2GKPWQBQcjs.d.call(void 0, this,S);if(_chunkAS2YN2YCcjs.b.call(void 0, _chunk2GKPWQBQcjs.d.call(void 0, this,w)))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(_chunk2GKPWQBQcjs.d.call(void 0, this,w)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,w).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,w)))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let n=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,w));_chunk2GKPWQBQcjs.f.call(void 0, this,S,_chunk2U7WGZKOcjs.a.call(void 0, this.chain,n,(s=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:s.deviceSignerKeyStorage));try{r.type==="signature"?yield this.approveSignatureAndWait(r.id):yield this.approveTransactionAndWait(r.id)}catch(d){throw _chunk2GKPWQBQcjs.f.call(void 0, this,S,e),d}finally{_chunk2GKPWQBQcjs.d.call(void 0, this,S)!==e&&_chunk2GKPWQBQcjs.f.call(void 0, this,S,t)}e.status="success",_chunkIR6H3POTcjs.a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0})})}findLocalDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=(yield this.signers()).filter(n=>n.locator.startsWith("device:"));for(let n of t){let s=n.locator.replace("device:","");try{if(yield e.hasKey(s)){let o=_chunk2U7WGZKOcjs.a.call(void 0, this.chain,{type:"device",locator:n.locator,address:this.address},e);return _chunkIR6H3POTcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:n.locator}),o}}catch(d){_chunkIR6H3POTcjs.a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:n.locator,error:d})}}return null})}signers(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,d;_chunkIR6H3POTcjs.a.info("wallet.signers.start");let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).getWallet(this.walletLocator);if("error"in e)throw _chunkIR6H3POTcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkT3U46LK3cjs.e)(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw _chunkIR6H3POTcjs.a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new (0, _chunkT3U46LK3cjs.d)(`Wallet type ${e.type} not supported`);let r=(d=(s=e==null?void 0:e.config)==null?void 0:s.delegatedSigners)!=null?d:[],n=(yield Promise.all(r.map(o=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{return(yield this.getSignerState(o.locator)).signer}catch(l){return null}})))).filter(o=>o!=null);return _chunkIR6H3POTcjs.a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,h).isServerSide)return this.address;{let e;switch(this.chain){case"stellar":e="me:stellar:smart";break;case"solana":e="me:solana:smart";break;default:e="me:evm:smart";break}let r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}requireSigner(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,S)==null)throw _chunk2GKPWQBQcjs.d.call(void 0, this,R).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):_chunk2GKPWQBQcjs.d.call(void 0, this,w).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
2
+ Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`):_chunk2GKPWQBQcjs.d.call(void 0, this,w).type==="external-wallet"||!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,w))?new Error(`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
3
+ Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`):new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available.");return _chunk2GKPWQBQcjs.d.call(void 0, this,S)}preAuthIfNeeded(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,O),_chunk2GKPWQBQcjs.d.call(void 0, this,F)==null&&_chunk2GKPWQBQcjs.f.call(void 0, this,F,this.recover());try{yield _chunk2GKPWQBQcjs.d.call(void 0, this,F)}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,F,null)}let e=this.requireSigner();e instanceof _chunkPGAG6P4Qcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=_chunk2GKPWQBQcjs.d.call(void 0, this,w);if(r==null||r.type!==e.type||e.type==="device")return!1;if(e.type==="passkey")return!0;if(e.type==="server"&&r.type==="server"){let t=d=>_chunkAS2YN2YCcjs.b.call(void 0, d)?d.address:_chunk3VSFHDFHcjs.b.call(void 0, d,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,h).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,h).environment).derivedAddress,n=t(e),s=t(r);if(n!==s)return!1}else if(_chunkNX256LAHcjs.a.call(void 0, e)!==_chunkNX256LAHcjs.a.call(void 0, r))return!1;return _chunk2GKPWQBQcjs.f.call(void 0, this,w,e),!0}validateSignerInput(e){switch(e.type){case"email":if(!("email"in e)||e.email==null)throw new Error("Email signer requires an email address");break;case"phone":if(!("phone"in e)||e.phone==null)throw new Error("Phone signer requires a phone number");break;case"external-wallet":if(!("address"in e)||e.address==null)throw new Error("External wallet signer requires a wallet address");if(!("onSign"in e)||typeof e.onSign!="function")throw new Error("External wallet signer requires an onSign callback");break;case"passkey":case"device":case"api-key":break;default:break}}resolveDeviceSignerAvailability(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d;let r=(d=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:d.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let t=yield r.getKey(this.address);if(t!=null){e.locator=`device:${t}`;return}let s=(yield this.signers()).filter(o=>o.locator.startsWith("device:"));for(let o of s){let l=o.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=o.locator;return}}_chunk2GKPWQBQcjs.f.call(void 0, this,A,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,L,!1)})}assembleFullSigner(s){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=(n=>(n=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:n.deviceSignerKeyStorage)(),t){var o;let d=_chunk2U7WGZKOcjs.a.call(void 0, this.chain,e,r);if(t!=null&&t.isAdminSigner)d.status="active";else{let l=yield this.getSignerState(d.locator());d.status=(o=l.signer)==null?void 0:o.status}return d})}getSignerState(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;try{r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).getSigner(this.walletLocator,e)}catch(n){return{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return{response:null,signer:null,pendingOperation:null};let t=_chunkD6SLJ5C2cjs.b.call(void 0, r,this.chain);return{response:r,signer:t,pendingOperation:_chunkD6SLJ5C2cjs.c.call(void 0, r,this.chain)}})}buildInternalSignerConfig(e){var r,t,n,s,d,o;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,h).crossmint,clientTEEConnection:(r=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:r.clientTEEConnection,onAuthRequired:(n=(t=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:t.callbacks)==null?void 0:n.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,h).crossmint,clientTEEConnection:(s=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:s.clientTEEConnection,onAuthRequired:(o=(d=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:d.callbacks)==null?void 0:o.onAuthRequired};case"passkey":{let l="id"in e&&e.id?e.id:"";return{type:"passkey",id:l,locator:`passkey:${l}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:e.onCreatePasskey,onSignWithPasskey:e.onSignWithPasskey}}case"device":return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:this.address};case"external-wallet":return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{locator:`external-wallet:${e.address}`});case"api-key":return{type:"api-key",locator:"api-key",address:this.address};case"server":{let{derivedKeyBytes:l,derivedAddress:g}=_chunk3VSFHDFHcjs.b.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,h).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,h).environment);return{type:"server",derivedKeyBytes:l,locator:`server:${g}`,address:g}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}isAutoAssemblableSignerConfig(e){var r;switch(e.type){case"email":case"phone":case"passkey":case"api-key":return!0;case"device":return((r=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:r.deviceSignerKeyStorage)!=null;case"server":return!_chunkAS2YN2YCcjs.b.call(void 0, e);case"external-wallet":return"onSign"in e&&typeof e.onSign=="function";default:return!1}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=_chunkR6HDN7FKcjs.f.call(void 0, this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,h).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,g;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=this.requireSigner(),n=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).getSignature(this.walletLocator,e);if("error"in n)throw new (0, _chunkT3U46LK3cjs.q)(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let u=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,u)}let s=(l=n.approvals)==null?void 0:l.pending;if(s==null)return n;let d=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],t],o=yield Promise.all(s.map(u=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let f=d.find(m=>m.locator()===u.signer.locator);if(f==null)throw new (0, _chunkT3U46LK3cjs.j)(`Signer ${u.signer.locator} not found in pending approvals`);let y=yield f.signMessage(u.message);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},y),{signer:f.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,o)})}approveTransactionInternal(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,g,u,f,y;let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).getTransaction(this.walletLocator,e);if("error"in t)throw new (0, _chunkT3U46LK3cjs.u)(JSON.stringify(t));yield(u=(g=(l=_chunk2GKPWQBQcjs.d.call(void 0, this,C))==null?void 0:l.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:u.call(g);let n=this.requireSigner();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let s=(f=t.approvals)==null?void 0:f.pending;if(s==null)return t;let d=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],n],o=yield Promise.all(s.map(m=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let I=d.find(ge=>ge.locator()===m.signer.locator);if(I==null)throw new (0, _chunkT3U46LK3cjs.j)(`Signer ${m.signer.locator} not found in pending approvals`);let K=I.type==="device",B=t.chainType==="solana"&&"transaction"in t.onChain&&!K?t.onChain.transaction:m.message,ce=yield I.signTransaction(B);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},ce),{signer:I.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,o)})}executeApproveTransactionWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new (0, _chunkT3U46LK3cjs.z)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new (0, _chunkT3U46LK3cjs.r)(JSON.stringify(t));return t})}waitForSignature(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;do if(yield new Promise(t=>setTimeout(t,_chunkJ7D3WVQKcjs.d)),r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).getSignature(this.walletLocator,e),"error"in r)throw new (0, _chunkT3U46LK3cjs.q)(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new (0, _chunkT3U46LK3cjs.n)("Signature signing failed");if(!r.outputSignature)throw new (0, _chunkT3U46LK3cjs.q)("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(d){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:n=2e3,initialBackoffMs:s=_chunkJ7D3WVQKcjs.d}={}){var f,y;_chunkIR6H3POTcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let o=Date.now(),l;do{if(Date.now()-o>r)throw new (0, _chunkT3U46LK3cjs.v)("Transaction confirmation timeout");if(l=yield _chunk2GKPWQBQcjs.d.call(void 0, this,h).getTransaction(this.walletLocator,e),l.error)throw new (0, _chunkT3U46LK3cjs.u)(JSON.stringify(l));yield this.sleep(s),s=Math.min(s*t,n)}while(l.status==="pending");if(l.status==="failed")throw new (0, _chunkT3U46LK3cjs.w)(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new (0, _chunkT3U46LK3cjs.x)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let g="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,u=(f=l.onChain.txId)!=null?f:g;if(u==null)throw new (0, _chunkT3U46LK3cjs.y)("Transaction hash not found on transaction response");return{hash:u,explorerLink:(y=l.onChain.explorerLink)!=null?y:"",transactionId:l.id}})}sleep(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};S=new WeakMap,C=new WeakMap,h=new WeakMap,w=new WeakMap,R=new WeakMap,A=new WeakMap,L=new WeakMap,O=new WeakMap,F=new WeakMap,_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"balances",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"stagingFund",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"send",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"approve",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"addSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"removeSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"useSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"recover",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkIR6H3POTcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"signers",1);function de(v){if(typeof v=="string"){if(!_commonsdkbase.isValidAddress.call(void 0, v))throw new (0, _chunkT3U46LK3cjs.B)(`Invalid recipient address: "${v}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return v}if("email"in v)return`email:${v.email}`;if("x"in v)return`x:${v.x}`;if("twitter"in v)return`twitter:${v.twitter}`;if("phone"in v)return`phoneNumber:${v.phone}`;if("userId"in v)return`userId:${v.userId}`;throw new Error("Invalid recipient locator")}function ue(v,e){return _commonsdkbase.isValidAddress.call(void 0, v)?`${e}:${v}`:`${e}:${v.toLowerCase()}`}exports.a = T;
@@ -1 +1 @@
1
- import{a as o}from"./chunk-EXC7TCGL.js";import{a}from"./chunk-LEIODNM5.js";import{b as p,c}from"./chunk-6Z4EZBIA.js";import{g as t}from"./chunk-J3R36SGJ.js";import{APIKeyEnvironmentPrefix as d,APIKeyUsageOrigin as g,CrossmintApiClient as P}from"@crossmint/common-sdk-base";var h=class extends P{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:c,version:p}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return t(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;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?a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return t(this,null,function*(){a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return t(this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return t(this,null,function*(){if(this.environment===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 t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return t(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 t(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 t(this,null,function*(){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?a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}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
+ import{a as o}from"./chunk-EXC7TCGL.js";import{a}from"./chunk-HZVB2TS2.js";import{b as p,c}from"./chunk-7GRHCD3D.js";import{g as t}from"./chunk-J3R36SGJ.js";import{APIKeyEnvironmentPrefix as d,APIKeyUsageOrigin as g,CrossmintApiClient as P}from"@crossmint/common-sdk-base";var h=class extends P{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:c,version:p}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return t(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;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?a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return t(this,null,function*(){a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return t(this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return t(this,null,function*(){if(this.environment===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 t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return t(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 t(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 t(this,null,function*(){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?a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}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 _chunkOH2QJLHXcjs = require('./chunk-OH2QJLHX.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkQLHOHXVZcjs = require('./chunk-QLHOHXVZ.cjs');var _chunkHFQTOJEGcjs = require('./chunk-HFQTOJEG.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkHFQTOJEGcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkQLHOHXVZcjs.a)(e);this.walletFactory=new (0, _chunkOH2QJLHXcjs.a)(t),_chunkHFQTOJEGcjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunkYHV3672Rcjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkDYJIQP7Icjs = require('./chunk-DYJIQP7I.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkVXCCA7ALcjs = require('./chunk-VXCCA7AL.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkIR6H3POTcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkVXCCA7ALcjs.a)(e);this.walletFactory=new (0, _chunkDYJIQP7Icjs.a)(t),_chunkIR6H3POTcjs.a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunkYHV3672Rcjs.a.call(void 0, e,t)})}createPasskeySigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};exports.a = _commonsdkbase.createCrossmint; exports.b = o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkHFQTOJEGcjs = require('./chunk-HFQTOJEG.cjs');var _chunk6XGP4HMGcjs = require('./chunk-6XGP4HMG.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunk6XGP4HMGcjs.c,version:_chunk6XGP4HMGcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkHFQTOJEGcjs.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?_chunkHFQTOJEGcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkHFQTOJEGcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkHFQTOJEGcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkHFQTOJEGcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkHFQTOJEGcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkHFQTOJEGcjs.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?_chunkHFQTOJEGcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkHFQTOJEGcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunkJ7D3WVQKcjs = require('./chunk-J7D3WVQK.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkJ7D3WVQKcjs.c,version:_chunkJ7D3WVQKcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkIR6H3POTcjs.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?_chunkIR6H3POTcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkIR6H3POTcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkIR6H3POTcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkIR6H3POTcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkIR6H3POTcjs.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?_chunkIR6H3POTcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkIR6H3POTcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
@@ -1 +1 @@
1
- import{a as v}from"./chunk-IOSADDL5.js";import{a as l}from"./chunk-LEIODNM5.js";import{c as d,g as n}from"./chunk-J3R36SGJ.js";import{getEnvironmentForKey as E,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as w}from"ox";var b={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},P=6e4,K="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;let r=E(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=b[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${P}ms`))},P);function p(y){let m=y.data;m==null||m.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),m.type==="error"&&m.code===K?s({fatal:!0}):m.type==="error"?o(new Error(m.error)):s({value:m.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield w.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield w.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};d([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
1
+ import{a as v}from"./chunk-IOSADDL5.js";import{a as l}from"./chunk-HZVB2TS2.js";import{c as d,g as n}from"./chunk-J3R36SGJ.js";import{getEnvironmentForKey as E,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as w}from"ox";var b={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},P=6e4,K="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;let r=E(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=b[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${P}ms`))},P);function p(y){let m=y.data;m==null||m.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),m.type==="error"&&m.code===K?s({fatal:!0}):m.type==="error"?o(new Error(m.error)):s({value:m.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield w.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield w.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};d([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk6OELZRMTcjs = require('./chunk-6OELZRMT.cjs');var _chunkHFQTOJEGcjs = require('./chunk-HFQTOJEG.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunk6OELZRMTcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=_bs582.default.decode(n),y=_web3js.VersionedTransaction.deserialize(m).message.serialize();_chunkHFQTOJEGcjs.a.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(y)),encoding:"base58"}},options:_chunk6OELZRMTcjs.b});if(_chunkHFQTOJEGcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkPGAG6P4Qcjs = require('./chunk-PGAG6P4Q.cjs');var _chunkIR6H3POTcjs = require('./chunk-IR6H3POT.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var g=class c extends _chunkPGAG6P4Qcjs.a{constructor(n){super(n)}signMessage(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=_bs582.default.decode(n),y=_web3js.VersionedTransaction.deserialize(m).message.serialize();_chunkIR6H3POTcjs.a.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:_bs582.default.encode(new Uint8Array(y)),encoding:"base58"}},options:_chunkPGAG6P4Qcjs.b});if(_chunkIR6H3POTcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;