@crossmint/wallets-sdk 1.5.2 → 1.6.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 (162) hide show
  1. package/dist/api/__tests__/test-utils.cjs +1 -1
  2. package/dist/api/__tests__/test-utils.js +1 -1
  3. package/dist/api/client.cjs +1 -1
  4. package/dist/api/client.js +1 -1
  5. package/dist/api/index.cjs +1 -1
  6. package/dist/api/index.js +1 -1
  7. package/dist/chains/chains.cjs +1 -1
  8. package/dist/chains/chains.js +1 -1
  9. package/dist/{chunk-2O6HQK34.js → chunk-2L3ALABB.js} +1 -1
  10. package/dist/chunk-2YZQ4YYU.cjs +1 -0
  11. package/dist/chunk-3EQ6LL7S.cjs +3 -0
  12. package/dist/chunk-3HGHIZUM.js +1 -0
  13. package/dist/chunk-54AGQUDX.js +1 -0
  14. package/dist/{chunk-RJ24JXFS.js → chunk-55VVCZZI.js} +1 -1
  15. package/dist/{chunk-MDINF2FR.js → chunk-5LN6KXFF.js} +1 -1
  16. package/dist/{chunk-M5BPFF6N.js → chunk-6MG5B26I.js} +1 -1
  17. package/dist/chunk-6SVERTV3.js +1 -0
  18. package/dist/{chunk-42JFJWEX.js → chunk-6ZO5Q6UF.js} +1 -1
  19. package/dist/chunk-7KVV2MJH.js +1 -0
  20. package/dist/{chunk-W4RKYWY3.cjs → chunk-AEI5YK44.cjs} +1 -1
  21. package/dist/chunk-AHCLROCH.cjs +1 -0
  22. package/dist/{chunk-2MSS6HZD.cjs → chunk-B3LVLCQQ.cjs} +1 -1
  23. package/dist/{chunk-6BERCSZQ.cjs → chunk-B7EMVOYB.cjs} +1 -1
  24. package/dist/chunk-BDDLUP62.cjs +1 -0
  25. package/dist/{chunk-PG6S5LNU.js → chunk-CMGXTYC7.js} +1 -1
  26. package/dist/{chunk-GDEOTJEZ.cjs → chunk-CNF7UPOI.cjs} +1 -1
  27. package/dist/{chunk-KHFRALRB.cjs → chunk-DGBLZC3D.cjs} +1 -1
  28. package/dist/{chunk-TLLXWU3N.js → chunk-DOIIACVT.js} +1 -1
  29. package/dist/chunk-E3H6RZHM.js +1 -0
  30. package/dist/chunk-EGL3LHTY.js +1 -0
  31. package/dist/{chunk-FF2GQYF4.js → chunk-FFYOHSGP.js} +1 -1
  32. package/dist/chunk-FJPAMX7L.js +1 -0
  33. package/dist/chunk-GSNFNRH2.cjs +1 -0
  34. package/dist/{chunk-4TGSG3UZ.cjs → chunk-GUP2PIJO.cjs} +1 -1
  35. package/dist/{chunk-X5JWMXUK.js → chunk-GZCR52HV.js} +1 -1
  36. package/dist/{chunk-CAQZTHJB.cjs → chunk-HHVIOE43.cjs} +1 -1
  37. package/dist/chunk-IB2JS6WX.js +1 -0
  38. package/dist/{chunk-EOBMHTZD.js → chunk-IDNVSMIL.js} +1 -1
  39. package/dist/{chunk-VUC4UU5M.cjs → chunk-LR4JIGWX.cjs} +1 -1
  40. package/dist/chunk-LWA3SX6Z.cjs +1 -0
  41. package/dist/{chunk-JGWGYONV.js → chunk-MB6IDU3A.js} +1 -1
  42. package/dist/chunk-MRLWVOFK.cjs +1 -0
  43. package/dist/{chunk-A5GN63FT.cjs → chunk-MTT7UFU3.cjs} +1 -1
  44. package/dist/chunk-MVQ24ML4.cjs +1 -0
  45. package/dist/chunk-NOYMQ6J5.cjs +1 -0
  46. package/dist/{chunk-YM3T5Z2Z.js → chunk-NPIMFXJ5.js} +1 -1
  47. package/dist/chunk-NZXYWQE5.js +1 -0
  48. package/dist/{chunk-Q4EIDR3A.cjs → chunk-OIZ7ZSZ7.cjs} +1 -1
  49. package/dist/chunk-OOU7QZJ5.js +1 -0
  50. package/dist/{chunk-6EUBBDIV.cjs → chunk-PEXE6P6S.cjs} +1 -1
  51. package/dist/{chunk-YVDA37CD.cjs → chunk-PTLVEO7E.cjs} +1 -1
  52. package/dist/{chunk-VVX6XW5L.cjs → chunk-Q2RVHFFW.cjs} +1 -1
  53. package/dist/{chunk-W5SV3EQJ.cjs → chunk-Q34P6JFX.cjs} +1 -1
  54. package/dist/{chunk-LDOMAUCN.js → chunk-QRCGBBPU.js} +1 -1
  55. package/dist/chunk-QT4XQUYM.cjs +1 -0
  56. package/dist/chunk-QVM2QBXE.cjs +1 -0
  57. package/dist/{chunk-6X5JEJD7.js → chunk-R3SPSOEE.js} +1 -1
  58. package/dist/{chunk-SYQ5Q3WU.js → chunk-SR3F22XV.js} +1 -1
  59. package/dist/{chunk-E4EOD7MP.cjs → chunk-UV6RKGBY.cjs} +1 -1
  60. package/dist/chunk-X6CVAVC7.cjs +1 -0
  61. package/dist/chunk-XYTDDT77.js +3 -0
  62. package/dist/{chunk-R52TCQ54.js → chunk-YBHPAOH7.js} +1 -1
  63. package/dist/{chunk-ENZ7MQIX.js → chunk-YHD5NORG.js} +1 -1
  64. package/dist/{chunk-4HWSBR3N.cjs → chunk-ZMP33IOH.cjs} +1 -1
  65. package/dist/index.cjs +1 -1
  66. package/dist/index.d.cts +1 -1
  67. package/dist/index.d.ts +1 -1
  68. package/dist/index.js +1 -1
  69. package/dist/logger/index.cjs +1 -1
  70. package/dist/logger/index.js +1 -1
  71. package/dist/logger/init.cjs +1 -1
  72. package/dist/logger/init.js +1 -1
  73. package/dist/sdk.cjs +1 -1
  74. package/dist/sdk.js +1 -1
  75. package/dist/signers/index.cjs +1 -1
  76. package/dist/signers/index.js +1 -1
  77. package/dist/signers/non-custodial/index.cjs +1 -1
  78. package/dist/signers/non-custodial/index.js +1 -1
  79. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  80. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  81. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  82. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  83. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  84. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  85. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  86. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  87. package/dist/signers/server/assemble-server-signer.cjs +1 -1
  88. package/dist/signers/server/assemble-server-signer.js +1 -1
  89. package/dist/signers/server/evm-server-signer.cjs +1 -1
  90. package/dist/signers/server/evm-server-signer.js +1 -1
  91. package/dist/signers/server/helpers/derive-server-signer.cjs +1 -1
  92. package/dist/signers/server/helpers/derive-server-signer.js +1 -1
  93. package/dist/signers/server/helpers/index.cjs +1 -1
  94. package/dist/signers/server/helpers/index.js +1 -1
  95. package/dist/signers/server/index.cjs +1 -1
  96. package/dist/signers/server/index.js +1 -1
  97. package/dist/signers/server/solana-server-signer.cjs +1 -1
  98. package/dist/signers/server/solana-server-signer.js +1 -1
  99. package/dist/signers/server/stellar-server-signer.cjs +1 -1
  100. package/dist/signers/server/stellar-server-signer.js +1 -1
  101. package/dist/signers/solana-external-wallet.cjs +1 -1
  102. package/dist/signers/solana-external-wallet.js +1 -1
  103. package/dist/utils/constants.cjs +1 -1
  104. package/dist/utils/constants.js +1 -1
  105. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  106. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  107. package/dist/utils/device-signers/index.cjs +1 -1
  108. package/dist/utils/device-signers/index.js +1 -1
  109. package/dist/utils/device-signers/storage-partitioning.cjs +1 -0
  110. package/dist/utils/device-signers/storage-partitioning.d.cts +13 -0
  111. package/dist/utils/device-signers/storage-partitioning.d.ts +13 -0
  112. package/dist/utils/device-signers/storage-partitioning.js +1 -0
  113. package/dist/utils/errors.cjs +1 -1
  114. package/dist/utils/errors.d.cts +11 -2
  115. package/dist/utils/errors.d.ts +11 -2
  116. package/dist/utils/errors.js +1 -1
  117. package/dist/utils/secure-wipe.cjs +1 -0
  118. package/dist/utils/secure-wipe.d.cts +7 -0
  119. package/dist/utils/secure-wipe.d.ts +7 -0
  120. package/dist/utils/secure-wipe.js +1 -0
  121. package/dist/utils/server-key-derivation.cjs +1 -1
  122. package/dist/utils/server-key-derivation.js +1 -1
  123. package/dist/utils/server-signers/createServerSigner.cjs +1 -1
  124. package/dist/utils/server-signers/createServerSigner.js +1 -1
  125. package/dist/utils/server-signers/index.cjs +1 -1
  126. package/dist/utils/server-signers/index.js +1 -1
  127. package/dist/utils/signer-validation.cjs +1 -1
  128. package/dist/utils/signer-validation.js +1 -1
  129. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  130. package/dist/wallets/__tests__/test-helpers.js +1 -1
  131. package/dist/wallets/evm.cjs +1 -1
  132. package/dist/wallets/evm.js +1 -1
  133. package/dist/wallets/solana.cjs +1 -1
  134. package/dist/wallets/solana.js +1 -1
  135. package/dist/wallets/stellar.cjs +1 -1
  136. package/dist/wallets/stellar.js +1 -1
  137. package/dist/wallets/wallet-factory.cjs +1 -1
  138. package/dist/wallets/wallet-factory.js +1 -1
  139. package/dist/wallets/wallet.cjs +1 -1
  140. package/dist/wallets/wallet.d.cts +12 -6
  141. package/dist/wallets/wallet.d.ts +12 -6
  142. package/dist/wallets/wallet.js +1 -1
  143. package/package.json +4 -4
  144. package/dist/chunk-3SVXPFSP.cjs +0 -1
  145. package/dist/chunk-3VRN3GKQ.js +0 -1
  146. package/dist/chunk-4DJWSV7I.cjs +0 -1
  147. package/dist/chunk-5OYPWGMX.js +0 -1
  148. package/dist/chunk-BITOMWYZ.js +0 -1
  149. package/dist/chunk-GZP2JQ6P.cjs +0 -1
  150. package/dist/chunk-HSLZH2ZC.cjs +0 -1
  151. package/dist/chunk-MYJFCP65.js +0 -1
  152. package/dist/chunk-N355UETO.js +0 -1
  153. package/dist/chunk-OWQZPI3U.cjs +0 -1
  154. package/dist/chunk-PMUGCRPI.js +0 -3
  155. package/dist/chunk-QLEJSDVV.js +0 -1
  156. package/dist/chunk-QVNXEPOZ.cjs +0 -3
  157. package/dist/chunk-VDNAVMQQ.cjs +0 -1
  158. package/dist/chunk-XNZLCUTY.js +0 -1
  159. package/dist/chunk-YF5G4U6L.cjs +0 -1
  160. package/dist/chunk-YGL4ITFK.cjs +0 -1
  161. package/dist/chunk-YN4JN7PO.js +0 -1
  162. package/dist/chunk-ZF4VCMLC.cjs +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ33QM2IDcjs = require('../../chunk-J33QM2ID.cjs');var _chunk4TGSG3UZcjs = require('../../chunk-4TGSG3UZ.cjs');require('../../chunk-OWQZPI3U.cjs');require('../../chunk-VUC4UU5M.cjs');require('../../chunk-VVX6XW5L.cjs');var _chunk2GKPWQBQcjs = require('../../chunk-2GKPWQBQ.cjs');var _vitest = require('vitest');var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:_vitest.vi.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j= exports.createMockSuccessResponse =e=>P({data:e}),b= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B= exports.createMockCrossmint =(e={})=>{let t=_chunk2GKPWQBQcjs.a.call(void 0, {apiKey:_chunkJ33QM2IDcjs.m},e);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{setJwt:_vitest.vi.fn().mockReturnThis()})},L= exports.createTestApiClient =e=>new (0, _chunk4TGSG3UZcjs.a)(e||B()),K= exports.createServerSideApiClient =()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},Y= exports.extractFetchCall =e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N= exports.expectRequestPath =(e,t)=>{_vitest.expect.call(void 0, e==null?void 0:e.path).toBe(t)},V= exports.expectCommonHeaders =e=>{_vitest.expect.call(void 0, e["Content-Type"]).toBe("application/json")},q= exports.expectRequestBody =(e,t)=>{_vitest.expect.call(void 0, e.body).toBe(JSON.stringify(t))},z= exports.validateRequest =(e,t,n)=>{_vitest.expect.call(void 0, e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},X= exports.testHttpErrorResponse =(e,t,n,s)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();_vitest.expect.call(void 0, l(a)).toBe(!0),l(a)&&(_vitest.expect.call(void 0, a.error).toBe(!0),n.message&&_vitest.expect.call(void 0, a.message).toBe(n.message))}),Z= exports.testCommonHttpErrors =(s,a,...o)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of _chunkJ33QM2IDcjs.a){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();_vitest.expect.call(void 0, l(m)).toBe(!0)}}),Q= exports.testNetworkError =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Network error")}),ee= exports.testInvalidJsonResponse =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let n={json:_vitest.vi.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield _vitest.expect.call(void 0, e()).rejects.toThrow()}),te= exports.testTimeoutError =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Request timeout")}),ne= exports.testMalformedResponse =(e,t,n)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();_vitest.expect.call(void 0, s).toEqual(n)}),se= exports.createMockWalletResponse =(e={})=>_chunk2GKPWQBQcjs.a.call(void 0, {address:_chunkJ33QM2IDcjs.b.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:_chunkJ33QM2IDcjs.k.EVM_TEST}}},e),oe= exports.createMockSendResponse =(e={})=>_chunk2GKPWQBQcjs.a.call(void 0, {id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),re= exports.isValidEthereumAddress =e=>/^0x[a-fA-F0-9]{40}$/.test(e),ae= exports.isValidSolanaAddress =e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ie= exports.createIntegrationApiClient =(e,t,n={})=>{let s=_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {apiKey:e},t&&{overrideBaseUrl:t}),n),a=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},s),{setJwt:()=>a});return new (0, _chunk4TGSG3UZcjs.a)(a)},v= exports.TestDataFactory =class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function ce(s,a){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(_chunk2GKPWQBQcjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function pe(e,t,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function le(e,t){_vitest.expect.call(void 0, l(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function ue(e){_vitest.expect.call(void 0, C(e)).toBe(!0)}function de(e){_vitest.expect.call(void 0, $(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(_chunkJ33QM2IDcjs.i),c}),U= exports.approveTransaction =(a,o,c,...g)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,[a,o,c,...g],function*(e,t,n,s=_chunkJ33QM2IDcjs.l.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),me= exports.fundWalletAndWait =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){return I(e,t,n,s,a)}),fe= exports.sendTokenAndApprove =(e,t,n,s,a)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),ge= exports.ensureWalletFunded =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});exports.TestDataFactory = v; exports.approveTransaction = U; exports.createIntegrationApiClient = ie; exports.createMockCrossmint = B; exports.createMockErrorResponse = b; exports.createMockResponse = P; exports.createMockSendResponse = oe; exports.createMockSuccessResponse = j; exports.createMockWalletResponse = se; exports.createServerSideApiClient = K; exports.createTestApiClient = L; exports.createTestWallet = pe; exports.delay = x; exports.ensureWalletExists = ce; exports.ensureWalletFunded = ge; exports.expectCommonHeaders = V; exports.expectErrorResponse = le; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = ue; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = l; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = C; exports.isValidEthereumAddress = re; exports.isValidSolanaAddress = ae; exports.sendTokenAndApprove = fe; exports.testCommonHttpErrors = Z; exports.testHttpErrorResponse = X; exports.testInvalidJsonResponse = ee; exports.testMalformedResponse = ne; exports.testNetworkError = Q; exports.testTimeoutError = te; exports.validateRequest = z;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ33QM2IDcjs = require('../../chunk-J33QM2ID.cjs');var _chunkGUP2PIJOcjs = require('../../chunk-GUP2PIJO.cjs');require('../../chunk-QVM2QBXE.cjs');require('../../chunk-LR4JIGWX.cjs');require('../../chunk-Q2RVHFFW.cjs');var _chunk2GKPWQBQcjs = require('../../chunk-2GKPWQBQ.cjs');var _vitest = require('vitest');var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:_vitest.vi.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j= exports.createMockSuccessResponse =e=>P({data:e}),b= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B= exports.createMockCrossmint =(e={})=>{let t=_chunk2GKPWQBQcjs.a.call(void 0, {apiKey:_chunkJ33QM2IDcjs.m},e);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{setJwt:_vitest.vi.fn().mockReturnThis()})},L= exports.createTestApiClient =e=>new (0, _chunkGUP2PIJOcjs.a)(e||B()),K= exports.createServerSideApiClient =()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},Y= exports.extractFetchCall =e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N= exports.expectRequestPath =(e,t)=>{_vitest.expect.call(void 0, e==null?void 0:e.path).toBe(t)},V= exports.expectCommonHeaders =e=>{_vitest.expect.call(void 0, e["Content-Type"]).toBe("application/json")},q= exports.expectRequestBody =(e,t)=>{_vitest.expect.call(void 0, e.body).toBe(JSON.stringify(t))},z= exports.validateRequest =(e,t,n)=>{_vitest.expect.call(void 0, e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},X= exports.testHttpErrorResponse =(e,t,n,s)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();_vitest.expect.call(void 0, l(a)).toBe(!0),l(a)&&(_vitest.expect.call(void 0, a.error).toBe(!0),n.message&&_vitest.expect.call(void 0, a.message).toBe(n.message))}),Z= exports.testCommonHttpErrors =(s,a,...o)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of _chunkJ33QM2IDcjs.a){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();_vitest.expect.call(void 0, l(m)).toBe(!0)}}),Q= exports.testNetworkError =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Network error")}),ee= exports.testInvalidJsonResponse =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let n={json:_vitest.vi.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield _vitest.expect.call(void 0, e()).rejects.toThrow()}),te= exports.testTimeoutError =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Request timeout")}),ne= exports.testMalformedResponse =(e,t,n)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();_vitest.expect.call(void 0, s).toEqual(n)}),se= exports.createMockWalletResponse =(e={})=>_chunk2GKPWQBQcjs.a.call(void 0, {address:_chunkJ33QM2IDcjs.b.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:_chunkJ33QM2IDcjs.k.EVM_TEST}}},e),oe= exports.createMockSendResponse =(e={})=>_chunk2GKPWQBQcjs.a.call(void 0, {id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),re= exports.isValidEthereumAddress =e=>/^0x[a-fA-F0-9]{40}$/.test(e),ae= exports.isValidSolanaAddress =e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ie= exports.createIntegrationApiClient =(e,t,n={})=>{let s=_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {apiKey:e},t&&{overrideBaseUrl:t}),n),a=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},s),{setJwt:()=>a});return new (0, _chunkGUP2PIJOcjs.a)(a)},v= exports.TestDataFactory =class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function ce(s,a){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(_chunk2GKPWQBQcjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function pe(e,t,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function le(e,t){_vitest.expect.call(void 0, l(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function ue(e){_vitest.expect.call(void 0, C(e)).toBe(!0)}function de(e){_vitest.expect.call(void 0, $(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(_chunkJ33QM2IDcjs.i),c}),U= exports.approveTransaction =(a,o,c,...g)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,[a,o,c,...g],function*(e,t,n,s=_chunkJ33QM2IDcjs.l.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),me= exports.fundWalletAndWait =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){return I(e,t,n,s,a)}),fe= exports.sendTokenAndApprove =(e,t,n,s,a)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),ge= exports.ensureWalletFunded =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});exports.TestDataFactory = v; exports.approveTransaction = U; exports.createIntegrationApiClient = ie; exports.createMockCrossmint = B; exports.createMockErrorResponse = b; exports.createMockResponse = P; exports.createMockSendResponse = oe; exports.createMockSuccessResponse = j; exports.createMockWalletResponse = se; exports.createServerSideApiClient = K; exports.createTestApiClient = L; exports.createTestWallet = pe; exports.delay = x; exports.ensureWalletExists = ce; exports.ensureWalletFunded = ge; exports.expectCommonHeaders = V; exports.expectErrorResponse = le; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = ue; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = l; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = C; exports.isValidEthereumAddress = re; exports.isValidSolanaAddress = ae; exports.sendTokenAndApprove = fe; exports.testCommonHttpErrors = Z; exports.testHttpErrorResponse = X; exports.testInvalidJsonResponse = ee; exports.testMalformedResponse = ne; exports.testNetworkError = Q; exports.testTimeoutError = te; exports.validateRequest = z;
@@ -1 +1 @@
1
- import{a as A,b as F,i as R,j as W,k as E,l as M,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-42JFJWEX.js";import"../../chunk-5OYPWGMX.js";import"../../chunk-SYQ5Q3WU.js";import"../../chunk-YN4JN7PO.js";import{a as p,b as k,g as i}from"../../chunk-J3R36SGJ.js";import{expect as r,vi as y}from"vitest";var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>P({data:e}),b=(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B=(e={})=>{let t=p({apiKey:S},e);return k(p({},t),{setJwt:y.fn().mockReturnThis()})},L=e=>new w(e||B()),Y=()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},z=e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N=(e,t)=>{r(e==null?void 0:e.path).toBe(t)},V=e=>{r(e["Content-Type"]).toBe("application/json")},q=(e,t)=>{r(e.body).toBe(JSON.stringify(t))},X=(e,t,n)=>{r(e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},Z=(e,t,n,s)=>i(void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();r(l(a)).toBe(!0),l(a)&&(r(a.error).toBe(!0),n.message&&r(a.message).toBe(n.message))}),Q=(s,a,...o)=>i(void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of A){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();r(l(m)).toBe(!0)}}),ee=(e,t)=>i(void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield r(e()).rejects.toThrow("Network error")}),te=(e,t)=>i(void 0,null,function*(){let n={json:y.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield r(e()).rejects.toThrow()}),ne=(e,t)=>i(void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield r(e()).rejects.toThrow("Request timeout")}),se=(e,t,n)=>i(void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();r(s).toEqual(n)}),oe=(e={})=>p({address:F.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:E.EVM_TEST}}},e),re=(e={})=>p({id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),ae=e=>/^0x[a-fA-F0-9]{40}$/.test(e),ie=e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ce=(e,t,n={})=>{let s=p(p({apiKey:e},t&&{overrideBaseUrl:t}),n),a=k(p({},s),{setJwt:()=>a});return new w(a)},v=class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function pe(s,a){return i(this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function le(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function ue(e,t){r(l(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(C(e)).toBe(!0)}function me(e){r($(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(R),c}),U=(a,o,c,...g)=>i(void 0,[a,o,c,...g],function*(e,t,n,s=M.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(W);continue}yield x(R)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),fe=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){return I(e,t,n,s,a)}),ge=(e,t,n,s,a)=>i(void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),Te=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});export{v as TestDataFactory,U as approveTransaction,ce as createIntegrationApiClient,B as createMockCrossmint,b as createMockErrorResponse,P as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,le as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,ue as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,l as isErrorResponse,$ as isSuccessTransactionResponse,C as isSuccessWalletResponse,ae as isValidEthereumAddress,ie as isValidSolanaAddress,ge as sendTokenAndApprove,Q as testCommonHttpErrors,Z as testHttpErrorResponse,te as testInvalidJsonResponse,se as testMalformedResponse,ee as testNetworkError,ne as testTimeoutError,X as validateRequest};
1
+ import{a as A,b as F,i as R,j as W,k as E,l as M,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-6ZO5Q6UF.js";import"../../chunk-EGL3LHTY.js";import"../../chunk-SR3F22XV.js";import"../../chunk-3HGHIZUM.js";import{a as p,b as k,g as i}from"../../chunk-J3R36SGJ.js";import{expect as r,vi as y}from"vitest";var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>P({data:e}),b=(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B=(e={})=>{let t=p({apiKey:S},e);return k(p({},t),{setJwt:y.fn().mockReturnThis()})},L=e=>new w(e||B()),Y=()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},z=e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N=(e,t)=>{r(e==null?void 0:e.path).toBe(t)},V=e=>{r(e["Content-Type"]).toBe("application/json")},q=(e,t)=>{r(e.body).toBe(JSON.stringify(t))},X=(e,t,n)=>{r(e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},Z=(e,t,n,s)=>i(void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();r(l(a)).toBe(!0),l(a)&&(r(a.error).toBe(!0),n.message&&r(a.message).toBe(n.message))}),Q=(s,a,...o)=>i(void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of A){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();r(l(m)).toBe(!0)}}),ee=(e,t)=>i(void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield r(e()).rejects.toThrow("Network error")}),te=(e,t)=>i(void 0,null,function*(){let n={json:y.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield r(e()).rejects.toThrow()}),ne=(e,t)=>i(void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield r(e()).rejects.toThrow("Request timeout")}),se=(e,t,n)=>i(void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();r(s).toEqual(n)}),oe=(e={})=>p({address:F.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:E.EVM_TEST}}},e),re=(e={})=>p({id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),ae=e=>/^0x[a-fA-F0-9]{40}$/.test(e),ie=e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ce=(e,t,n={})=>{let s=p(p({apiKey:e},t&&{overrideBaseUrl:t}),n),a=k(p({},s),{setJwt:()=>a});return new w(a)},v=class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function pe(s,a){return i(this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function le(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function ue(e,t){r(l(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(C(e)).toBe(!0)}function me(e){r($(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(R),c}),U=(a,o,c,...g)=>i(void 0,[a,o,c,...g],function*(e,t,n,s=M.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(W);continue}yield x(R)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),fe=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){return I(e,t,n,s,a)}),ge=(e,t,n,s,a)=>i(void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),Te=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});export{v as TestDataFactory,U as approveTransaction,ce as createIntegrationApiClient,B as createMockCrossmint,b as createMockErrorResponse,P as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,le as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,ue as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,l as isErrorResponse,$ as isSuccessTransactionResponse,C as isSuccessWalletResponse,ae as isValidEthereumAddress,ie as isValidSolanaAddress,ge as sendTokenAndApprove,Q as testCommonHttpErrors,Z as testHttpErrorResponse,te as testInvalidJsonResponse,se as testMalformedResponse,ee as testNetworkError,ne as testTimeoutError,X as validateRequest};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4TGSG3UZcjs = require('../chunk-4TGSG3UZ.cjs');require('../chunk-OWQZPI3U.cjs');require('../chunk-VUC4UU5M.cjs');require('../chunk-VVX6XW5L.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunk4TGSG3UZcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGUP2PIJOcjs = require('../chunk-GUP2PIJO.cjs');require('../chunk-QVM2QBXE.cjs');require('../chunk-LR4JIGWX.cjs');require('../chunk-Q2RVHFFW.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkGUP2PIJOcjs.a;
@@ -1 +1 @@
1
- import{a}from"../chunk-42JFJWEX.js";import"../chunk-5OYPWGMX.js";import"../chunk-SYQ5Q3WU.js";import"../chunk-YN4JN7PO.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
1
+ import{a}from"../chunk-6ZO5Q6UF.js";import"../chunk-EGL3LHTY.js";import"../chunk-SR3F22XV.js";import"../chunk-3HGHIZUM.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var _chunk4TGSG3UZcjs = require('../chunk-4TGSG3UZ.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-OWQZPI3U.cjs');require('../chunk-VUC4UU5M.cjs');require('../chunk-VVX6XW5L.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunk4TGSG3UZcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var _chunkGUP2PIJOcjs = require('../chunk-GUP2PIJO.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-QVM2QBXE.cjs');require('../chunk-LR4JIGWX.cjs');require('../chunk-Q2RVHFFW.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkGUP2PIJOcjs.a;
package/dist/api/index.js CHANGED
@@ -1 +1 @@
1
- import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-42JFJWEX.js";import"../chunk-KBJA7JDT.js";import"../chunk-5OYPWGMX.js";import"../chunk-SYQ5Q3WU.js";import"../chunk-YN4JN7PO.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
1
+ import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-6ZO5Q6UF.js";import"../chunk-KBJA7JDT.js";import"../chunk-EGL3LHTY.js";import"../chunk-SR3F22XV.js";import"../chunk-3HGHIZUM.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkCAQZTHJBcjs = require('../chunk-CAQZTHJB.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-OWQZPI3U.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-VUC4UU5M.cjs');require('../chunk-VVX6XW5L.cjs');require('../chunk-2GKPWQBQ.cjs');exports.isMainnetChain = _chunkCAQZTHJBcjs.c; exports.isTestnetChain = _chunkCAQZTHJBcjs.b; exports.isValidChain = _chunkCAQZTHJBcjs.e; exports.mainnetToTestnet = _chunkCAQZTHJBcjs.d; exports.toViemChain = _chunkCAQZTHJBcjs.a; exports.validateChainForEnvironment = _chunkCAQZTHJBcjs.f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkHHVIOE43cjs = require('../chunk-HHVIOE43.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-QVM2QBXE.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-LR4JIGWX.cjs');require('../chunk-Q2RVHFFW.cjs');require('../chunk-2GKPWQBQ.cjs');exports.isMainnetChain = _chunkHHVIOE43cjs.c; exports.isTestnetChain = _chunkHHVIOE43cjs.b; exports.isValidChain = _chunkHHVIOE43cjs.e; exports.mainnetToTestnet = _chunkHHVIOE43cjs.d; exports.toViemChain = _chunkHHVIOE43cjs.a; exports.validateChainForEnvironment = _chunkHHVIOE43cjs.f;
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"../chunk-X5JWMXUK.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-SVIKBM3S.js";import"../chunk-KKQBZXFE.js";import"../chunk-5OYPWGMX.js";import"../chunk-455NK5LB.js";import"../chunk-SYQ5Q3WU.js";import"../chunk-YN4JN7PO.js";import"../chunk-J3R36SGJ.js";export{c as isMainnetChain,b as isTestnetChain,e as isValidChain,d as mainnetToTestnet,a as toViemChain,f as validateChainForEnvironment};
1
+ import{a,b,c,d,e,f}from"../chunk-GZCR52HV.js";import"../chunk-KKQBZXFE.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-SVIKBM3S.js";import"../chunk-EGL3LHTY.js";import"../chunk-455NK5LB.js";import"../chunk-SR3F22XV.js";import"../chunk-3HGHIZUM.js";import"../chunk-J3R36SGJ.js";export{c as isMainnetChain,b as isTestnetChain,e as isValidChain,d as mainnetToTestnet,a as toViemChain,f as validateChainForEnvironment};
@@ -1 +1 @@
1
- import{a as s}from"./chunk-2YLRFJ66.js";import{B as a}from"./chunk-5OYPWGMX.js";import{g as e}from"./chunk-J3R36SGJ.js";import{PublicKey as h,VersionedTransaction as f}from"@solana/web3.js";import o from"bs58";var l=class extends s{constructor(n){super(n),this.onSign=n.onSign}signMessage(){return e(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for solana external wallet signer"))})}signTransaction(n){return e(this,null,function*(){if(this.onSign==null)throw new Error("[SolanaExternalWalletSigner] No onSign callback provided. Pass an onSign callback when configuring the external wallet signer.");let c=o.decode(n),g=f.deserialize(c),t=yield this.onSign(g),d=new h(this._address),i=t.message.staticAccountKeys.findIndex(m=>m.equals(d));if(i===-1)throw new a("Wallet public key not found in transaction signers");let r=t.signatures[i];if(r==null)throw new a("No valid signature found in the transaction");let u=new Uint8Array(Object.values(r));return{signature:o.encode(u)}})}};export{l as a};
1
+ import{a as s}from"./chunk-2YLRFJ66.js";import{C as a}from"./chunk-EGL3LHTY.js";import{g as e}from"./chunk-J3R36SGJ.js";import{PublicKey as h,VersionedTransaction as f}from"@solana/web3.js";import o from"bs58";var l=class extends s{constructor(n){super(n),this.onSign=n.onSign}signMessage(){return e(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for solana external wallet signer"))})}signTransaction(n){return e(this,null,function*(){if(this.onSign==null)throw new Error("[SolanaExternalWalletSigner] No onSign callback provided. Pass an onSign callback when configuring the external wallet signer.");let c=o.decode(n),g=f.deserialize(c),t=yield this.onSign(g),d=new h(this._address),i=t.message.staticAccountKeys.findIndex(m=>m.equals(d));if(i===-1)throw new a("Wallet public key not found in transaction signers");let r=t.signatures[i];if(r==null)throw new a("No valid signature found in the transaction");let u=new Uint8Array(Object.values(r));return{signature:o.encode(u)}})}};export{l as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _hkdf = require('@noble/hashes/hkdf');var _sha2 = require('@noble/hashes/sha2');var _utils = require('@noble/hashes/utils');var m="crossmint",g="xmsk1_";function S(t,r,s,n){let e=d(t),i=_utils.hexToBytes.call(void 0, e),o=u(n),c=`${r}:${s}:${n}-${o}`;return _hkdf.hkdf.call(void 0, _sha2.sha256,i,m,c,32)}function T(t,r,s,n){let e=d(t),i=_utils.hexToBytes.call(void 0, e),o=`${r}:${s}:${n}-alias`,c=_hkdf.hkdf.call(void 0, _sha2.sha256,i,m,o,17);return`s-${_utils.bytesToHex.call(void 0, c).slice(0,34)}`}var a=64;function d(t){let r=t.startsWith(g)?t.slice(g.length):t;if(r.length!==a)throw new Error(`Invalid server signer secret: expected ${a}-char hex string (256-bit), got ${r.length} chars`);return r}function u(t){return t==="solana"||t==="stellar"?"ed25519":"secp256k1"}exports.a = S; exports.b = T;
@@ -0,0 +1,3 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkKXKBZNETcjs = require('./chunk-KXKBZNET.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunkMVQ24ML4cjs = require('./chunk-MVQ24ML4.cjs');var _chunkOIZ7ZSZ7cjs = require('./chunk-OIZ7ZSZ7.cjs');var _chunkZMP33IOHcjs = require('./chunk-ZMP33IOH.cjs');var _chunk5HBCBS5Wcjs = require('./chunk-5HBCBS5W.cjs');var _chunkLWA3SX6Zcjs = require('./chunk-LWA3SX6Z.cjs');var _chunkHHVIOE43cjs = require('./chunk-HHVIOE43.cjs');var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunkQ2RVHFFWcjs = require('./chunk-Q2RVHFFW.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var p,A,f,S,k,y,F,W,E,N,B,q,K,H,R= exports.a =class{constructor(e,r){_chunk2GKPWQBQcjs.e.call(void 0, this,p);_chunk2GKPWQBQcjs.e.call(void 0, this,A);_chunk2GKPWQBQcjs.e.call(void 0, this,f);_chunk2GKPWQBQcjs.e.call(void 0, this,S);_chunk2GKPWQBQcjs.e.call(void 0, this,k);_chunk2GKPWQBQcjs.e.call(void 0, this,y,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,F,!1);_chunk2GKPWQBQcjs.e.call(void 0, this,W,null);_chunk2GKPWQBQcjs.e.call(void 0, this,E,null);_chunk2GKPWQBQcjs.e.call(void 0, this,N,null);_chunk2GKPWQBQcjs.e.call(void 0, this,B,[]);_chunk2GKPWQBQcjs.e.call(void 0, this,q);_chunk2GKPWQBQcjs.e.call(void 0, this,K,null);_chunk2GKPWQBQcjs.e.call(void 0, this,H,!1);let{chain:i,address:n,owner:o,options:g,alias:s,recovery:l,apiRecoveryServerSignerAddress:c,apiDelegatedServerSignerAddresses:h,signers:v,signer:w}=e;_chunk2GKPWQBQcjs.f.call(void 0, this,f,r),this.chain=i,this.address=n,this.owner=o,_chunk2GKPWQBQcjs.f.call(void 0, this,A,g),this.alias=s,_chunk2GKPWQBQcjs.f.call(void 0, this,S,l),c!=null?_chunk2GKPWQBQcjs.f.call(void 0, this,N,c):l.type==="server"&&_chunk5HBCBS5Wcjs.e.call(void 0, l)&&_chunk2GKPWQBQcjs.f.call(void 0, this,N,l.address),_chunk2GKPWQBQcjs.f.call(void 0, this,B,h!=null?h:[]),_chunk2GKPWQBQcjs.f.call(void 0, this,k,v!=null?v:[]),_chunk2GKPWQBQcjs.f.call(void 0, this,p,w),_chunk2GKPWQBQcjs.f.call(void 0, this,q,this.initDefaultSigner())}get signer(){return _chunk2GKPWQBQcjs.d.call(void 0, this,p)}waitForInit(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,q)})}initDeviceSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;let e=(n=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:n.deviceSignerKeyStorage;if(e==null||_chunk2GKPWQBQcjs.d.call(void 0, this,H))return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(o){_chunkLR4JIGWXcjs.a.error("wallet.initDeviceSigner.error",{error:o}),_chunk2GKPWQBQcjs.f.call(void 0, this,y,!0);return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,y))return;let i=this.buildInternalSignerConfig(r);_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(i,e)),this.isApprovedSignerStatus(_chunk2GKPWQBQcjs.d.call(void 0, this,p).status)||(_chunkLR4JIGWXcjs.a.info("wallet.initDeviceSigner.pendingApproval",{signerLocator:_chunk2GKPWQBQcjs.d.call(void 0, this,p).locator(),status:_chunk2GKPWQBQcjs.d.call(void 0, this,p).status}),_chunk2GKPWQBQcjs.f.call(void 0, this,y,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,F,!1))})}initDefaultSigner(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,p)!=null||(yield this.initDeviceSigner(),_chunk2GKPWQBQcjs.d.call(void 0, this,p)!=null||_chunk2GKPWQBQcjs.d.call(void 0, this,y)))return;let e=_chunk2GKPWQBQcjs.d.call(void 0, this,k).length===0?_chunk2GKPWQBQcjs.d.call(void 0, this,S):_chunk2GKPWQBQcjs.d.call(void 0, this,k).length===1?_chunk2GKPWQBQcjs.d.call(void 0, this,k)[0]:null;if(e==null||!this.isAutoAssemblableSignerConfig(e))return;let r=e===_chunk2GKPWQBQcjs.d.call(void 0, this,S);try{let i=this.buildInternalSignerConfig(e);_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(i,void 0,{isAdminSigner:r}))}catch(i){_chunkLR4JIGWXcjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunk2GKPWQBQcjs.d.call(void 0, this,S).type,signerCount:_chunk2GKPWQBQcjs.d.call(void 0, this,k).length,error:i})}})}assembleRecoverySignerFallback(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,S)))try{let e=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,S));_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(e,void 0,{isAdminSigner:!0}))}catch(e){_chunkLR4JIGWXcjs.a.warn("wallet.recover.device.unsupportedFallback.autoAssemblyFailed",{recoveryType:_chunk2GKPWQBQcjs.d.call(void 0, this,S).type,error:e})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,S)}static getInitialSigners(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,k)}static getApiRecoveryServerSignerAddress(e){var r;return(r=_chunk2GKPWQBQcjs.d.call(void 0, e,N))!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return _chunk2GKPWQBQcjs.d.call(void 0, e,B)}get apiClient(){return _chunk2GKPWQBQcjs.d.call(void 0, this,f)}get options(){return _chunk2GKPWQBQcjs.d.call(void 0, this,A)}deriveServerSignerCandidates(e){return _chunkOIZ7ZSZ7cjs.c.call(void 0, e,this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,f).projectId,_chunk2GKPWQBQcjs.d.call(void 0, this,f).environment)}resolveServerSignerDerivation(e){var o;if(_chunk5HBCBS5Wcjs.e.call(void 0, e)){if(_chunk2GKPWQBQcjs.d.call(void 0, this,E)!=null)return _chunk2GKPWQBQcjs.d.call(void 0, this,E);throw new Error('Cannot resolve server signer derivation: no secret available and no cached recovery resolution. Call wallet.useSigner({ type: "server", secret: ... }) first.')}let{primary:r,legacy:i}=this.deriveServerSignerCandidates(e),n=(o=_chunk2GKPWQBQcjs.d.call(void 0, this,W))!=null?o:_chunk2GKPWQBQcjs.d.call(void 0, this,E);if(n!=null){let g=n.derivedAddress;if(g===r.derivedAddress||i!=null&&g===i.derivedAddress)return _chunkLWA3SX6Zcjs.a.call(void 0, r.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),n}if(i!=null){if(i.derivedAddress===_chunk2GKPWQBQcjs.d.call(void 0, this,N))return _chunkLWA3SX6Zcjs.a.call(void 0, r.derivedKeyBytes),i;if(_chunk2GKPWQBQcjs.d.call(void 0, this,k).some(g=>g.type==="server"&&_chunk5HBCBS5Wcjs.e.call(void 0, g)&&g.address===i.derivedAddress)||_chunk2GKPWQBQcjs.d.call(void 0, this,B).includes(i.derivedAddress))return _chunkLWA3SX6Zcjs.a.call(void 0, r.derivedKeyBytes),i;_chunkLWA3SX6Zcjs.a.call(void 0, i.derivedKeyBytes)}return r}resolveServerSignerApiLocator(e){return`server:${this.resolveServerSignerDerivation(e).derivedAddress}`}get recovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,S)}balances(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkLR4JIGWXcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),i;switch(this.chain){case"solana":i="sol";break;case"stellar":i="xlm";break;default:i="eth";break}let n=[i,"usdc",...e!=null?e:[]],o=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getBalance(this.address,{chains:[r],tokens:n});if("error"in o)throw _chunkLR4JIGWXcjs.a.error("wallet.balances.error",{error:o}),new Error(`Failed to get balances for wallet: ${JSON.stringify(o.message)}`);return _chunkLR4JIGWXcjs.a.info("wallet.balances.success"),this.transformBalanceResponse(o,i,e)})}stagingFund(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkLR4JIGWXcjs.a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let i=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in i)throw _chunkLR4JIGWXcjs.a.error("wallet.stagingFund.error",{error:i}),new Error(`Failed to fund wallet: ${JSON.stringify(i.message)}`);return _chunkLR4JIGWXcjs.a.info("wallet.stagingFund.success"),i})}transformBalanceResponse(e,r,i){let n=c=>{var w,m,D,G,U;let h=(w=c.chains)==null?void 0:w[this.chain],v={};return this.chain==="solana"&&h!=null&&"mintHash"in h?v={mintHash:h.mintHash}:this.chain==="stellar"&&h!=null&&"contractId"in h?v={contractId:h.contractId}:h!=null&&"contractAddress"in h&&(v={contractAddress:h.contractAddress}),_chunk2GKPWQBQcjs.a.call(void 0, {symbol:(m=c.symbol)!=null?m:"",name:(D=c.name)!=null?D:"",amount:(G=c.amount)!=null?G:"0",decimals:c.decimals,rawAmount:(U=c.rawAmount)!=null?U:"0"},v)},o=e.find(c=>c.symbol===r),g=e.find(c=>c.symbol==="usdc"),s=e.filter(c=>{var h;return c.symbol!==r&&c.symbol!=="usdc"&&(i==null||i.includes((h=c.symbol)!=null?h:""))}),l=c=>{let h={symbol:c,name:c,amount:"0",decimals:0,rawAmount:"0"},v={};return this.chain==="solana"?v={mintHash:void 0}:this.chain==="stellar"?v={contractId:void 0}:v={contractAddress:void 0},_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},h),v)};return{nativeToken:o!=null?n(o):l(r),usdc:g!=null?n(g):l("usdc"),tokens:s.map(n)}}nfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getNfts(_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{chain:this.chain,address:this.address}))})}transactions(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),i=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in i)throw new Error(`Failed to get transfers: ${JSON.stringify(i.message)}`);return i})}send(e,r,i,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let o=this.resolveChainForEnvironment(),g=me(e),s=Ce(r,o),l=Number(i);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new (0, _chunkQVM2QBXEcjs.v)(`Invalid transfer amount: "${i}". Amount must be a positive number greater than zero.`);_chunkLR4JIGWXcjs.a.info("wallet.send.start",_chunk2GKPWQBQcjs.a.call(void 0, {recipient:g,token:s,amount:i},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let c=this.requireSigner(),h;(n==null?void 0:n.signer)==null?h=c.locator():typeof n.signer=="string"?h=n.signer:h=this.resolveServerSignerApiLocator(n.signer);let v=_chunk2GKPWQBQcjs.a.call(void 0, {recipient:g,amount:i,signer:h},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),w=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).send(this.walletLocator,s,v);if("message"in w)throw _chunkLR4JIGWXcjs.a.error("wallet.send.error",{error:w}),new (0, _chunkQVM2QBXEcjs.w)(`Failed to send token: ${JSON.stringify(w.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return _chunkLR4JIGWXcjs.a.info("wallet.send.prepared",{transactionId:w.id}),{hash:void 0,explorerLink:void 0,transactionId:w.id};let m=yield this.approveTransactionAndWait(w.id);return _chunkLR4JIGWXcjs.a.info("wallet.send.success",{transactionId:w.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(_chunkLR4JIGWXcjs.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 _chunkLR4JIGWXcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkLR4JIGWXcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkLR4JIGWXcjs.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*(){_chunkLR4JIGWXcjs.a.info("wallet.addSigner.start");let i=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return this.withRecoverySigner(()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var h,v,w,m;let n=typeof i=="string"?i:_chunkNX256LAHcjs.a.call(void 0, i),o=yield this.getSignerState(n);if(o.signer!=null){if(this.isApprovedSignerStatus(o.signer.status))return _chunkLR4JIGWXcjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(o.signer,null,r);if(o.pendingOperation!=null)return _chunkLR4JIGWXcjs.a.info("wallet.addSigner.resuming",{operationType:o.pendingOperation.type,operationId:o.pendingOperation.id}),this.completeSignerRegistration(o.signer,o.pendingOperation,r)}let g=typeof i=="string"||i.type==="passkey"?i:i.type==="device"&&"publicKey"in i&&i.publicKey!=null?{type:"device",publicKey:i.publicKey,name:i.name}:_chunkNX256LAHcjs.a.call(void 0, i),s=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).registerSigner(this.walletLocator,_chunk2GKPWQBQcjs.a.call(void 0, {signer:g,chain:this.getSignerRegistrationChain()},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}));if("error"in s)throw _chunkLR4JIGWXcjs.a.error("wallet.addSigner.error",{error:s}),s.code===_chunkQVM2QBXEcjs.k?new (0, _chunkQVM2QBXEcjs.l)(s.message):new (0, _chunkQVM2QBXEcjs.j)(`Failed to register signer: ${JSON.stringify(s.message)}`);let l=_chunkKXKBZNETcjs.b.call(void 0, s,this.chain);if(l==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let c=null;if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in s)||s.transaction==null)throw _chunkLR4JIGWXcjs.a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");c={type:"transaction",id:s.transaction.id}}else{if(!("chains"in s))throw _chunkLR4JIGWXcjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((v=(h=s.chains)==null?void 0:h[this.chain])==null?void 0:v.status)==="failed")throw _chunkLR4JIGWXcjs.a.error("wallet.addSigner.failed",{chain:this.chain,signerType:e.type,signerLocator:n,chainStatus:(w=s.chains)==null?void 0:w[this.chain]}),new (0, _chunkQVM2QBXEcjs.j)(`Signer registration failed for chain ${this.chain} (signer: ${n})`,JSON.stringify((m=s.chains)==null?void 0:m[this.chain]));c=_chunkKXKBZNETcjs.c.call(void 0, s,this.chain)}return this.completeSignerRegistration(l,c,r)}))})}completeSignerRegistration(e,r,i){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i!=null&&i.prepareOnly){if(r==null)return _chunk2GKPWQBQcjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return _chunkLR4JIGWXcjs.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 _chunkLR4JIGWXcjs.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),_chunkLR4JIGWXcjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkLR4JIGWXcjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else _chunkLR4JIGWXcjs.a.info("wallet.addSigner.success");return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=this.resolveSignerLocator(e);return _chunkLR4JIGWXcjs.a.info("wallet.removeSigner.start",{signerLocator:i}),this.withRecoverySigner(()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).removeSigner(this.walletLocator,i,{chain:this.getSignerRegistrationChain()});if("error"in n)throw _chunkLR4JIGWXcjs.a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let o=n.id;return r!=null&&r.prepareOnly?(_chunkLR4JIGWXcjs.a.info("wallet.removeSigner.prepared",{transactionId:o}),{transactionId:o,status:void 0}):(yield this.approveTransactionAndWait(o),_chunkLR4JIGWXcjs.a.info("wallet.removeSigner.success",{transactionId:o}),{transactionId:o,status:"success"})}))})}useSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o;_chunkLR4JIGWXcjs.a.info("wallet.useSigner.start"),e.type==="server"&&(_chunkLWA3SX6Zcjs.a.call(void 0, (o=_chunk2GKPWQBQcjs.d.call(void 0, this,W))==null?void 0:o.derivedKeyBytes),_chunk2GKPWQBQcjs.f.call(void 0, this,W,null)),this.validateSignerInput(e);let r=!1;e.type==="device"?yield this.resolveDeviceSignerAvailability(e):r=yield this.resolveNonDeviceSigner(e);let i=this.buildInternalSignerConfig(e),n=_chunkNX256LAHcjs.a.call(void 0, e);_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner(i,void 0,{isAdminSigner:r})),_chunkLR4JIGWXcjs.a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,y,!1),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,y,!1),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return _chunk2GKPWQBQcjs.f.call(void 0, this,y,!1),!1;if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.f.call(void 0, this,y,!1),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let{primary:r,legacy:i}=this.deriveServerSignerCandidates(e),n=yield this.signers();if(n.some(g=>g.locator===`server:${r.derivedAddress}`))return _chunk2GKPWQBQcjs.f.call(void 0, this,W,r),this.wipeNonSelectedCandidate(r,i),_chunk2GKPWQBQcjs.f.call(void 0, this,y,!1),!1;if(i!=null&&n.some(g=>g.locator===`server:${i.derivedAddress}`))return _chunk2GKPWQBQcjs.f.call(void 0, this,W,i),this.wipeNonSelectedCandidate(i,r),_chunk2GKPWQBQcjs.f.call(void 0, this,y,!1),!1;if(this.isRecoverySigner(e))return _chunk2GKPWQBQcjs.d.call(void 0, this,N)!=null&&i!=null&&i.derivedAddress===_chunk2GKPWQBQcjs.d.call(void 0, this,N)?(_chunk2GKPWQBQcjs.f.call(void 0, this,E,i),this.wipeNonSelectedCandidate(i,r)):(_chunk2GKPWQBQcjs.f.call(void 0, this,E,r),this.wipeNonSelectedCandidate(r,i)),this.stripSecretFromRecovery(),_chunk2GKPWQBQcjs.f.call(void 0, this,y,!1),!0;let o=i!=null?`"server:${r.derivedAddress}" or "server:${i.derivedAddress}"`:`"server:${r.derivedAddress}"`;throw _chunkLWA3SX6Zcjs.a.call(void 0, r.derivedKeyBytes,i==null?void 0:i.derivedKeyBytes),new Error(`Signer ${o} is not registered in this wallet.`)})}wipeNonSelectedCandidate(e,r){r!=null&&r!==e&&_chunkLWA3SX6Zcjs.a.call(void 0, r.derivedKeyBytes)}stripSecretFromRecovery(){_chunk2GKPWQBQcjs.d.call(void 0, this,S)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,S).type==="server"&&!_chunk5HBCBS5Wcjs.e.call(void 0, _chunk2GKPWQBQcjs.d.call(void 0, this,S))&&_chunk2GKPWQBQcjs.d.call(void 0, this,E)!=null&&_chunk2GKPWQBQcjs.f.call(void 0, this,S,{type:"server",address:_chunk2GKPWQBQcjs.d.call(void 0, this,E).derivedAddress})}tryAutoSelectPasskey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=(yield this.signers()).filter(n=>n.type==="passkey");if(i.length===0)return!1;if(i.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=i[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):_chunkNX256LAHcjs.a.call(void 0, e)}getSignerRegistrationChain(){if(!(this.chain==="solana"||this.chain==="stellar"))return this.chain}withRecoverySigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;let r=this.signer;if(_chunk5HBCBS5Wcjs.e.call(void 0, _chunk2GKPWQBQcjs.d.call(void 0, this,S))&&_chunk2GKPWQBQcjs.d.call(void 0, this,E)==null)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,S)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,S).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,S)))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let i=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,S));_chunk2GKPWQBQcjs.f.call(void 0, this,p,_chunkMVQ24ML4cjs.a.call(void 0, this.chain,i,(n=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:n.deviceSignerKeyStorage));try{return yield e()}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,p,r)}})}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.signers()).some(i=>i.locator===e)})}isSignerApproved(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;let r=yield this.getSignerState(e);return this.isApprovedSignerStatus((i=r.signer)==null?void 0:i.status)})}isApprovedSignerStatus(e){return e==="success"||e==="active"}needsRecovery(){return _chunk2GKPWQBQcjs.d.call(void 0, this,y)}recover(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o,g;if(_chunkLR4JIGWXcjs.a.info("wallet.recover.start"),_chunk2GKPWQBQcjs.d.call(void 0, this,F)){_chunkLR4JIGWXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,H)){_chunkLR4JIGWXcjs.a.info("wallet.recover.skipped",{reason:"device signer not supported (cached)"}),_chunk2GKPWQBQcjs.f.call(void 0, this,y,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,F,!0);return}let e=()=>{_chunk2GKPWQBQcjs.f.call(void 0, this,y,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,F,!0)};if(((o=_chunk2GKPWQBQcjs.d.call(void 0, this,p))==null?void 0:o.type)==="device"&&(yield this.checkAndResumeDeviceSigner(_chunk2GKPWQBQcjs.d.call(void 0, this,p)))){e();return}if(_chunk2GKPWQBQcjs.d.call(void 0, this,p)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,p).type!=="device"){_chunkLR4JIGWXcjs.a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),_chunk2GKPWQBQcjs.f.call(void 0, this,y,!1);return}let r=(g=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:g.deviceSignerKeyStorage;if(r==null){if(!_chunk2GKPWQBQcjs.d.call(void 0, this,y))return;throw new Error("Device signer key storage is required to recover a device signer")}let i=yield this.findLocalDeviceSigner(r);if(i!=null&&(yield this.checkAndResumeDeviceSigner(i))){_chunk2GKPWQBQcjs.f.call(void 0, this,p,i),e();let s=i.locator().replace("device:","");try{yield r.mapAddressToKey(this.address,s)}catch(l){_chunkLR4JIGWXcjs.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(s){let l=s instanceof Error&&s.message.toLowerCase().includes("delegated signer")&&s.message.toLowerCase().includes("already")&&s.message.toLowerCase().includes("approved");if(s instanceof _chunkQVM2QBXEcjs.l){_chunkLR4JIGWXcjs.a.info("wallet.recover.device.unsupportedFallback",{signerLocator:n.locator}),yield r.deleteKey(this.address),_chunk2GKPWQBQcjs.f.call(void 0, this,H,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,y,!1),_chunk2GKPWQBQcjs.f.call(void 0, this,F,!0),yield this.assembleRecoverySignerFallback();return}else if(l)_chunkLR4JIGWXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:n.locator});else throw s instanceof _chunk5HBCBS5Wcjs.a||s instanceof Error&&s.name==="AuthRejectedError"?(_chunkLR4JIGWXcjs.a.info("wallet.recover.device.authRejected",{signerLocator:n.locator}),s):s instanceof _chunk5HBCBS5Wcjs.b||s instanceof Error&&s.name==="OtpValidationError"?(_chunkLR4JIGWXcjs.a.warn("wallet.recover.device.otpValidationFailed",{signerLocator:n.locator,code:s instanceof _chunk5HBCBS5Wcjs.b?s.code:void 0}),s):(_chunkLR4JIGWXcjs.a.error("wallet.recover.device.error",{error:s}),yield r.deleteKey(this.address),s)}_chunk2GKPWQBQcjs.f.call(void 0, this,p,yield this.assembleFullSigner({type:"device",locator:n.locator,address:this.address},r)),_chunk2GKPWQBQcjs.d.call(void 0, this,p).type==="device"&&(_chunk2GKPWQBQcjs.d.call(void 0, this,p).status="success"),_chunkLR4JIGWXcjs.a.info("wallet.recover.device.success",{signerLocator:n.locator}),e()})}checkAndResumeDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;if(this.isApprovedSignerStatus(e.status))return _chunkLR4JIGWXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let r=yield this.getSignerState(e.locator());return e.status=(i=r.signer)==null?void 0:i.status,r.pendingOperation!=null?(yield this.resumePendingDeviceSignerApproval(e,r.pendingOperation),!0):this.isApprovedSignerStatus(e.status)?(_chunkLR4JIGWXcjs.a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})}resumePendingDeviceSignerApproval(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o;let i=_chunk2GKPWQBQcjs.d.call(void 0, this,p);if(_chunk5HBCBS5Wcjs.e.call(void 0, _chunk2GKPWQBQcjs.d.call(void 0, this,S))&&_chunk2GKPWQBQcjs.d.call(void 0, this,E)==null)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,S)!=null&&_chunk2GKPWQBQcjs.d.call(void 0, this,S).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,S)))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let n=this.buildInternalSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,S));_chunk2GKPWQBQcjs.f.call(void 0, this,p,_chunkMVQ24ML4cjs.a.call(void 0, this.chain,n,(o=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:o.deviceSignerKeyStorage));try{r.type==="signature"?yield this.approveSignatureAndWait(r.id):yield this.approveTransactionAndWait(r.id)}catch(g){throw _chunk2GKPWQBQcjs.f.call(void 0, this,p,e),g}finally{_chunk2GKPWQBQcjs.d.call(void 0, this,p)!==e&&_chunk2GKPWQBQcjs.f.call(void 0, this,p,i)}e.status="success",_chunkLR4JIGWXcjs.a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0})})}findLocalDeviceSigner(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=(yield this.signers()).filter(n=>n.locator.startsWith("device:"));for(let n of i){let o=n.locator.replace("device:","");try{if(yield e.hasKey(o)){let s=_chunkMVQ24ML4cjs.a.call(void 0, this.chain,{type:"device",locator:n.locator,address:this.address},e);return _chunkLR4JIGWXcjs.a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:n.locator}),s}}catch(g){_chunkLR4JIGWXcjs.a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:n.locator,error:g})}}return null})}signers(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o,g;_chunkLR4JIGWXcjs.a.info("wallet.signers.start");let e=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getWallet(this.walletLocator);if("error"in e)throw _chunkLR4JIGWXcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkQVM2QBXEcjs.e)(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw _chunkLR4JIGWXcjs.a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new (0, _chunkQVM2QBXEcjs.d)(`Wallet type ${e.type} not supported`);let r=(g=(o=e==null?void 0:e.config)==null?void 0:o.delegatedSigners)!=null?g:[],n=(yield Promise.all(r.map(s=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{return(yield this.getSignerState(s.locator)).signer}catch(l){return null}})))).filter(s=>s!=null);return _chunkLR4JIGWXcjs.a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,f).isServerSide)return this.address;{let e;switch(this.chain){case"stellar":e="me:stellar:smart";break;case"solana":e="me:solana:smart";break;default:e="me:evm:smart";break}let r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}requireSigner(){if(_chunk2GKPWQBQcjs.d.call(void 0, this,p)==null)throw _chunk2GKPWQBQcjs.d.call(void 0, this,k).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,S).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,S).type==="external-wallet"||!this.isAutoAssemblableSignerConfig(_chunk2GKPWQBQcjs.d.call(void 0, this,S))?new Error(`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
3
+ Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`):new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available.");return _chunk2GKPWQBQcjs.d.call(void 0, this,p)}preAuthIfNeeded(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield _chunk2GKPWQBQcjs.d.call(void 0, this,q),_chunk2GKPWQBQcjs.d.call(void 0, this,K)==null&&_chunk2GKPWQBQcjs.f.call(void 0, this,K,this.recover());try{yield _chunk2GKPWQBQcjs.d.call(void 0, this,K)}finally{_chunk2GKPWQBQcjs.f.call(void 0, this,K,null)}let e=this.requireSigner();e instanceof _chunkZMP33IOHcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=_chunk2GKPWQBQcjs.d.call(void 0, this,S);if(r==null||r.type!==e.type||e.type==="device")return!1;if(e.type==="passkey")return!0;if(e.type==="server"&&r.type==="server"){let i=s=>{if(_chunk5HBCBS5Wcjs.e.call(void 0, s))return[s.address];let{primary:l,legacy:c}=this.deriveServerSignerCandidates(s),h=[l.derivedAddress];return c!=null&&h.push(c.derivedAddress),_chunkLWA3SX6Zcjs.a.call(void 0, l.derivedKeyBytes,c==null?void 0:c.derivedKeyBytes),h},n=i(e),o=i(r);if(!n.some(s=>o.includes(s)))return!1}else if(_chunkNX256LAHcjs.a.call(void 0, e)!==_chunkNX256LAHcjs.a.call(void 0, r))return!1;return _chunk2GKPWQBQcjs.f.call(void 0, this,S,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 g;let r=(g=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:g.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let i=yield r.getKey(this.address);if(i!=null){e.locator=`device:${i}`;return}let o=(yield this.signers()).filter(s=>s.locator.startsWith("device:"));for(let s of o){let l=s.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=s.locator;return}}_chunk2GKPWQBQcjs.f.call(void 0, this,y,!0),_chunk2GKPWQBQcjs.f.call(void 0, this,F,!1)})}assembleFullSigner(o){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=(n=>(n=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:n.deviceSignerKeyStorage)(),i){var s;let g=_chunkMVQ24ML4cjs.a.call(void 0, this.chain,e,r);if(i!=null&&i.isAdminSigner)g.status="active";else{let l=yield this.getSignerState(g.locator());g.status=(s=l.signer)==null?void 0:s.status}return g})}getSignerState(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;try{r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getSigner(this.walletLocator,e)}catch(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 i=_chunkKXKBZNETcjs.b.call(void 0, r,this.chain);return{response:r,signer:i,pendingOperation:_chunkKXKBZNETcjs.c.call(void 0, r,this.chain)}})}buildInternalSignerConfig(e){var r,i,n,o,g,s;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:_chunk2GKPWQBQcjs.d.call(void 0, this,f).crossmint,clientTEEConnection:(r=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:r.clientTEEConnection,onAuthRequired:(n=(i=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:i.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,f).crossmint,clientTEEConnection:(o=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:o.clientTEEConnection,onAuthRequired:(s=(g=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:g.callbacks)==null?void 0:s.onAuthRequired};case"passkey":{let l="id"in e&&e.id?e.id:"";return{type:"passkey",id:l,locator:`passkey:${l}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:e.onCreatePasskey,onSignWithPasskey:e.onSignWithPasskey}}case"device":return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:this.address};case"external-wallet":return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},e),{locator:`external-wallet:${e.address}`});case"api-key":return{type:"api-key",locator:"api-key",address:this.address};case"server":{let l=e,c=this.resolveServerSignerDerivation(l),h=new Uint8Array(c.derivedKeyBytes);return c!==_chunk2GKPWQBQcjs.d.call(void 0, this,W)&&c!==_chunk2GKPWQBQcjs.d.call(void 0, this,E)&&_chunkLWA3SX6Zcjs.a.call(void 0, c.derivedKeyBytes),{type:"server",derivedKeyBytes:h,locator:`server:${c.derivedAddress}`,address:c.derivedAddress}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}isAutoAssemblableSignerConfig(e){var r;switch(e.type){case"email":case"phone":case"passkey":case"api-key":return!0;case"device":return((r=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:r.deviceSignerKeyStorage)!=null;case"server":return!_chunk5HBCBS5Wcjs.e.call(void 0, e)||_chunk2GKPWQBQcjs.d.call(void 0, this,E)!=null;case"external-wallet":return"onSign"in e&&typeof e.onSign=="function";default:return!1}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=_chunkHHVIOE43cjs.f.call(void 0, this.chain,_chunk2GKPWQBQcjs.d.call(void 0, this,f).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield this.approveSignatureInternal(e,r);return!("error"in i)&&i.status==="success"&&i.outputSignature!=null?{signature:i.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,c;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let i=this.requireSigner(),n=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getSignature(this.walletLocator,e);if("error"in n)throw new (0, _chunkQVM2QBXEcjs.t)(JSON.stringify(n));if(i.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let h=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,h)}let o=(l=n.approvals)==null?void 0:l.pending;if(o==null||o.length===0)return n;let g=[...(c=r==null?void 0:r.additionalSigners)!=null?c:[],i],s=yield Promise.all(o.map(h=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let v=g.find(m=>m.locator()===h.signer.locator);if(v==null)throw new (0, _chunkQVM2QBXEcjs.j)(`Signer ${h.signer.locator} not found in pending approvals`);let w=yield v.signMessage(h.message);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},w),{signer:v.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,s)})}approveTransactionInternal(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var l,c,h,v,w;let i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getTransaction(this.walletLocator,e);if("error"in i)throw new (0, _chunkQVM2QBXEcjs.x)(JSON.stringify(i));yield(h=(c=(l=_chunk2GKPWQBQcjs.d.call(void 0, this,A))==null?void 0:l.callbacks)==null?void 0:c.onTransactionStart)==null?void 0:h.call(c);let n=this.requireSigner();if(n.type==="api-key")return i;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let o=(v=i.approvals)==null?void 0:v.pending;if(o==null||o.length===0)return i;let g=[...(w=r==null?void 0:r.additionalSigners)!=null?w:[],n],s=yield Promise.all(o.map(m=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let D=g.find(ye=>ye.locator()===m.signer.locator);if(D==null)throw new (0, _chunkQVM2QBXEcjs.j)(`Signer ${m.signer.locator} not found in pending approvals`);let G=D.type==="device",U=i.chainType==="solana"&&"transaction"in i.onChain&&!G?i.onChain.transaction:m.message,we=yield D.signTransaction(U);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},we),{signer:D.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,s)})}executeApproveTransactionWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkLR4JIGWXcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).approveTransaction(this.walletLocator,e,{approvals:r});if(i.error)throw new (0, _chunkQVM2QBXEcjs.C)(JSON.stringify(i));return i})}executeApproveSignatureWithErrorHandling(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).approveSignature(this.walletLocator,e,{approvals:r});if(i.error)throw new (0, _chunkQVM2QBXEcjs.u)(JSON.stringify(i));return i})}waitForSignature(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=null;do if(yield new Promise(i=>setTimeout(i,_chunkQ2RVHFFWcjs.d)),r=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getSignature(this.walletLocator,e),"error"in r)throw new (0, _chunkQVM2QBXEcjs.t)(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new (0, _chunkQVM2QBXEcjs.q)("Signature signing failed");if(!r.outputSignature)throw new (0, _chunkQVM2QBXEcjs.t)("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(g){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,r=6e4,{backoffMultiplier:i=1.1,maxBackoffMs:n=2e3,initialBackoffMs:o=_chunkQ2RVHFFWcjs.d}={}){var v,w;_chunkLR4JIGWXcjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let s=Date.now(),l;do{if(Date.now()-s>r)throw new (0, _chunkQVM2QBXEcjs.y)("Transaction confirmation timeout");if(l=yield _chunk2GKPWQBQcjs.d.call(void 0, this,f).getTransaction(this.walletLocator,e),l.error)throw new (0, _chunkQVM2QBXEcjs.x)(JSON.stringify(l));yield this.sleep(o),o=Math.min(o*i,n)}while(l.status==="pending");if(l.status==="failed")throw new (0, _chunkQVM2QBXEcjs.z)(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new (0, _chunkQVM2QBXEcjs.A)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let c="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,h=(v=l.onChain.txId)!=null?v:c;if(h==null)throw new (0, _chunkQVM2QBXEcjs.B)("Transaction hash not found on transaction response");return{hash:h,explorerLink:(w=l.onChain.explorerLink)!=null?w:"",transactionId:l.id}})}sleep(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};p=new WeakMap,A=new WeakMap,f=new WeakMap,S=new WeakMap,k=new WeakMap,y=new WeakMap,F=new WeakMap,W=new WeakMap,E=new WeakMap,N=new WeakMap,B=new WeakMap,q=new WeakMap,K=new WeakMap,H=new WeakMap,_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"balances",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"stagingFund",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"send",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"approve",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"addSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"removeSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"useSigner",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"recover",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],R.prototype,"signers",1);function me(C){if(typeof C=="string"){if(!_commonsdkbase.isValidAddress.call(void 0, C))throw new (0, _chunkQVM2QBXEcjs.E)(`Invalid recipient address: "${C}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return C}if("email"in C)return`email:${C.email}`;if("x"in C)return`x:${C.x}`;if("twitter"in C)return`twitter:${C.twitter}`;if("phone"in C)return`phoneNumber:${C.phone}`;if("userId"in C)return`userId:${C.userId}`;throw new Error("Invalid recipient locator")}function Ce(C,e){return _commonsdkbase.isValidAddress.call(void 0, C)?`${e}:${C}`:`${e}:${C.toLowerCase()}`}exports.a = R;
@@ -0,0 +1 @@
1
+ var s="@crossmint/wallets-sdk",t="1.6.0";var c="WALLETS_SDK",r=t,a=s,d=500;export{c as a,r as b,a as c,d};
@@ -0,0 +1 @@
1
+ import{a as P}from"./chunk-NZXYWQE5.js";import{a as v}from"./chunk-IOSADDL5.js";import{m as w}from"./chunk-EGL3LHTY.js";import{a as l}from"./chunk-SR3F22XV.js";import{c as m,g as n}from"./chunk-J3R36SGJ.js";import{getEnvironmentForKey as K,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as b}from"ox";var R={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},E=6e4,L="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;if(typeof window!="undefined"&&!P())throw new w("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=K(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return 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 ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return 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 b.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 b.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}};m([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
@@ -1 +1 @@
1
- import{a as S}from"./chunk-6X5JEJD7.js";import{a as l}from"./chunk-EOBMHTZD.js";import{a as i}from"./chunk-PG6S5LNU.js";import{a as t}from"./chunk-YM3T5Z2Z.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-2O6HQK34.js";import{g as a}from"./chunk-5OYPWGMX.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-R3SPSOEE.js";import{a as t}from"./chunk-NPIMFXJ5.js";import{a as l}from"./chunk-IDNVSMIL.js";import{a as i}from"./chunk-CMGXTYC7.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-2L3ALABB.js";import{g as a}from"./chunk-EGL3LHTY.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 d}from"./chunk-OQZTL6ZG.js";import{a as S,b as g}from"./chunk-EM3D5Q3A.js";import{a as o}from"./chunk-XNZLCUTY.js";import{privateKeyToAccount as f}from"viem/accounts";import{bytesToHex as l}from"@noble/hashes/utils";import{Keypair as u}from"@solana/web3.js";function y(r,e){switch(d(e)){case"evm":return f(`0x${l(r)}`).address;case"solana":return u.fromSeed(r).publicKey.toBase58();case"stellar":return S(g(r).publicKey)}}function B(r,e,i,t){if(typeof window!="undefined")throw new Error("Server signers can only be used from server-side code.");let s=d(e),n=o(r.secret,i,t,s),a=y(n,e);return{derivedKeyBytes:n,derivedAddress:a}}function D(r,e,i,t){if(typeof window!="undefined")throw new Error("Server signers can only be used from server-side code.");let s=d(e),n=o(r.secret,i,t,s),a=y(n,e),c={derivedKeyBytes:n,derivedAddress:a},p=typeof e=="string"?e:String(e);if(s==="evm"&&p!=="evm"){let v=o(r.secret,i,t,p),m=y(v,e);return{primary:c,legacy:{derivedKeyBytes:v,derivedAddress:m}}}return{primary:c,legacy:null}}export{y as a,B as b,D as c};
1
+ import{a as d}from"./chunk-OQZTL6ZG.js";import{a as S,b as g}from"./chunk-EM3D5Q3A.js";import{a as o}from"./chunk-E3H6RZHM.js";import{privateKeyToAccount as f}from"viem/accounts";import{bytesToHex as l}from"@noble/hashes/utils";import{Keypair as u}from"@solana/web3.js";function y(r,e){switch(d(e)){case"evm":return f(`0x${l(r)}`).address;case"solana":return u.fromSeed(r).publicKey.toBase58();case"stellar":return S(g(r).publicKey)}}function B(r,e,i,t){if(typeof window!="undefined")throw new Error("Server signers can only be used from server-side code.");let s=d(e),n=o(r.secret,i,t,s),a=y(n,e);return{derivedKeyBytes:n,derivedAddress:a}}function D(r,e,i,t){if(typeof window!="undefined")throw new Error("Server signers can only be used from server-side code.");let s=d(e),n=o(r.secret,i,t,s),a=y(n,e),c={derivedKeyBytes:n,derivedAddress:a},p=typeof e=="string"?e:String(e);if(s==="evm"&&p!=="evm"){let v=o(r.secret,i,t,p),m=y(v,e);return{primary:c,legacy:{derivedKeyBytes:v,derivedAddress:m}}}return{primary:c,legacy:null}}export{y as a,B as b,D as c};
@@ -1 +1 @@
1
- import{a as i}from"./chunk-PMUGCRPI.js";import{v as u}from"./chunk-5OYPWGMX.js";import{a as t}from"./chunk-SYQ5Q3WU.js";import{a as f,c,g as s}from"./chunk-J3R36SGJ.js";import{isValidStellarAddress as T,WithLoggerContext as g}from"@crossmint/common-sdk-base";var m=409,l=class l extends i{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:i.getOptions(e),alias:e.alias,recovery:i.getRecovery(e),apiRecoveryServerSignerAddress:i.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:i.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:i.getInitialSigners(e)},i.getApiClient(e))}static from(e){if(!T(e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return s(this,null,function*(){var d;t.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return t.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return t.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return s(this,null,function*(){t.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return t.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),t.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else t.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return t.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return s(this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return s(this,null,function*(){t.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new u("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return t.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return t.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return s(this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new u(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return s(this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:f({transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new u(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.requireSigner().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};c([g({logger:t,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),c([g({logger:t,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),c([g({logger:t,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}export{h as a};
1
+ import{a as i}from"./chunk-XYTDDT77.js";import{w as u}from"./chunk-EGL3LHTY.js";import{a as t}from"./chunk-SR3F22XV.js";import{a as f,c,g as s}from"./chunk-J3R36SGJ.js";import{isValidStellarAddress as T,WithLoggerContext as g}from"@crossmint/common-sdk-base";var m=409,l=class l extends i{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:i.getOptions(e),alias:e.alias,recovery:i.getRecovery(e),apiRecoveryServerSignerAddress:i.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:i.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:i.getInitialSigners(e)},i.getApiClient(e))}static from(e){if(!T(e.address))throw new Error("Wallet is not a Stellar wallet");return new l(e)}sendTransaction(e){return s(this,null,function*(){var d;t.info("stellarWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=yield this.createTransaction(e);if((d=e.options)!=null&&d.prepareOnly)return t.info("stellarWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a={},n=yield this.approveTransactionAndWait(r.id,a);return t.info("stellarWallet.sendTransaction.success",{transactionId:r.id,hash:n.hash}),n})}upgrade(e){return s(this,null,function*(){t.info("stellarWallet.upgrade.start"),yield this.preAuthIfNeeded();let r=yield this.createWalletLifecycleTransaction("upgrade-wallet",e);if(r!=null){if(e!=null&&e.prepareOnly)return t.info("stellarWallet.upgrade.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};yield this.approveTransactionAndWait(r),t.info("stellarWallet.upgrade.phase1.success",{transactionId:r})}else t.info("stellarWallet.upgrade.phase1.skipped",{reason:"wallet already locked from a prior upgrade"});let a=yield this.migrateInternal({signer:e==null?void 0:e.signer,prepareOnly:e==null?void 0:e.prepareOnly});return t.info("stellarWallet.upgrade.success",{transactionId:a.transactionId,hash:a.hash}),a})}migrate(e){return s(this,null,function*(){return yield this.preAuthIfNeeded(),yield this.migrateInternal(e)})}migrateInternal(e){return s(this,null,function*(){t.info("stellarWallet.migrate.start");let r=yield this.createWalletLifecycleTransaction("migrate-wallet",e);if(r==null)throw new u("Failed to create migrate-wallet transaction");if(e!=null&&e.prepareOnly)return t.info("stellarWallet.migrate.prepared",{transactionId:r}),{hash:void 0,explorerLink:void 0,transactionId:r};let a=yield this.approveTransactionAndWait(r);return t.info("stellarWallet.migrate.success",{transactionId:r,hash:a.hash}),a})}createTransaction(e){return s(this,null,function*(){let{contractId:r,options:a}=e,n=this.resolveStellarSigner(a==null?void 0:a.signer),d="transaction"in e?{type:"serialized-transaction",serializedTransaction:e.transaction,contractId:r}:{type:"contract-call",contractId:r,method:e.method,memo:e.memo!=null?{type:"text",value:e.memo}:void 0,args:e.args},p=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:d,signer:n}});if("error"in p)throw new u(JSON.stringify(p));return p})}createWalletLifecycleTransaction(e,r){return s(this,null,function*(){let a=(r==null?void 0:r.signer)!=null?this.resolveStellarSigner(r.signer):void 0,n=yield this.apiClient.createTransaction(this.walletLocator,{params:f({transaction:{type:e}},a!=null?{signer:a}:{})});if("error"in n){if(e==="upgrade-wallet"&&y(n))return null;throw new u(JSON.stringify(n))}return n.id})}resolveStellarSigner(e){return e==null?this.requireSigner().locator():typeof e=="string"?e:this.resolveServerSignerApiLocator(e)}};c([g({logger:t,methodName:"stellarWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"sendTransaction",1),c([g({logger:t,methodName:"stellarWallet.upgrade",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"upgrade",1),c([g({logger:t,methodName:"stellarWallet.migrate",buildContext(e){return{chain:e.chain,address:e.address}}})],l.prototype,"migrate",1);var h=l;function y(o){return typeof o=="object"&&o!==null&&"statusCode"in o&&o.statusCode===m}export{h as a};
@@ -0,0 +1 @@
1
+ import{a as o}from"./chunk-XYTDDT77.js";import{a as W}from"./chunk-GZCR52HV.js";import{o as l,s as f,w}from"./chunk-EGL3LHTY.js";import{a as n}from"./chunk-SR3F22XV.js";import{c as u,g as p}from"./chunk-J3R36SGJ.js";import{createPublicClient as O,encodeFunctionData as x,http as E}from"viem";import{isValidEvmAddress as A,WithLoggerContext as h}from"@crossmint/common-sdk-base";var c=class c extends o{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:o.getOptions(e),alias:e.alias,recovery:o.getRecovery(e),apiRecoveryServerSignerAddress:o.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:o.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:o.getInitialSigners(e)},o.getApiClient(e))}static from(e){if(!A(e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return p(this,null,function*(){var i;n.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=this.buildTransaction(e),t=yield this.createTransaction(r,e.options);if((i=e.options)!=null&&i.prepareOnly)return n.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return n.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return p(this,null,function*(){var i;n.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let r=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:r.locator(),chain:this.chain}});if("error"in t)throw n.error("evmWallet.signMessage.error",{error:t}),new f(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return n.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return n.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return p(this,null,function*(){var C;n.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let r=this.requireSigner(),{domain:t,message:a,primaryType:i,types:g,chain:T}=e;if(!t||!a||!g||!T)throw n.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new l("Invalid typed data");let{name:m,version:S,chainId:v,verifyingContract:I,salt:D}=t;if(!m||!S||!v||!I)throw n.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new l("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:S,chainId:Number(v),verifyingContract:I,salt:D},message:y(a),primaryType:i,types:g},signer:r.locator(),chain:T}});if("error"in d)throw n.error("evmWallet.signTypedData.error",{error:d}),new f(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return n.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let M=yield this.approveSignatureAndWait(d.id);return n.info("evmWallet.signTypedData.success",{signatureId:d.id}),M})}getViemClient(e){var r;return O({transport:(r=e==null?void 0:e.transport)!=null?r:E(),chain:W(this.chain)})}createTransaction(e,r){return p(this,null,function*(){let t;(r==null?void 0:r.signer)==null?t=this.requireSigner().locator():typeof r.signer=="string"?t=r.signer:t=this.resolveServerSignerApiLocator(r.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new w(JSON.stringify(a));return a})}buildTransaction(e){var r,t,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(r=e.value)==null?void 0:r.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:x({abi:e.abi,functionName:e.functionName,args:e.args})}}};u([h({logger:n,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),u([h({logger:n,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),u([h({logger:n,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var b=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,r])=>[e,y(r)])):s}export{b as a};
@@ -1 +1 @@
1
- import{a as o}from"./chunk-5OYPWGMX.js";import{a}from"./chunk-SYQ5Q3WU.js";import{b as p,c}from"./chunk-YN4JN7PO.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*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.json()})}getSignature(e,s){return 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-EGL3LHTY.js";import{a}from"./chunk-SR3F22XV.js";import{b as p,c}from"./chunk-3HGHIZUM.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*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.json()})}getSignature(e,s){return 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};
@@ -0,0 +1 @@
1
+ import{a}from"./chunk-FJPAMX7L.js";import{g as t}from"./chunk-J3R36SGJ.js";import{Keypair as p,VersionedTransaction as y}from"@solana/web3.js";import r from"bs58";import n from"tweetnacl";var o=class{constructor(e){this.type="server";this.keypair=p.fromSeed(e.derivedKeyBytes),this._address=this.keypair.publicKey.toBase58(),this._locator=e.locator,a(e.derivedKeyBytes)}address(){return this._address}locator(){return this._locator}signMessage(e){return t(this,null,function*(){let s=r.decode(e),i=n.sign.detached(s,this.keypair.secretKey);return{signature:r.encode(i)}})}signTransaction(e){return t(this,null,function*(){let s=r.decode(e),c=y.deserialize(s).message.serialize(),d=n.sign.detached(c,this.keypair.secretKey);return{signature:r.encode(d)}})}};export{o as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQVNXEPOZcjs = require('./chunk-QVNXEPOZ.cjs');var _chunkCAQZTHJBcjs = require('./chunk-CAQZTHJB.cjs');var _chunkOWQZPI3Ucjs = require('./chunk-OWQZPI3U.cjs');var _chunkVUC4UU5Mcjs = require('./chunk-VUC4UU5M.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkQVNXEPOZcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkQVNXEPOZcjs.a.getOptions(e),alias:e.alias,recovery:_chunkQVNXEPOZcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunkQVNXEPOZcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunkQVNXEPOZcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunkQVNXEPOZcjs.a.getInitialSigners(e)},_chunkQVNXEPOZcjs.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;_chunkVUC4UU5Mcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=this.buildTransaction(e),t=yield this.createTransaction(r,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkVUC4UU5Mcjs.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 _chunkVUC4UU5Mcjs.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;_chunkVUC4UU5Mcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let r=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:r.locator(),chain:this.chain}});if("error"in t)throw _chunkVUC4UU5Mcjs.a.error("evmWallet.signMessage.error",{error:t}),new (0, _chunkOWQZPI3Ucjs.r)(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return _chunkVUC4UU5Mcjs.a.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return _chunkVUC4UU5Mcjs.a.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var C;_chunkVUC4UU5Mcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let r=this.requireSigner(),{domain:t,message:a,primaryType:i,types:g,chain:T}=e;if(!t||!a||!g||!T)throw _chunkVUC4UU5Mcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkOWQZPI3Ucjs.n)("Invalid typed data");let{name:m,version:S,chainId:v,verifyingContract:I,salt:D}=t;if(!m||!S||!v||!I)throw _chunkVUC4UU5Mcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkOWQZPI3Ucjs.n)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:S,chainId:Number(v),verifyingContract:I,salt:D},message:y(a),primaryType:i,types:g},signer:r.locator(),chain:T}});if("error"in d)throw _chunkVUC4UU5Mcjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunkOWQZPI3Ucjs.r)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkVUC4UU5Mcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let M=yield this.approveSignatureAndWait(d.id);return _chunkVUC4UU5Mcjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),M})}getViemClient(e){var r;return _viem.createPublicClient.call(void 0, {transport:(r=e==null?void 0:e.transport)!=null?r:_viem.http.call(void 0, ),chain:_chunkCAQZTHJBcjs.a.call(void 0, this.chain)})}createTransaction(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t;(r==null?void 0:r.signer)==null?t=this.requireSigner().locator():typeof r.signer=="string"?t=r.signer:t=this.resolveServerSignerApiLocator(r.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkOWQZPI3Ucjs.v)(JSON.stringify(a));return a})}buildTransaction(e){var r,t,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(r=e.value)==null?void 0:r.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkVUC4UU5Mcjs.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:_chunkVUC4UU5Mcjs.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:_chunkVUC4UU5Mcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var b=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,r])=>[e,y(r)])):s}exports.a = b;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3EQ6LL7Scjs = require('./chunk-3EQ6LL7S.cjs');var _chunkHHVIOE43cjs = require('./chunk-HHVIOE43.cjs');var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunk3EQ6LL7Scjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk3EQ6LL7Scjs.a.getOptions(e),alias:e.alias,recovery:_chunk3EQ6LL7Scjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunk3EQ6LL7Scjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunk3EQ6LL7Scjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk3EQ6LL7Scjs.a.getInitialSigners(e)},_chunk3EQ6LL7Scjs.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;_chunkLR4JIGWXcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let r=this.buildTransaction(e),t=yield this.createTransaction(r,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkLR4JIGWXcjs.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 _chunkLR4JIGWXcjs.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;_chunkLR4JIGWXcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let r=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:r.locator(),chain:this.chain}});if("error"in t)throw _chunkLR4JIGWXcjs.a.error("evmWallet.signMessage.error",{error:t}),new (0, _chunkQVM2QBXEcjs.s)(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return _chunkLR4JIGWXcjs.a.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return _chunkLR4JIGWXcjs.a.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var C;_chunkLR4JIGWXcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let r=this.requireSigner(),{domain:t,message:a,primaryType:i,types:g,chain:T}=e;if(!t||!a||!g||!T)throw _chunkLR4JIGWXcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkQVM2QBXEcjs.o)("Invalid typed data");let{name:m,version:S,chainId:v,verifyingContract:I,salt:D}=t;if(!m||!S||!v||!I)throw _chunkLR4JIGWXcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkQVM2QBXEcjs.o)("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:S,chainId:Number(v),verifyingContract:I,salt:D},message:y(a),primaryType:i,types:g},signer:r.locator(),chain:T}});if("error"in d)throw _chunkLR4JIGWXcjs.a.error("evmWallet.signTypedData.error",{error:d}),new (0, _chunkQVM2QBXEcjs.s)(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return _chunkLR4JIGWXcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let M=yield this.approveSignatureAndWait(d.id);return _chunkLR4JIGWXcjs.a.info("evmWallet.signTypedData.success",{signatureId:d.id}),M})}getViemClient(e){var r;return _viem.createPublicClient.call(void 0, {transport:(r=e==null?void 0:e.transport)!=null?r:_viem.http.call(void 0, ),chain:_chunkHHVIOE43cjs.a.call(void 0, this.chain)})}createTransaction(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t;(r==null?void 0:r.signer)==null?t=this.requireSigner().locator():typeof r.signer=="string"?t=r.signer:t=this.resolveServerSignerApiLocator(r.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkQVM2QBXEcjs.w)(JSON.stringify(a));return a})}buildTransaction(e){var r,t,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(r=e.value)==null?void 0:r.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.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:_chunkLR4JIGWXcjs.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:_chunkLR4JIGWXcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var b=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,r])=>[e,y(r)])):s}exports.a = b;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkLWA3SX6Zcjs = require('./chunk-LWA3SX6Z.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _web3js = require('@solana/web3.js');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _tweetnacl = require('tweetnacl'); var _tweetnacl2 = _interopRequireDefault(_tweetnacl);var o=class{constructor(e){this.type="server";this.keypair=_web3js.Keypair.fromSeed(e.derivedKeyBytes),this._address=this.keypair.publicKey.toBase58(),this._locator=e.locator,_chunkLWA3SX6Zcjs.a.call(void 0, e.derivedKeyBytes)}address(){return this._address}locator(){return this._locator}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=_bs582.default.decode(e),i=_tweetnacl2.default.sign.detached(s,this.keypair.secretKey);return{signature:_bs582.default.encode(i)}})}signTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=_bs582.default.decode(e),c=_web3js.VersionedTransaction.deserialize(s).message.serialize(),d=_tweetnacl2.default.sign.detached(c,this.keypair.secretKey);return{signature:_bs582.default.encode(d)}})}};exports.a = o;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4HWSBR3Ncjs = require('./chunk-4HWSBR3N.cjs');var _chunkVUC4UU5Mcjs = require('./chunk-VUC4UU5M.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var a=class g extends _chunk4HWSBR3Ncjs.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();_chunkVUC4UU5Mcjs.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:_chunk4HWSBR3Ncjs.b});if(_chunkVUC4UU5Mcjs.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 _chunkZMP33IOHcjs = require('./chunk-ZMP33IOH.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var a=class g extends _chunkZMP33IOHcjs.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();_chunkLR4JIGWXcjs.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:_chunkZMP33IOHcjs.b});if(_chunkLR4JIGWXcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4HWSBR3Ncjs = require('./chunk-4HWSBR3N.cjs');var _chunkVUC4UU5Mcjs = require('./chunk-VUC4UU5M.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunk4HWSBR3Ncjs.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","");_chunkVUC4UU5Mcjs.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:_chunk4HWSBR3Ncjs.b});if(_chunkVUC4UU5Mcjs.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 _chunkZMP33IOHcjs = require('./chunk-ZMP33IOH.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkZMP33IOHcjs.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","");_chunkLR4JIGWXcjs.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:_chunkZMP33IOHcjs.b});if(_chunkLR4JIGWXcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};exports.a = c;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGSNFNRH2cjs = require('./chunk-GSNFNRH2.cjs');var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var R={[_commonsdkbase.APIKeyEnvironmentPrefix.DEVELOPMENT]:"https://development.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.STAGING]:"https://staging.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION]:"https://devicekey.store"},E=6e4,L="indexeddb-fatal",c= exports.a =class extends _chunk3VYGTPRFcjs.a{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;if(typeof window!="undefined"&&!_chunkGSNFNRH2cjs.a.call(void 0, ))throw new (0, _chunkQVM2QBXEcjs.m)("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=_commonsdkbase.getEnvironmentForKey.call(void 0, e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){_chunkLR4JIGWXcjs.a.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.reloading!=null)return this.reloading;let e=_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield _ox.WebAuthnP256.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield _ox.WebAuthnP256.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkLR4JIGWXcjs.a,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);exports.a = c;
@@ -1 +1 @@
1
- import{a,b as g}from"./chunk-LDOMAUCN.js";import{a as s}from"./chunk-SYQ5Q3WU.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-QRCGBBPU.js";import{a as s}from"./chunk-SR3F22XV.js";import{g as t}from"./chunk-J3R36SGJ.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkW5SV3EQJcjs = require('./chunk-W5SV3EQJ.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunk4TGSG3UZcjs = require('./chunk-4TGSG3UZ.cjs');var _chunkVUC4UU5Mcjs = require('./chunk-VUC4UU5M.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkVUC4UU5Mcjs.b.call(void 0, e.apiKey);let t=new (0, _chunk4TGSG3UZcjs.a)(e);this.walletFactory=new (0, _chunkW5SV3EQJcjs.a)(t),_chunkVUC4UU5Mcjs.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 _chunkQ34P6JFXcjs = require('./chunk-Q34P6JFX.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkGUP2PIJOcjs = require('./chunk-GUP2PIJO.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var o=class c{constructor(e){_chunkLR4JIGWXcjs.b.call(void 0, e.apiKey);let t=new (0, _chunkGUP2PIJOcjs.a)(e);this.walletFactory=new (0, _chunkQ34P6JFXcjs.a)(t),_chunkLR4JIGWXcjs.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}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk4HWSBR3Ncjs = require('./chunk-4HWSBR3N.cjs');var _chunkVUC4UU5Mcjs = require('./chunk-VUC4UU5M.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 _chunk4HWSBR3Ncjs.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();_chunkVUC4UU5Mcjs.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:_chunk4HWSBR3Ncjs.b});if(_chunkVUC4UU5Mcjs.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 _chunkZMP33IOHcjs = require('./chunk-ZMP33IOH.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.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 _chunkZMP33IOHcjs.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();_chunkLR4JIGWXcjs.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:_chunkZMP33IOHcjs.b});if(_chunkLR4JIGWXcjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};exports.a = g;
@@ -1 +1 @@
1
- import{a as i}from"./chunk-MDINF2FR.js";import{a as n}from"./chunk-OQZTL6ZG.js";import{a as t}from"./chunk-XNZLCUTY.js";function h(s){let{secret:o,chain:e,projectId:a,environment:p}=s,c=n(e),r=t(o,a,p,c);return{type:"server",address:i(r,e),keyBytes:r}}export{h as a};
1
+ import{a as i}from"./chunk-5LN6KXFF.js";import{a as n}from"./chunk-OQZTL6ZG.js";import{a as t}from"./chunk-E3H6RZHM.js";function h(s){let{secret:o,chain:e,projectId:a,environment:p}=s,c=n(e),r=t(o,a,p,c);return{type:"server",address:i(r,e),keyBytes:r}}export{h as a};
@@ -0,0 +1 @@
1
+ import{hkdf as l}from"@noble/hashes/hkdf";import{sha256 as f}from"@noble/hashes/sha2";import{bytesToHex as E,hexToBytes as h}from"@noble/hashes/utils";var m="crossmint",g="xmsk1_";function T(t,r,s,n){let e=d(t),i=h(e),o=u(n),c=`${r}:${s}:${n}-${o}`;return l(f,i,m,c,32)}function _(t,r,s,n){let e=d(t),i=h(e),o=`${r}:${s}:${n}-alias`,c=l(f,i,m,o,17);return`s-${E(c).slice(0,34)}`}var a=64;function d(t){let r=t.startsWith(g)?t.slice(g.length):t;if(r.length!==a)throw new Error(`Invalid server signer secret: expected ${a}-char hex string (256-bit), got ${r.length} chars`);return r}function u(t){return t==="solana"||t==="stellar"?"ed25519":"secp256k1"}export{T as a,_ as b};
@@ -0,0 +1 @@
1
+ import{CrossmintSDKError as t,WalletErrorCode as e}from"@crossmint/common-sdk-base";var o=class extends t{constructor(s,r){super(s,e.API_KEY_INVALID,r)}},c=class extends t{constructor(s,r){super(s,e.ENVIRONMENT_INVALID,r)}},I=class extends t{constructor(s,r){super(s,e.WALLET_CREATION_FAILED,r)}},p=class extends t{constructor(s,r){super(s,e.WALLET_TYPE_INVALID,r)}},i=class extends t{constructor(s,r){super(s,e.WALLET_NOT_AVAILABLE,r)}},x=class extends t{constructor(s,r){super(s,e.WALLET_NOT_AVAILABLE,r)}},N=class extends t{constructor(s,r){super(s,e.WALLET_CREATION_FAILED,r)}},A=class extends t{constructor(s,r){super(s,e.WALLET_TYPE_INVALID,r)}},g=class extends t{constructor(s,r){super(s,e.SIGNER_INVALID,r)}},u=class extends t{constructor(s,r){super(s,e.SIGNER_INVALID,r)}},f="DEVICE_SIGNER_NOT_SUPPORTED",E=class extends t{constructor(s,r){super(s,e.SIGNER_INVALID,r)}},_=class extends t{constructor(s,r){super(s,e.ENVIRONMENT_INVALID,r)}},L=class extends t{constructor(s,r){super(s,e.MESSAGE_INVALID,r)}},T=class extends t{constructor(s,r){super(s,e.MESSAGE_INVALID,r)}},l=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},a=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},d=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},D=class extends t{constructor(s,r){super(s,e.NO_SIGNATURE,r)}},S=class extends t{constructor(s,r){super(s,e.NO_SIGNATURE,r)}},R=class extends t{constructor(s,r){super(s,e.SIGNING_FAILED,r)}},O=class extends t{constructor(s,r){super(s,e.NO_TRANSACTION,r)}},C=class extends t{constructor(s,r){super(s,e.NO_TRANSACTION,r)}},G=class extends t{constructor(s,r){super(s,e.NO_TRANSACTION,r)}},V=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},F=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},P=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},W=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},M=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},U=class extends t{constructor(s,r){super(s,e.TRANSACTION_FAILED,r)}},m=class extends t{constructor(s,r){super(s,e.RECIPIENT_ADDRESS_INVALID,r)}};export{o as a,c as b,I as c,p as d,i as e,x as f,N as g,A as h,g as i,u as j,f as k,E as l,_ as m,L as n,T as o,l as p,a as q,d as r,D as s,S as t,R as u,O as v,C as w,G as x,V as y,F as z,P as A,W as B,M as C,U as D,m as E};
@@ -1 +1 @@
1
- import{a as n}from"./chunk-ENZ7MQIX.js";import{a as s}from"./chunk-N4IWDL6M.js";import{a as l}from"./chunk-42JFJWEX.js";import{a,b as i}from"./chunk-SYQ5Q3WU.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-YHD5NORG.js";import{a as s}from"./chunk-N4IWDL6M.js";import{a as l}from"./chunk-6ZO5Q6UF.js";import{a,b as i}from"./chunk-SR3F22XV.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
+ function l(...f){for(let n of f)n!=null&&n.fill(0)}export{l as a};
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});function a(){if(typeof navigator=="undefined")return!1;let t=navigator.userAgent;if(!t)return!1;let r=t.match(/Chrome\/(\d+)/);if(r!=null)return parseInt(r[1],10)>=115;let e=t.match(/Firefox\/(\d+)/);return e!=null?parseInt(e[1],10)>=103:!!/Safari\/\d+/.test(t)}exports.a = a;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkOWQZPI3Ucjs = require('./chunk-OWQZPI3U.cjs');var _chunkVUC4UU5Mcjs = require('./chunk-VUC4UU5M.cjs');var _chunkVVX6XW5Lcjs = require('./chunk-VVX6XW5L.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:_chunkVVX6XW5Lcjs.c,version:_chunkVVX6XW5Lcjs.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`;_chunkVUC4UU5Mcjs.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?_chunkVUC4UU5Mcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkVUC4UU5Mcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkVUC4UU5Mcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkVUC4UU5Mcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkVUC4UU5Mcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.json()})}getSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkVUC4UU5Mcjs.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?_chunkVUC4UU5Mcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkVUC4UU5Mcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkOWQZPI3Ucjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkOWQZPI3Ucjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQVM2QBXEcjs = require('./chunk-QVM2QBXE.cjs');var _chunkLR4JIGWXcjs = require('./chunk-LR4JIGWX.cjs');var _chunkQ2RVHFFWcjs = require('./chunk-Q2RVHFFW.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:_chunkQ2RVHFFWcjs.c,version:_chunkQ2RVHFFWcjs.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`;_chunkLR4JIGWXcjs.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?_chunkLR4JIGWXcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkLR4JIGWXcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkLR4JIGWXcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkLR4JIGWXcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkLR4JIGWXcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.json()})}getSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkLR4JIGWXcjs.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?_chunkLR4JIGWXcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkLR4JIGWXcjs.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, _chunkQVM2QBXEcjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkQVM2QBXEcjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;