@crossmint/wallets-sdk 1.0.12 → 1.0.13

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 (80) 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-FOFZZIP6.cjs → chunk-3ES7AU7Z.cjs} +1 -1
  10. package/dist/{chunk-VM44GMMD.cjs → chunk-4UKQXGPB.cjs} +1 -1
  11. package/dist/{chunk-4RI43OYI.js → chunk-BKBD4C7T.js} +1 -1
  12. package/dist/{chunk-NCMB6JPN.cjs → chunk-DDNQDJCW.cjs} +1 -1
  13. package/dist/{chunk-KIKFBPJP.js → chunk-DLLP4CTN.js} +1 -1
  14. package/dist/{chunk-IEBR4VOA.js → chunk-EZUZR5OQ.js} +1 -1
  15. package/dist/{chunk-OMIBDAQS.js → chunk-FLT6EMX3.js} +1 -1
  16. package/dist/{chunk-BGEVA5VH.cjs → chunk-FWKVWAMG.cjs} +1 -1
  17. package/dist/{chunk-UOQMZXMC.cjs → chunk-GKWN7JSL.cjs} +1 -1
  18. package/dist/{chunk-BMUUDNT6.js → chunk-HCORGS2Y.js} +1 -1
  19. package/dist/{chunk-46PT2BD6.js → chunk-HUWBO6P7.js} +1 -1
  20. package/dist/{chunk-K22OQG7C.js → chunk-ID7RNLCG.js} +1 -1
  21. package/dist/{chunk-3RJ2OR3P.js → chunk-IWDL4WB7.js} +1 -1
  22. package/dist/{chunk-2MUNT6EY.js → chunk-KKBYSFTH.js} +1 -1
  23. package/dist/{chunk-4SZDDY2P.cjs → chunk-KZYWN2DL.cjs} +1 -1
  24. package/dist/{chunk-7LTZRBP6.js → chunk-L2WKVC6H.js} +1 -1
  25. package/dist/{chunk-BTR5DXDU.cjs → chunk-LUPYQFQ2.cjs} +1 -1
  26. package/dist/{chunk-UYRIB3UM.cjs → chunk-MCXLP6ND.cjs} +1 -1
  27. package/dist/{chunk-YXM5QQWL.cjs → chunk-MJ44COEV.cjs} +1 -1
  28. package/dist/{chunk-2WWBXNRB.js → chunk-NRSO3EOP.js} +1 -1
  29. package/dist/{chunk-ATHH2TXY.cjs → chunk-O6VG4EVR.cjs} +2 -2
  30. package/dist/{chunk-3VX6XVRC.cjs → chunk-QKNUASFH.cjs} +1 -1
  31. package/dist/{chunk-QJGO3XB4.cjs → chunk-TFC7TYGW.cjs} +1 -1
  32. package/dist/{chunk-Q3KNP7DW.cjs → chunk-TLKQF44C.cjs} +1 -1
  33. package/dist/{chunk-SBO36KCZ.js → chunk-TYLZH2Q6.js} +1 -1
  34. package/dist/{chunk-EGLJRCMB.cjs → chunk-UI2MD5VN.cjs} +1 -1
  35. package/dist/{chunk-NQYZGWB6.js → chunk-UU2L76MJ.js} +1 -1
  36. package/dist/{chunk-6DCPC33F.cjs → chunk-UZWS4OLZ.cjs} +1 -1
  37. package/dist/{chunk-FOGKDOTH.js → chunk-WAWTCY5G.js} +1 -1
  38. package/dist/chunk-WJ6Z7KVH.js +1 -0
  39. package/dist/{chunk-Y6CX3OBV.cjs → chunk-ZCT3LXMP.cjs} +1 -1
  40. package/dist/{chunk-FFJ5HKVE.js → chunk-ZS7CPI4N.js} +1 -1
  41. package/dist/index.cjs +1 -1
  42. package/dist/index.js +1 -1
  43. package/dist/logger/index.cjs +1 -1
  44. package/dist/logger/index.js +1 -1
  45. package/dist/logger/init.cjs +1 -1
  46. package/dist/logger/init.js +1 -1
  47. package/dist/sdk.cjs +1 -1
  48. package/dist/sdk.js +1 -1
  49. package/dist/signers/index.cjs +1 -1
  50. package/dist/signers/index.js +1 -1
  51. package/dist/signers/non-custodial/index.cjs +1 -1
  52. package/dist/signers/non-custodial/index.js +1 -1
  53. package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
  54. package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
  55. package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
  56. package/dist/signers/non-custodial/ncs-signer.js +1 -1
  57. package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
  58. package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
  59. package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
  60. package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
  61. package/dist/utils/constants.cjs +1 -1
  62. package/dist/utils/constants.js +1 -1
  63. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
  64. package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
  65. package/dist/utils/device-signers/index.cjs +1 -1
  66. package/dist/utils/device-signers/index.js +1 -1
  67. package/dist/wallets/__tests__/test-helpers.cjs +1 -1
  68. package/dist/wallets/__tests__/test-helpers.js +1 -1
  69. package/dist/wallets/evm.cjs +1 -1
  70. package/dist/wallets/evm.js +1 -1
  71. package/dist/wallets/solana.cjs +1 -1
  72. package/dist/wallets/solana.js +1 -1
  73. package/dist/wallets/stellar.cjs +1 -1
  74. package/dist/wallets/stellar.js +1 -1
  75. package/dist/wallets/wallet-factory.cjs +1 -1
  76. package/dist/wallets/wallet-factory.js +1 -1
  77. package/dist/wallets/wallet.cjs +1 -1
  78. package/dist/wallets/wallet.js +1 -1
  79. package/package.json +2 -2
  80. package/dist/chunk-K2IXWI5K.js +0 -1
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ33QM2IDcjs = require('../../chunk-J33QM2ID.cjs');var _chunkVM44GMMDcjs = require('../../chunk-VM44GMMD.cjs');require('../../chunk-T3U46LK3.cjs');require('../../chunk-6DCPC33F.cjs');require('../../chunk-Y6CX3OBV.cjs');var _chunk2GKPWQBQcjs = require('../../chunk-2GKPWQBQ.cjs');var _vitest = require('vitest');var b=({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=>b({data:e}),P= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>b({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, _chunkVM44GMMDcjs.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(P(n,s));let a=yield e();_vitest.expect.call(void 0, u(a)).toBe(!0),u(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 l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();_vitest.expect.call(void 0, u(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 u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(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, _chunkVM44GMMDcjs.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:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(_chunk2GKPWQBQcjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(h(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 h(s)&&t.addWallet(s.address),s})}function ue(e,t){_vitest.expect.call(void 0, u(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function le(e){_vitest.expect.call(void 0, h(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(u(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(u(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:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),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(u(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 = P; exports.createMockResponse = b; 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 = ue; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = le; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = u; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = h; 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 _chunk4UKQXGPBcjs = require('../../chunk-4UKQXGPB.cjs');require('../../chunk-T3U46LK3.cjs');require('../../chunk-UZWS4OLZ.cjs');require('../../chunk-ZCT3LXMP.cjs');var _chunk2GKPWQBQcjs = require('../../chunk-2GKPWQBQ.cjs');var _vitest = require('vitest');var b=({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=>b({data:e}),P= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>b({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, _chunk4UKQXGPBcjs.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(P(n,s));let a=yield e();_vitest.expect.call(void 0, u(a)).toBe(!0),u(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 l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();_vitest.expect.call(void 0, u(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 u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(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, _chunk4UKQXGPBcjs.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:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(_chunk2GKPWQBQcjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(h(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 h(s)&&t.addWallet(s.address),s})}function ue(e,t){_vitest.expect.call(void 0, u(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function le(e){_vitest.expect.call(void 0, h(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(u(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(u(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:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),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(u(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 = P; exports.createMockResponse = b; 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 = ue; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = le; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = u; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = h; 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 E,k as M,l as W,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-NQYZGWB6.js";import"../../chunk-EXC7TCGL.js";import"../../chunk-46PT2BD6.js";import"../../chunk-K2IXWI5K.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 b=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>b({data:e}),P=(e,t=400,n="Bad Request")=>b({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(P(n,s));let a=yield e();r(u(a)).toBe(!0),u(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 l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();r(u(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:M.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 u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(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:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(h(f))return t.addWallet(f.address),f.address})}function ue(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return h(s)&&t.addWallet(s.address),s})}function le(e,t){r(u(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(h(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(u(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=W.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(u(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:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(E);continue}yield x(R)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),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(u(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,P as createMockErrorResponse,b as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,ue as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,le as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,u as isErrorResponse,$ as isSuccessTransactionResponse,h 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 E,k as M,l as W,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-UU2L76MJ.js";import"../../chunk-EXC7TCGL.js";import"../../chunk-HUWBO6P7.js";import"../../chunk-WJ6Z7KVH.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 b=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>b({data:e}),P=(e,t=400,n="Bad Request")=>b({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(P(n,s));let a=yield e();r(u(a)).toBe(!0),u(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 l={error:!0,message:g};t.mockResolvedValueOnce(P(l,c));let m=yield e();r(u(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:M.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 u(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function h(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:l="default"}=n,m=g||`userId:integration-${l}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(h(f))return t.addWallet(f.address),f.address})}function ue(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return h(s)&&t.addWallet(s.address),s})}function le(e,t){r(u(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(h(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(u(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=W.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(u(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:""}))},C=yield e.approveTransaction(t,n,O);if(u(C))throw new Error(`Failed to approve transaction: ${C.message||"Unknown error"}`);yield x(E);continue}yield x(R)}let l=yield e.getTransaction(t,n);if(u(l))throw new Error(`Transaction not found after retries: ${l.message||"Unknown error"}`);if(!("status"in l))throw new Error("Transaction response missing status property");return l}),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(u(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,P as createMockErrorResponse,b as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,ue as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,le as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,u as isErrorResponse,$ as isSuccessTransactionResponse,h 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 _chunkVM44GMMDcjs = require('../chunk-VM44GMMD.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-6DCPC33F.cjs');require('../chunk-Y6CX3OBV.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkVM44GMMDcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk4UKQXGPBcjs = require('../chunk-4UKQXGPB.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-UZWS4OLZ.cjs');require('../chunk-ZCT3LXMP.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunk4UKQXGPBcjs.a;
@@ -1 +1 @@
1
- import{a}from"../chunk-NQYZGWB6.js";import"../chunk-EXC7TCGL.js";import"../chunk-46PT2BD6.js";import"../chunk-K2IXWI5K.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
1
+ import{a}from"../chunk-UU2L76MJ.js";import"../chunk-EXC7TCGL.js";import"../chunk-HUWBO6P7.js";import"../chunk-WJ6Z7KVH.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 _chunkVM44GMMDcjs = require('../chunk-VM44GMMD.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-6DCPC33F.cjs');require('../chunk-Y6CX3OBV.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkVM44GMMDcjs.a;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var _chunk4UKQXGPBcjs = require('../chunk-4UKQXGPB.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-UZWS4OLZ.cjs');require('../chunk-ZCT3LXMP.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunk4UKQXGPBcjs.a;
package/dist/api/index.js CHANGED
@@ -1 +1 @@
1
- import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-NQYZGWB6.js";import"../chunk-KBJA7JDT.js";import"../chunk-EXC7TCGL.js";import"../chunk-46PT2BD6.js";import"../chunk-K2IXWI5K.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
1
+ import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-UU2L76MJ.js";import"../chunk-KBJA7JDT.js";import"../chunk-EXC7TCGL.js";import"../chunk-HUWBO6P7.js";import"../chunk-WJ6Z7KVH.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkUYRIB3UMcjs = require('../chunk-UYRIB3UM.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-6DCPC33F.cjs');require('../chunk-Y6CX3OBV.cjs');require('../chunk-2GKPWQBQ.cjs');exports.isMainnetChain = _chunkUYRIB3UMcjs.c; exports.isTestnetChain = _chunkUYRIB3UMcjs.b; exports.isValidChain = _chunkUYRIB3UMcjs.e; exports.mainnetToTestnet = _chunkUYRIB3UMcjs.d; exports.toViemChain = _chunkUYRIB3UMcjs.a; exports.validateChainForEnvironment = _chunkUYRIB3UMcjs.f;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkMCXLP6NDcjs = require('../chunk-MCXLP6ND.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-UZWS4OLZ.cjs');require('../chunk-ZCT3LXMP.cjs');require('../chunk-2GKPWQBQ.cjs');exports.isMainnetChain = _chunkMCXLP6NDcjs.c; exports.isTestnetChain = _chunkMCXLP6NDcjs.b; exports.isValidChain = _chunkMCXLP6NDcjs.e; exports.mainnetToTestnet = _chunkMCXLP6NDcjs.d; exports.toViemChain = _chunkMCXLP6NDcjs.a; exports.validateChainForEnvironment = _chunkMCXLP6NDcjs.f;
@@ -1 +1 @@
1
- import{a,b,c,d,e,f}from"../chunk-KIKFBPJP.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-SVIKBM3S.js";import"../chunk-KKQBZXFE.js";import"../chunk-EXC7TCGL.js";import"../chunk-455NK5LB.js";import"../chunk-46PT2BD6.js";import"../chunk-K2IXWI5K.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-DLLP4CTN.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-SVIKBM3S.js";import"../chunk-KKQBZXFE.js";import"../chunk-EXC7TCGL.js";import"../chunk-455NK5LB.js";import"../chunk-HUWBO6P7.js";import"../chunk-WJ6Z7KVH.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
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkK5TQ4QU3cjs = require('./chunk-K5TQ4QU3.cjs');var _chunkATHH2TXYcjs = require('./chunk-ATHH2TXY.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkUYRIB3UMcjs = require('./chunk-UYRIB3UM.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunk6DCPC33Fcjs = require('./chunk-6DCPC33F.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var D="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",h= exports.a =class{constructor(t){this.apiClient=t}getWallet(t,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let a,n;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunkT3U46LK3cjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunkT3U46LK3cjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");a=t,n=e}else{if(this.apiClient.isServerSide)throw new (0, _chunkT3U46LK3cjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");n=t,a=this.getWalletLocator(n)}let i=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},n),{chain:_chunkUYRIB3UMcjs.f.call(void 0, n.chain,this.apiClient.environment)});_chunk6DCPC33Fcjs.a.info("walletFactory.getWallet.start");let r=yield this.apiClient.getWallet(a);if("error"in r)throw _chunk6DCPC33Fcjs.a.warn("walletFactory.getWallet.notFound",{error:r.error}),new (0, _chunkT3U46LK3cjs.e)(JSON.stringify(r));return _chunk6DCPC33Fcjs.a.info("walletFactory.getWallet.success",{address:r.address}),yield this.createWalletInstance(r,i)})}createWallet(t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o,s,g,v,W,A,k,F;let e=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{chain:_chunkUYRIB3UMcjs.f.call(void 0, t.chain,this.apiClient.environment)});if(yield(g=(s=(o=e.options)==null?void 0:o.callbacks)==null?void 0:s.onWalletCreationStart)==null?void 0:g.call(s),_chunk6DCPC33Fcjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunk6DCPC33Fcjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunkT3U46LK3cjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let a=((v=e.options)==null?void 0:v.deviceSignerKeyStorage)!=null?this.ensureDeviceSignerInSigners(e):(W=e.signers)!=null?W:[],n=yield this.registerSigners(a,e.chain,(A=e.options)==null?void 0:A.deviceSignerKeyStorage),i;if(e.recovery.type==="passkey"&&e.recovery.id==null)i=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:I}=_chunk3VSFHDFHcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);i={type:"server",address:I}}else i=e.recovery;let r=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {adminSigner:i},e.plugins?{plugins:e.plugins}:{}),n!=null?{delegatedSigners:n}:{}),owner:(k=e.owner)!=null?k:void 0,alias:(F=e.alias)!=null?F:void 0});if("error"in r)throw _chunk6DCPC33Fcjs.a.error("walletFactory.createWallet.error",{error:r.error}),new (0, _chunkT3U46LK3cjs.g)(JSON.stringify(r));return _chunk6DCPC33Fcjs.a.info("walletFactory.createWallet.success",{address:r.address}),yield this.createWalletInstance(r,e)})}createWalletInstance(t,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,g;this.validateExistingWalletConfig(t,e);let a=e,n=t.config.adminSigner,i=((s=a.recovery)==null?void 0:s.type)==="server"||((g=a.recovery)==null?void 0:g.type)==="external-wallet"?a.recovery:n,r=t.config.delegatedSigners;r!=null&&r.length===1&&(r[0].type==="server"||r[0].type==="external-wallet")&&(r=a.signers);let o=new (0, _chunkATHH2TXYcjs.a)({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:i,signers:r!=null?r:[]},this.apiClient);return yield o.waitForInit(),o})}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(n=t.name)!=null?n:`Crossmint Wallet ${Date.now()}`,a=t.onCreatePasskey?yield t.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(t){var n,i;if(t.chain==="solana")return(n=t.signers)!=null?n:[];let e=(i=t.signers)!=null?i:[];return e.some(r=>r.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&_chunkK5TQ4QU3cjs.a.call(void 0, e.owner)!==_chunkK5TQ4QU3cjs.a.call(void 0, t.owner))throw new (0, _chunkT3U46LK3cjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&t.chainType!=="solana"||e.chain!=="solana"&&t.chainType==="solana"||e.chain==="stellar"&&t.chainType!=="stellar"||e.chain!=="stellar"&&t.chainType==="stellar")throw new (0, _chunkT3U46LK3cjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let a=e;if(a.recovery!=null||a.signers!=null){let n=t.config,i=n==null?void 0:n.adminSigner;if(a.recovery!=null&&i!=null){if(a.recovery.type!==i.type)throw new (0, _chunkT3U46LK3cjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkK5TQ4QU3cjs.b.call(void 0, a.recovery,i)}let r=a.signers;r!=null&&this.validateSigners(t,r,e.chain)}}validateSigners(t,e,a){let n=t.config,i=n==null?void 0:n.delegatedSigners;if(e.length!==0){if(i==null||i.length===0)throw new (0, _chunkT3U46LK3cjs.g)(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${D}`);for(let r of e){let o=i.find(s=>{if(this.isMatchingPasskeySigner(r,s,n)||s.type==="device"&&r.type==="device")return!0;if(r.type==="server"){let{derivedAddress:g}=_chunk3VSFHDFHcjs.b.call(void 0, r,a,this.apiClient.projectId,this.apiClient.environment);return s.locator===`server:${g}`}return s.locator===_chunkNX256LAHcjs.a.call(void 0, r)});if(o==null){let s=i.map(g=>g.locator).join(", ");throw new (0, _chunkT3U46LK3cjs.g)(`Signer '${r.type}' does not exist in wallet "${t.address}". Available signers: ${s}. ${D}`)}_chunkK5TQ4QU3cjs.b.call(void 0, r,o)}}}isMatchingPasskeySigner(t,e,a){var i,r;let n=((r=(i=a.delegatedSigners)==null?void 0:i.filter(o=>o.type==="passkey").length)!=null?r:0)+(a.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&n===1)return e.type==="passkey";if(t.id==null&&n>1)throw new (0, _chunkT3U46LK3cjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,a){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;return yield Promise.all((n=t==null?void 0:t.map(i=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i.type==="passkey")return i.id==null?{signer:yield this.createPasskeySigner(i)}:{signer:i};if(i.type==="device"){if(e==="solana")throw new (0, _chunkT3U46LK3cjs.j)("Device signers are not currently supported for Solana wallets. Contact sales (https://www.crossmint.com/contact/sales) for access.");if(i.publicKey!=null)return{signer:{type:"device",publicKey:i.publicKey,name:i.name}};if(i.locator!=null)return{signer:i.locator};if(a==null)throw new (0, _chunkT3U46LK3cjs.g)("Device signer key storage is required for device signers");let r=yield _chunkYHV3672Rcjs.a.call(void 0, a);return{signer:{type:"device",publicKey:r.publicKey,name:r.name}}}if(i.type==="server"&&e!=null){let{derivedAddress:r}=_chunk3VSFHDFHcjs.b.call(void 0, i,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${r}`}}return{signer:_chunkNX256LAHcjs.a.call(void 0, i)}})))!=null?n:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6DCPC33Fcjs.a,methodName:"walletFactory.getWallet",buildContext(t,e){if(typeof e[0]=="string"){let n=e[1];return{walletLocator:e[0],chain:n==null?void 0:n.chain}}let a=e[0];return{chain:a==null?void 0:a.chain}}})],h.prototype,"getWallet",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6DCPC33Fcjs.a,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],h.prototype,"createWallet",1);exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkK5TQ4QU3cjs = require('./chunk-K5TQ4QU3.cjs');var _chunkO6VG4EVRcjs = require('./chunk-O6VG4EVR.cjs');var _chunkYHV3672Rcjs = require('./chunk-YHV3672R.cjs');var _chunkNX256LAHcjs = require('./chunk-NX256LAH.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunkMCXLP6NDcjs = require('./chunk-MCXLP6ND.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkUZWS4OLZcjs = require('./chunk-UZWS4OLZ.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var D="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",h= exports.a =class{constructor(t){this.apiClient=t}getWallet(t,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let a,n;if(typeof t=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunkT3U46LK3cjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(e==null)throw new (0, _chunkT3U46LK3cjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");a=t,n=e}else{if(this.apiClient.isServerSide)throw new (0, _chunkT3U46LK3cjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");n=t,a=this.getWalletLocator(n)}let i=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},n),{chain:_chunkMCXLP6NDcjs.f.call(void 0, n.chain,this.apiClient.environment)});_chunkUZWS4OLZcjs.a.info("walletFactory.getWallet.start");let r=yield this.apiClient.getWallet(a);if("error"in r)throw _chunkUZWS4OLZcjs.a.warn("walletFactory.getWallet.notFound",{error:r.error}),new (0, _chunkT3U46LK3cjs.e)(JSON.stringify(r));return _chunkUZWS4OLZcjs.a.info("walletFactory.getWallet.success",{address:r.address}),yield this.createWalletInstance(r,i)})}createWallet(t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o,s,g,v,W,A,k,F;let e=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{chain:_chunkMCXLP6NDcjs.f.call(void 0, t.chain,this.apiClient.environment)});if(yield(g=(s=(o=e.options)==null?void 0:o.callbacks)==null?void 0:s.onWalletCreationStart)==null?void 0:g.call(s),_chunkUZWS4OLZcjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&e.owner!=null)throw _chunkUZWS4OLZcjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunkT3U46LK3cjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let a=((v=e.options)==null?void 0:v.deviceSignerKeyStorage)!=null?this.ensureDeviceSignerInSigners(e):(W=e.signers)!=null?W:[],n=yield this.registerSigners(a,e.chain,(A=e.options)==null?void 0:A.deviceSignerKeyStorage),i;if(e.recovery.type==="passkey"&&e.recovery.id==null)i=yield this.createPasskeySigner(e.recovery);else if(e.recovery.type==="server"){let{derivedAddress:I}=_chunk3VSFHDFHcjs.b.call(void 0, e.recovery,e.chain,this.apiClient.projectId,this.apiClient.environment);i={type:"server",address:I}}else i=e.recovery;let r=yield this.apiClient.createWallet({type:"smart",chainType:this.getChainType(e.chain),config:_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {adminSigner:i},e.plugins?{plugins:e.plugins}:{}),n!=null?{delegatedSigners:n}:{}),owner:(k=e.owner)!=null?k:void 0,alias:(F=e.alias)!=null?F:void 0});if("error"in r)throw _chunkUZWS4OLZcjs.a.error("walletFactory.createWallet.error",{error:r.error}),new (0, _chunkT3U46LK3cjs.g)(JSON.stringify(r));return _chunkUZWS4OLZcjs.a.info("walletFactory.createWallet.success",{address:r.address}),yield this.createWalletInstance(r,e)})}createWalletInstance(t,e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,g;this.validateExistingWalletConfig(t,e);let a=e,n=t.config.adminSigner,i=((s=a.recovery)==null?void 0:s.type)==="server"||((g=a.recovery)==null?void 0:g.type)==="external-wallet"?a.recovery:n,r=t.config.delegatedSigners;r!=null&&r.length===1&&(r[0].type==="server"||r[0].type==="external-wallet")&&(r=a.signers);let o=new (0, _chunkO6VG4EVRcjs.a)({chain:e.chain,address:t.address,owner:t.owner,options:e.options,alias:e.alias,recovery:i,signers:r!=null?r:[]},this.apiClient);return yield o.waitForInit(),o})}getWalletLocator(t){return`me:${this.getChainType(t.chain)}:smart`+(t.alias!=null?`:alias:${t.alias}`:"")}createPasskeySigner(t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;if(t.type!=="passkey")throw new Error("Signer is not a passkey");let e=(n=t.name)!=null?n:`Crossmint Wallet ${Date.now()}`,a=t.onCreatePasskey?yield t.onCreatePasskey(e):yield _ox.WebAuthnP256.createCredential({name:e});return{type:"passkey",id:a.id,name:e,publicKey:{x:a.publicKey.x.toString(),y:a.publicKey.y.toString()}}})}ensureDeviceSignerInSigners(t){var n,i;if(t.chain==="solana")return(n=t.signers)!=null?n:[];let e=(i=t.signers)!=null?i:[];return e.some(r=>r.type==="device")?e:[...e,{type:"device"}]}validateExistingWalletConfig(t,e){if(e.owner!=null&&t.owner!=null&&_chunkK5TQ4QU3cjs.a.call(void 0, e.owner)!==_chunkK5TQ4QU3cjs.a.call(void 0, t.owner))throw new (0, _chunkT3U46LK3cjs.g)("Wallet owner does not match existing wallet's linked user");if(e.chain==="solana"&&t.chainType!=="solana"||e.chain!=="solana"&&t.chainType==="solana"||e.chain==="stellar"&&t.chainType!=="stellar"||e.chain!=="stellar"&&t.chainType==="stellar")throw new (0, _chunkT3U46LK3cjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${t.chainType}.`);if(t.type!=="smart")return;let a=e;if(a.recovery!=null||a.signers!=null){let n=t.config,i=n==null?void 0:n.adminSigner;if(a.recovery!=null&&i!=null){if(a.recovery.type!==i.type)throw new (0, _chunkT3U46LK3cjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkK5TQ4QU3cjs.b.call(void 0, a.recovery,i)}let r=a.signers;r!=null&&this.validateSigners(t,r,e.chain)}}validateSigners(t,e,a){let n=t.config,i=n==null?void 0:n.delegatedSigners;if(e.length!==0){if(i==null||i.length===0)throw new (0, _chunkT3U46LK3cjs.g)(`${e.length} signer(s) specified, but wallet "${t.address}" has no signers. ${D}`);for(let r of e){let o=i.find(s=>{if(this.isMatchingPasskeySigner(r,s,n)||s.type==="device"&&r.type==="device")return!0;if(r.type==="server"){let{derivedAddress:g}=_chunk3VSFHDFHcjs.b.call(void 0, r,a,this.apiClient.projectId,this.apiClient.environment);return s.locator===`server:${g}`}return s.locator===_chunkNX256LAHcjs.a.call(void 0, r)});if(o==null){let s=i.map(g=>g.locator).join(", ");throw new (0, _chunkT3U46LK3cjs.g)(`Signer '${r.type}' does not exist in wallet "${t.address}". Available signers: ${s}. ${D}`)}_chunkK5TQ4QU3cjs.b.call(void 0, r,o)}}}isMatchingPasskeySigner(t,e,a){var i,r;let n=((r=(i=a.delegatedSigners)==null?void 0:i.filter(o=>o.type==="passkey").length)!=null?r:0)+(a.adminSigner.type==="passkey"?1:0);if(t.type==="passkey"){if(t.id==null&&n===1)return e.type==="passkey";if(t.id==null&&n>1)throw new (0, _chunkT3U46LK3cjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(t,e,a){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var n;return yield Promise.all((n=t==null?void 0:t.map(i=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i.type==="passkey")return i.id==null?{signer:yield this.createPasskeySigner(i)}:{signer:i};if(i.type==="device"){if(e==="solana")throw new (0, _chunkT3U46LK3cjs.j)("Device signers are not currently supported for Solana wallets. Contact sales (https://www.crossmint.com/contact/sales) for access.");if(i.publicKey!=null)return{signer:{type:"device",publicKey:i.publicKey,name:i.name}};if(i.locator!=null)return{signer:i.locator};if(a==null)throw new (0, _chunkT3U46LK3cjs.g)("Device signer key storage is required for device signers");let r=yield _chunkYHV3672Rcjs.a.call(void 0, a);return{signer:{type:"device",publicKey:r.publicKey,name:r.name}}}if(i.type==="server"&&e!=null){let{derivedAddress:r}=_chunk3VSFHDFHcjs.b.call(void 0, i,e,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${r}`}}return{signer:_chunkNX256LAHcjs.a.call(void 0, i)}})))!=null?n:[])})}getChainType(t){return t==="solana"?"solana":t==="stellar"?"stellar":"evm"}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkUZWS4OLZcjs.a,methodName:"walletFactory.getWallet",buildContext(t,e){if(typeof e[0]=="string"){let n=e[1];return{walletLocator:e[0],chain:n==null?void 0:n.chain}}let a=e[0];return{chain:a==null?void 0:a.chain}}})],h.prototype,"getWallet",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkUZWS4OLZcjs.a,methodName:"walletFactory.createWallet",buildContext(t,e){return{chain:e[0].chain}}})],h.prototype,"createWallet",1);exports.a = h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunk6DCPC33Fcjs = require('./chunk-6DCPC33F.cjs');var _chunkY6CX3OBVcjs = require('./chunk-Y6CX3OBV.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:_chunkY6CX3OBVcjs.c,version:_chunkY6CX3OBVcjs.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`;_chunk6DCPC33Fcjs.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?_chunk6DCPC33Fcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunk6DCPC33Fcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk6DCPC33Fcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunk6DCPC33Fcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunk6DCPC33Fcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunk6DCPC33Fcjs.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?_chunk6DCPC33Fcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunk6DCPC33Fcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkUZWS4OLZcjs = require('./chunk-UZWS4OLZ.cjs');var _chunkZCT3LXMPcjs = require('./chunk-ZCT3LXMP.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:_chunkZCT3LXMPcjs.c,version:_chunkZCT3LXMPcjs.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`;_chunkUZWS4OLZcjs.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?_chunkUZWS4OLZcjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkUZWS4OLZcjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkUZWS4OLZcjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkUZWS4OLZcjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkUZWS4OLZcjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getSignature(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkUZWS4OLZcjs.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?_chunkUZWS4OLZcjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkUZWS4OLZcjs.a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===_commonsdkbase.APIKeyUsageOrigin.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkT3U46LK3cjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
@@ -1 +1 @@
1
- import{a as g}from"./chunk-O6VBO7KG.js";import{a as l}from"./chunk-6RX65NOA.js";import{a as o}from"./chunk-46PT2BD6.js";import{c as m,g as a}from"./chunk-J3R36SGJ.js";import{validateAPIKey as p,WithLoggerContext as w}from"@crossmint/common-sdk-base";var f=class{constructor(r){this.config=r;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return a(this,null,function*(){try{if(this.config.clientTEEConnection==null){let r=p(this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new g({environment:r.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return a(this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return a(this,null,function*(){o.info("TEE connection not initialized, initializing now");let r=p(this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new g({environment:r.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");o.info("TEE connection initialized successfully")})}handleAuthRequired(){return a(this,null,function*(){var u;let r=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);o.info("get-status: sending request");let t=Date.now(),n=yield r.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),i=Date.now()-t;if((n==null?void 0:n.status)!=="success")throw o.error("get-status: failed",{status:n==null?void 0:n.status,error:n==null?void 0:n.error,durationMs:i}),new Error(n==null?void 0:n.error);if(o.info("get-status: response received",{signerStatus:n.signerStatus,durationMs:i}),n.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:h,reject:c}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:h,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>a(this,null,function*(){o.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new l)})),c(new l)}))}catch(e){o.error("handleAuthRequired error",{error:e}),c(e)}try{yield s}catch(e){throw o.error("handleAuthRequired promise error",{error:e}),e}})}ensureAuthenticated(){return a(this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let r=this.config.crossmint.jwt;if(r==null)throw new Error("JWT is required");return r}createAuthPromise(){let r,t;return{promise:new Promise((i,s)=>{r=i,t=s}),resolve:r,reject:t}}sendMessageWithOtp(){return a(this,null,function*(){var h,c;let r=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let n=Date.now(),i=yield r.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(h=this.config.crossmint.jwt)!=null?h:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),s=Date.now()-n;if(o.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:s}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}(i==null?void 0:i.status)==="error"&&(o.error("start-onboarding: failed",{error:i.error}),(c=this._authPromise)==null||c.reject(new Error(i.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(r){return a(this,null,function*(){var s,h,c,u;let t;try{let e=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let E=Date.now();t=yield e.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:r}}},options:d}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(e){throw o.error("complete-onboarding: error",{error:e}),this._needsAuth=!0,(h=this._authPromise)==null||h.reject(e),e}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new l)})),(c=this._authPromise)==null||c.resolve();return}o.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let n=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",i=new Error(n);throw(u=this._authPromise)==null||u.reject(i),i})}_exportPrivateKey(r){return a(this,null,function*(){yield this.handleAuthRequired();let t=this.getJwtOrThrow(),{scheme:n,encoding:i}=this.getChainKeyParams(),s=yield r.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:t,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:i}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};m([w({logger:o,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};export{f as a,d as b};
1
+ import{a as g}from"./chunk-O6VBO7KG.js";import{a as l}from"./chunk-6RX65NOA.js";import{a as o}from"./chunk-HUWBO6P7.js";import{c as m,g as a}from"./chunk-J3R36SGJ.js";import{validateAPIKey as p,WithLoggerContext as w}from"@crossmint/common-sdk-base";var f=class{constructor(r){this.config=r;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return a(this,null,function*(){try{if(this.config.clientTEEConnection==null){let r=p(this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new g({environment:r.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return a(this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return a(this,null,function*(){o.info("TEE connection not initialized, initializing now");let r=p(this.config.crossmint.apiKey);if(!r.isValid)throw new Error("Invalid API key");let t=new g({environment:r.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");o.info("TEE connection initialized successfully")})}handleAuthRequired(){return a(this,null,function*(){var u;let r=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);o.info("get-status: sending request");let t=Date.now(),n=yield r.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),i=Date.now()-t;if((n==null?void 0:n.status)!=="success")throw o.error("get-status: failed",{status:n==null?void 0:n.status,error:n==null?void 0:n.error,durationMs:i}),new Error(n==null?void 0:n.error);if(o.info("get-status: response received",{signerStatus:n.signerStatus,durationMs:i}),n.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;o.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:h,reject:c}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:h,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>a(this,null,function*(){o.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new l)})),c(new l)}))}catch(e){o.error("handleAuthRequired error",{error:e}),c(e)}try{yield s}catch(e){throw o.error("handleAuthRequired promise error",{error:e}),e}})}ensureAuthenticated(){return a(this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let r=this.config.crossmint.jwt;if(r==null)throw new Error("JWT is required");return r}createAuthPromise(){let r,t;return{promise:new Promise((i,s)=>{r=i,t=s}),resolve:r,reject:t}}sendMessageWithOtp(){return a(this,null,function*(){var h,c;let r=yield this.getTEEConnection(),t=this.getAuthId();o.info("start-onboarding: sending request");let n=Date.now(),i=yield r.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(h=this.config.crossmint.jwt)!=null?h:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),s=Date.now()-n;if(o.info("start-onboarding: response received",{status:i==null?void 0:i.status,durationMs:s}),(i==null?void 0:i.status)==="success"&&i.signerStatus==="ready"){this._needsAuth=!1;return}(i==null?void 0:i.status)==="error"&&(o.error("start-onboarding: failed",{error:i.error}),(c=this._authPromise)==null||c.reject(new Error(i.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(r){return a(this,null,function*(){var s,h,c,u;let t;try{let e=yield this.getTEEConnection();o.info("complete-onboarding: sending request");let E=Date.now();t=yield e.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:r}}},options:d}),o.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(e){throw o.error("complete-onboarding: error",{error:e}),this._needsAuth=!0,(h=this._authPromise)==null||h.reject(e),e}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new l)})),(c=this._authPromise)==null||c.resolve();return}o.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let n=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",i=new Error(n);throw(u=this._authPromise)==null||u.reject(i),i})}_exportPrivateKey(r){return a(this,null,function*(){yield this.handleAuthRequired();let t=this.getJwtOrThrow(),{scheme:n,encoding:i}=this.getChainKeyParams(),s=yield r.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:t,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:i}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};m([w({logger:o,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};export{f as a,d as b};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGZP2JQ6Pcjs = require('./chunk-GZP2JQ6P.cjs');var _chunkYXM5QQWLcjs = require('./chunk-YXM5QQWL.cjs');var _chunk4SZDDY2Pcjs = require('./chunk-4SZDDY2P.cjs');var _chunkUOQMZXMCcjs = require('./chunk-UOQMZXMC.cjs');var _chunkSPTXAOFRcjs = require('./chunk-SPTXAOFR.cjs');var _chunkGEY3BU62cjs = require('./chunk-GEY3BU62.cjs');var _chunkPHPBBEXUcjs = require('./chunk-PHPBBEXU.cjs');var _chunkA33BEWR7cjs = require('./chunk-A33BEWR7.cjs');var _chunkOGP7B5O3cjs = require('./chunk-OGP7B5O3.cjs');var _chunkIJ632UXDcjs = require('./chunk-IJ632UXD.cjs');var _chunk6EZCCLTKcjs = require('./chunk-6EZCCLTK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');function M(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new (0, _chunkUOQMZXMCcjs.a)(e):r==="stellar"?new (0, _chunkYXM5QQWLcjs.a)(e):new (0, _chunk4SZDDY2Pcjs.a)(e);case"api-key":return r==="solana"?new (0, _chunkIJ632UXDcjs.a)(e):new (0, _chunkPHPBBEXUcjs.a)(e);case"external-wallet":return r==="solana"?new (0, _chunk6EZCCLTKcjs.a)(e):r==="stellar"?new (0, _chunkSPTXAOFRcjs.a)(e):new (0, _chunkA33BEWR7cjs.a)(e);case"server":return _chunkGZP2JQ6Pcjs.a.call(void 0, r,e);case"passkey":return new (0, _chunkOGP7B5O3cjs.a)(e);case"device":if(n==null)throw new (0, _chunkT3U46LK3cjs.g)("Device signer key storage is required for device signers");return new (0, _chunkGEY3BU62cjs.a)(e,n)}}exports.a = M;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGZP2JQ6Pcjs = require('./chunk-GZP2JQ6P.cjs');var _chunkMJ44COEVcjs = require('./chunk-MJ44COEV.cjs');var _chunkKZYWN2DLcjs = require('./chunk-KZYWN2DL.cjs');var _chunkGKWN7JSLcjs = require('./chunk-GKWN7JSL.cjs');var _chunkSPTXAOFRcjs = require('./chunk-SPTXAOFR.cjs');var _chunkGEY3BU62cjs = require('./chunk-GEY3BU62.cjs');var _chunkPHPBBEXUcjs = require('./chunk-PHPBBEXU.cjs');var _chunkA33BEWR7cjs = require('./chunk-A33BEWR7.cjs');var _chunkOGP7B5O3cjs = require('./chunk-OGP7B5O3.cjs');var _chunkIJ632UXDcjs = require('./chunk-IJ632UXD.cjs');var _chunk6EZCCLTKcjs = require('./chunk-6EZCCLTK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');function M(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new (0, _chunkGKWN7JSLcjs.a)(e):r==="stellar"?new (0, _chunkMJ44COEVcjs.a)(e):new (0, _chunkKZYWN2DLcjs.a)(e);case"api-key":return r==="solana"?new (0, _chunkIJ632UXDcjs.a)(e):new (0, _chunkPHPBBEXUcjs.a)(e);case"external-wallet":return r==="solana"?new (0, _chunk6EZCCLTKcjs.a)(e):r==="stellar"?new (0, _chunkSPTXAOFRcjs.a)(e):new (0, _chunkA33BEWR7cjs.a)(e);case"server":return _chunkGZP2JQ6Pcjs.a.call(void 0, r,e);case"passkey":return new (0, _chunkOGP7B5O3cjs.a)(e);case"device":if(n==null)throw new (0, _chunkT3U46LK3cjs.g)("Device signer key storage is required for device signers");return new (0, _chunkGEY3BU62cjs.a)(e,n)}}exports.a = M;
@@ -1 +1 @@
1
- import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{b as i,c as s}from"./chunk-EXC7TCGL.js";import{a as E}from"./chunk-46PT2BD6.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as N,arbitrum as p,arbitrumNova as R,modeTestnet as h,mode as d,bsc as f,shape as W,zora as V,zoraSepolia as B,sepolia as U,flowMainnet as y,flowTestnet as v,plume as H,plumeTestnet as x}from"viem/chains";var b=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],w=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function X(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return N;case e.ARBITRUM:return p;case e.ARBITRUMNOVA:return R;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return f;case e.SHAPE:return W;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return U;case e.FLOW:return y;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return x;case e.PLUME:return H;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return b.includes(t)}function C(t){return w.includes(t)}var D={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function Y(t){return D[t]}function g(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function ee(t,a){if(!g(t))throw new s(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=Y(r);if(n!=null)return E.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;E.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}export{X as a,I as b,C as c,Y as d,g as e,ee as f};
1
+ import{a as A}from"./chunk-S3DYQVRD.js";import{a as O}from"./chunk-KUP7H7X2.js";import{a as l}from"./chunk-FT5EVMLB.js";import{a as o}from"./chunk-SVIKBM3S.js";import{a as S}from"./chunk-KKQBZXFE.js";import{b as i,c as s}from"./chunk-EXC7TCGL.js";import{a as E}from"./chunk-HUWBO6P7.js";import{APIKeyEnvironmentPrefix as M,BlockchainIncludingTestnet as e}from"@crossmint/common-sdk-base";import{baseSepolia as m,base as _,polygonAmoy as L,polygon as P,optimismSepolia as u,optimism as c,arbitrumSepolia as N,arbitrum as p,arbitrumNova as R,modeTestnet as h,mode as d,bsc as f,shape as W,zora as V,zoraSepolia as B,sepolia as U,flowMainnet as y,flowTestnet as v,plume as H,plumeTestnet as x}from"viem/chains";var b=[e.ABSTRACT_TESTNET,e.ARBITRUM_SEPOLIA,e.BASE_SEPOLIA,e.CURTIS,e.ETHEREUM_SEPOLIA,e.FLOW_TESTNET,e.MANTLE_SEPOLIA,e.MODE_SEPOLIA,e.OPTIMISM_SEPOLIA,e.PLUME_TESTNET,e.POLYGON_AMOY,e.SCROLL_SEPOLIA,e.SEI_ATLANTIC_2_TESTNET,e.STORY_TESTNET,e.WORLD_CHAIN_SEPOLIA,e.ZORA_SEPOLIA,e.ARC_TESTNET,e.TEMPO_TESTNET],w=[e.ABSTRACT,e.APECHAIN,e.ARBITRUM,e.ARBITRUMNOVA,e.BASE,e.BSC,e.FLOW,e.MANTLE,e.MODE,e.OPTIMISM,e.PLUME,e.POLYGON,e.SCROLL,e.SEI_PACIFIC_1,e.SHAPE,e.STORY,e.TEMPO,e.WORLDCHAIN,e.ZORA];function X(t){switch(t){case e.BASE_SEPOLIA:return m;case e.BASE:return _;case e.POLYGON_AMOY:return L;case e.POLYGON:return P;case e.OPTIMISM_SEPOLIA:return u;case e.OPTIMISM:return c;case e.ARBITRUM_SEPOLIA:return N;case e.ARBITRUM:return p;case e.ARBITRUMNOVA:return R;case e.STORY_TESTNET:return A;case e.STORY:return S;case e.MODE_SEPOLIA:return h;case e.MODE:return d;case e.BSC:return f;case e.SHAPE:return W;case e.ZORA:return V;case e.ZORA_SEPOLIA:return B;case e.ETHEREUM_SEPOLIA:return U;case e.FLOW:return y;case e.FLOW_TESTNET:return v;case e.PLUME_TESTNET:return x;case e.PLUME:return H;case e.ARC_TESTNET:return o;case e.TEMPO:return O;case e.TEMPO_TESTNET:return l;case e.ABSTRACT:case e.ABSTRACT_TESTNET:case e.APECHAIN:case e.MANTLE:case e.MANTLE_SEPOLIA:case e.SCROLL:case e.SCROLL_SEPOLIA:case e.SEI_PACIFIC_1:case e.SEI_ATLANTIC_2_TESTNET:case e.CURTIS:case e.WORLDCHAIN:case e.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return b.includes(t)}function C(t){return w.includes(t)}var D={[e.ABSTRACT]:e.ABSTRACT_TESTNET,[e.APECHAIN]:e.CURTIS,[e.ARBITRUM]:e.ARBITRUM_SEPOLIA,[e.BASE]:e.BASE_SEPOLIA,[e.FLOW]:e.FLOW_TESTNET,[e.MANTLE]:e.MANTLE_SEPOLIA,[e.MODE]:e.MODE_SEPOLIA,[e.OPTIMISM]:e.OPTIMISM_SEPOLIA,[e.PLUME]:e.PLUME_TESTNET,[e.POLYGON]:e.POLYGON_AMOY,[e.SCROLL]:e.SCROLL_SEPOLIA,[e.SEI_PACIFIC_1]:e.SEI_ATLANTIC_2_TESTNET,[e.STORY]:e.STORY_TESTNET,[e.WORLDCHAIN]:e.WORLD_CHAIN_SEPOLIA,[e.ZORA]:e.ZORA_SEPOLIA,[e.TEMPO]:e.TEMPO_TESTNET};function Y(t){return D[t]}function g(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function ee(t,a){if(!g(t))throw new s(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===M.PRODUCTION;if(T&&I(r))throw new i(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=Y(r);if(n!=null)return E.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;E.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}export{X as a,I as b,C as c,Y as d,g as e,ee as f};
@@ -1 +1 @@
1
- import{a as v}from"./chunk-IOSADDL5.js";import{a as l}from"./chunk-46PT2BD6.js";import{c as d,g as n}from"./chunk-J3R36SGJ.js";import{getEnvironmentForKey as E,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as w}from"ox";var b={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},P=6e4,K="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;let r=E(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=b[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${P}ms`))},P);function p(y){let m=y.data;m==null||m.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),m.type==="error"&&m.code===K?s({fatal:!0}):m.type==="error"?o(new Error(m.error)):s({value:m.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield w.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield w.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};d([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
1
+ import{a as v}from"./chunk-IOSADDL5.js";import{a as l}from"./chunk-HUWBO6P7.js";import{c as d,g as n}from"./chunk-J3R36SGJ.js";import{getEnvironmentForKey as E,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as w}from"ox";var b={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},P=6e4,K="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;let r=E(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=b[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${P}ms`))},P);function p(y){let m=y.data;m==null||m.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),m.type==="error"&&m.code===K?s({fatal:!0}):m.type==="error"?o(new Error(m.error)):s({value:m.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield w.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield w.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};d([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),d([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
@@ -1 +1 @@
1
- import{a as S}from"./chunk-6X5JEJD7.js";import{a as l}from"./chunk-3RJ2OR3P.js";import{a as i}from"./chunk-2WWBXNRB.js";import{a as t}from"./chunk-7LTZRBP6.js";import{a as C}from"./chunk-EE4ITUGS.js";import{a as u}from"./chunk-CKZYSQOK.js";import{a as p}from"./chunk-QVTKTDED.js";import{a as s}from"./chunk-XS5B3TUE.js";import{a as m}from"./chunk-M335XCYO.js";import{a as g}from"./chunk-YH7G2U6V.js";import{a as o}from"./chunk-W7LJS32A.js";import{g as a}from"./chunk-EXC7TCGL.js";function V(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new t(e):r==="stellar"?new l(e):new i(e);case"api-key":return r==="solana"?new g(e):new p(e);case"external-wallet":return r==="solana"?new o(e):r==="stellar"?new C(e):new s(e);case"server":return S(r,e);case"passkey":return new m(e);case"device":if(n==null)throw new a("Device signer key storage is required for device signers");return new u(e,n)}}export{V as a};
1
+ import{a as S}from"./chunk-6X5JEJD7.js";import{a as l}from"./chunk-IWDL4WB7.js";import{a as i}from"./chunk-NRSO3EOP.js";import{a as t}from"./chunk-L2WKVC6H.js";import{a as C}from"./chunk-EE4ITUGS.js";import{a as u}from"./chunk-CKZYSQOK.js";import{a as p}from"./chunk-QVTKTDED.js";import{a as s}from"./chunk-XS5B3TUE.js";import{a as m}from"./chunk-M335XCYO.js";import{a as g}from"./chunk-YH7G2U6V.js";import{a as o}from"./chunk-W7LJS32A.js";import{g as a}from"./chunk-EXC7TCGL.js";function V(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new t(e):r==="stellar"?new l(e):new i(e);case"api-key":return r==="solana"?new g(e):new p(e);case"external-wallet":return r==="solana"?new o(e):r==="stellar"?new C(e):new s(e);case"server":return S(r,e);case"passkey":return new m(e);case"device":if(n==null)throw new a("Device signer key storage is required for device signers");return new u(e,n)}}export{V as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkATHH2TXYcjs = require('./chunk-ATHH2TXY.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunk6EZCCLTKcjs = require('./chunk-6EZCCLTK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunk6DCPC33Fcjs = require('./chunk-6DCPC33F.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunkATHH2TXYcjs.a{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:_chunkATHH2TXYcjs.a.getOptions(n),alias:n.alias,recovery:_chunkATHH2TXYcjs.a.getRecovery(n),signer:n.signer,signers:_chunkATHH2TXYcjs.a.getInitialSigners(n)},_chunkATHH2TXYcjs.a.getApiClient(n))}static from(n){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d,p;_chunk6DCPC33Fcjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return _chunk6DCPC33Fcjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let t={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(c=>new (0, _chunk6EZCCLTKcjs.a)({type:"external-wallet",address:c.publicKey.toString(),locator:`external-wallet:${c.publicKey.toString()}`,onSign:h=>(h.sign([c]),Promise.resolve(h))}))},a=yield this.approveTransactionAndWait(e.id,t);return _chunk6DCPC33Fcjs.a.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:a.hash}),a})}createTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a;let e;((a=n.options)==null?void 0:a.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${_chunk3VSFHDFHcjs.b.call(void 0, n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=_bs582.default.encode(n.transaction.serialize());let t=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in t)throw new (0, _chunkT3U46LK3cjs.t)(JSON.stringify(t));return t})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunk6DCPC33Fcjs.a,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;exports.a = S;
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkO6VG4EVRcjs = require('./chunk-O6VG4EVR.cjs');var _chunk3VSFHDFHcjs = require('./chunk-3VSFHDFH.cjs');var _chunk6EZCCLTKcjs = require('./chunk-6EZCCLTK.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkUZWS4OLZcjs = require('./chunk-UZWS4OLZ.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunkO6VG4EVRcjs.a{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:_chunkO6VG4EVRcjs.a.getOptions(n),alias:n.alias,recovery:_chunkO6VG4EVRcjs.a.getRecovery(n),signer:n.signer,signers:_chunkO6VG4EVRcjs.a.getInitialSigners(n)},_chunkO6VG4EVRcjs.a.getApiClient(n))}static from(n){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var d,p;_chunkUZWS4OLZcjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return _chunkUZWS4OLZcjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let t={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(c=>new (0, _chunk6EZCCLTKcjs.a)({type:"external-wallet",address:c.publicKey.toString(),locator:`external-wallet:${c.publicKey.toString()}`,onSign:h=>(h.sign([c]),Promise.resolve(h))}))},a=yield this.approveTransactionAndWait(e.id,t);return _chunkUZWS4OLZcjs.a.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:a.hash}),a})}createTransaction(n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a;let e;((a=n.options)==null?void 0:a.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${_chunk3VSFHDFHcjs.b.call(void 0, n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=_bs582.default.encode(n.transaction.serialize());let t=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in t)throw new (0, _chunkT3U46LK3cjs.t)(JSON.stringify(t));return t})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkUZWS4OLZcjs.a,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;exports.a = S;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunkQJGO3XB4cjs = require('./chunk-QJGO3XB4.cjs');var _chunk6DCPC33Fcjs = require('./chunk-6DCPC33F.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 _chunkQJGO3XB4cjs.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();_chunk6DCPC33Fcjs.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:_chunkQJGO3XB4cjs.b});if(_chunk6DCPC33Fcjs.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 _chunkTFC7TYGWcjs = require('./chunk-TFC7TYGW.cjs');var _chunkUZWS4OLZcjs = require('./chunk-UZWS4OLZ.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 _chunkTFC7TYGWcjs.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();_chunkUZWS4OLZcjs.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:_chunkTFC7TYGWcjs.b});if(_chunkUZWS4OLZcjs.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-2MUNT6EY.js";import{b as T}from"./chunk-RBSMBO4T.js";import{a as f}from"./chunk-W7LJS32A.js";import{t as g}from"./chunk-EXC7TCGL.js";import{a as r}from"./chunk-46PT2BD6.js";import{c as u,g as l}from"./chunk-J3R36SGJ.js";import m from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as C}from"@crossmint/common-sdk-base";var o=class o extends i{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:i.getOptions(n),alias:n.alias,recovery:i.getRecovery(n),signer:n.signer,signers:i.getInitialSigners(n)},i.getApiClient(n))}static from(n){if(!y(n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return l(this,null,function*(){var d,p;r.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return r.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let t={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(c=>new f({type:"external-wallet",address:c.publicKey.toString(),locator:`external-wallet:${c.publicKey.toString()}`,onSign:h=>(h.sign([c]),Promise.resolve(h))}))},a=yield this.approveTransactionAndWait(e.id,t);return r.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:a.hash}),a})}createTransaction(n){return l(this,null,function*(){var a;let e;((a=n.options)==null?void 0:a.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${T(n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=m.encode(n.transaction.serialize());let t=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in t)throw new g(JSON.stringify(t));return t})}};u([C({logger:r,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;export{S as a};
1
+ import{a as i}from"./chunk-KKBYSFTH.js";import{b as T}from"./chunk-RBSMBO4T.js";import{a as f}from"./chunk-W7LJS32A.js";import{t as g}from"./chunk-EXC7TCGL.js";import{a as r}from"./chunk-HUWBO6P7.js";import{c as u,g as l}from"./chunk-J3R36SGJ.js";import m from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as C}from"@crossmint/common-sdk-base";var o=class o extends i{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:i.getOptions(n),alias:n.alias,recovery:i.getRecovery(n),signer:n.signer,signers:i.getInitialSigners(n)},i.getApiClient(n))}static from(n){if(!y(n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return l(this,null,function*(){var d,p;r.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return r.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let t={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(c=>new f({type:"external-wallet",address:c.publicKey.toString(),locator:`external-wallet:${c.publicKey.toString()}`,onSign:h=>(h.sign([c]),Promise.resolve(h))}))},a=yield this.approveTransactionAndWait(e.id,t);return r.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:a.hash}),a})}createTransaction(n){return l(this,null,function*(){var a;let e;((a=n.options)==null?void 0:a.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${T(n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=m.encode(n.transaction.serialize());let t=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in t)throw new g(JSON.stringify(t));return t})}};u([C({logger:r,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;export{S as a};
@@ -1 +1 @@
1
- import{b as n,c as i}from"./chunk-K2IXWI5K.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
1
+ import{b as n,c as i}from"./chunk-WJ6Z7KVH.js";import{SdkLogger as d,BrowserDatadogSink as k,detectPlatform as g,validateAPIKey as l,ServerDatadogSink as m}from"@crossmint/common-sdk-base";var t=new d;function f(s){let o=g(),e=l(s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:i,packageVersion:n,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new k(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new m(a);t.addSink(r);break}default:break}}export{t as a,f as b};
@@ -1 +1 @@
1
- import{a as o}from"./chunk-2MUNT6EY.js";import{b as w}from"./chunk-RBSMBO4T.js";import{a as S}from"./chunk-KIKFBPJP.js";import{l as u,p as g,t as C}from"./chunk-EXC7TCGL.js";import{a as r}from"./chunk-46PT2BD6.js";import{c as p,g as l}from"./chunk-J3R36SGJ.js";import{createPublicClient as x,encodeFunctionData as E,http as O}from"viem";import{isValidEvmAddress as b,WithLoggerContext as h}from"@crossmint/common-sdk-base";var d=class d 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),signer:e.signer,signers:o.getInitialSigners(e)},o.getApiClient(e))}static from(e){if(!b(e.address))throw new Error("Wallet is not an EVM wallet");return new d(e)}sendTransaction(e){return l(this,null,function*(){var i;r.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=this.buildTransaction(e),t=yield this.createTransaction(n,e.options);if((i=e.options)!=null&&i.prepareOnly)return r.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return r.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return l(this,null,function*(){var i;r.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:n.locator(),chain:this.chain}});if("error"in t)throw r.error("evmWallet.signMessage.error",{error:t}),new g(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return r.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return r.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return l(this,null,function*(){var I;r.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),{domain:t,message:a,primaryType:i,types:c,chain:m}=e;if(!t||!a||!c||!m)throw r.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new u("Invalid typed data");let{name:T,version:f,chainId:y,verifyingContract:v,salt:D}=t;if(!T||!f||!y||!v)throw r.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new u("Invalid typed data domain");let s=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:T,version:f,chainId:Number(y),verifyingContract:v,salt:D},message:a,primaryType:i,types:c},signer:n.locator(),chain:m}});if("error"in s)throw r.error("evmWallet.signTypedData.error",{error:s}),new g(JSON.stringify(s));if((I=e.options)!=null&&I.prepareOnly)return r.info("evmWallet.signTypedData.prepared",{signatureId:s.id}),{signature:void 0,signatureId:s.id};let M=yield this.approveSignatureAndWait(s.id);return r.info("evmWallet.signTypedData.success",{signatureId:s.id}),M})}getViemClient(e){var n;return x({transport:(n=e==null?void 0:e.transport)!=null?n:O(),chain:S(this.chain)})}createTransaction(e,n){return l(this,null,function*(){let t;(n==null?void 0:n.signer)==null?t=this.requireSigner().locator():typeof n.signer=="string"?t=n.signer:t=`server:${w(n.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new C(JSON.stringify(a));return a})}buildTransaction(e){var n,t,a,i,c;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(n=e.value)==null?void 0:n.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(c=(i=e.value)==null?void 0:i.toString())!=null?c:"0",data:E({abi:e.abi,functionName:e.functionName,args:e.args})}}};p([h({logger:r,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"sendTransaction",1),p([h({logger:r,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"signMessage",1),p([h({logger:r,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"signTypedData",1);var W=d;export{W as a};
1
+ import{a as o}from"./chunk-KKBYSFTH.js";import{b as w}from"./chunk-RBSMBO4T.js";import{a as S}from"./chunk-DLLP4CTN.js";import{l as u,p as g,t as C}from"./chunk-EXC7TCGL.js";import{a as r}from"./chunk-HUWBO6P7.js";import{c as p,g as l}from"./chunk-J3R36SGJ.js";import{createPublicClient as x,encodeFunctionData as E,http as O}from"viem";import{isValidEvmAddress as b,WithLoggerContext as h}from"@crossmint/common-sdk-base";var d=class d 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),signer:e.signer,signers:o.getInitialSigners(e)},o.getApiClient(e))}static from(e){if(!b(e.address))throw new Error("Wallet is not an EVM wallet");return new d(e)}sendTransaction(e){return l(this,null,function*(){var i;r.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=this.buildTransaction(e),t=yield this.createTransaction(n,e.options);if((i=e.options)!=null&&i.prepareOnly)return r.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return r.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return l(this,null,function*(){var i;r.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:n.locator(),chain:this.chain}});if("error"in t)throw r.error("evmWallet.signMessage.error",{error:t}),new g(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return r.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return r.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return l(this,null,function*(){var I;r.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),{domain:t,message:a,primaryType:i,types:c,chain:m}=e;if(!t||!a||!c||!m)throw r.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new u("Invalid typed data");let{name:T,version:f,chainId:y,verifyingContract:v,salt:D}=t;if(!T||!f||!y||!v)throw r.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new u("Invalid typed data domain");let s=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:T,version:f,chainId:Number(y),verifyingContract:v,salt:D},message:a,primaryType:i,types:c},signer:n.locator(),chain:m}});if("error"in s)throw r.error("evmWallet.signTypedData.error",{error:s}),new g(JSON.stringify(s));if((I=e.options)!=null&&I.prepareOnly)return r.info("evmWallet.signTypedData.prepared",{signatureId:s.id}),{signature:void 0,signatureId:s.id};let M=yield this.approveSignatureAndWait(s.id);return r.info("evmWallet.signTypedData.success",{signatureId:s.id}),M})}getViemClient(e){var n;return x({transport:(n=e==null?void 0:e.transport)!=null?n:O(),chain:S(this.chain)})}createTransaction(e,n){return l(this,null,function*(){let t;(n==null?void 0:n.signer)==null?t=this.requireSigner().locator():typeof n.signer=="string"?t=n.signer:t=`server:${w(n.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new C(JSON.stringify(a));return a})}buildTransaction(e){var n,t,a,i,c;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(n=e.value)==null?void 0:n.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(c=(i=e.value)==null?void 0:i.toString())!=null?c:"0",data:E({abi:e.abi,functionName:e.functionName,args:e.args})}}};p([h({logger:r,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"sendTransaction",1),p([h({logger:r,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"signMessage",1),p([h({logger:r,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],d.prototype,"signTypedData",1);var W=d;export{W as a};
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-4RI43OYI.js";import{a as r}from"./chunk-46PT2BD6.js";import{g as t}from"./chunk-J3R36SGJ.js";var a=class g extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();r.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};export{a};
1
+ import{a as s,b as o}from"./chunk-BKBD4C7T.js";import{a as r}from"./chunk-HUWBO6P7.js";import{g as t}from"./chunk-J3R36SGJ.js";var a=class g extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();r.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};export{a};
@@ -1,3 +1,3 @@
1
- import{a as oe}from"./chunk-N4IWDL6M.js";import{a as P}from"./chunk-GOXB2RBF.js";import{b as j,c as _}from"./chunk-VADIEIDS.js";import{a as $}from"./chunk-OMIBDAQS.js";import{b as W}from"./chunk-RBSMBO4T.js";import{a as se}from"./chunk-4RI43OYI.js";import{a as ae,b as D}from"./chunk-6RX65NOA.js";import{f as ne}from"./chunk-KIKFBPJP.js";import{B as ie,d as M,e as U,j as q,n as V,q as H,r as z,s as Y,t as Q,u as G,v as X,w as Z,x as ee,y as re,z as te}from"./chunk-EXC7TCGL.js";import{a}from"./chunk-46PT2BD6.js";import{d as J}from"./chunk-K2IXWI5K.js";import{a as b,b as F,c as E,d as i,e as x,f as p,g as c}from"./chunk-J3R36SGJ.js";import{isValidAddress as le,WithLoggerContext as k}from"@crossmint/common-sdk-base";var S,C,u,w,R,T,N,O,L,A=class{constructor(e,r){x(this,S);x(this,C);x(this,u);x(this,w);x(this,R);x(this,T,!1);x(this,N,!1);x(this,O);x(this,L,null);let{chain:t,address:n,owner:s,options:d,alias:o,recovery:l,signers:g,signer:h}=e;p(this,u,r),this.chain=t,this.address=n,this.owner=s,p(this,C,d),this.alias=o,p(this,w,l),p(this,R,g!=null?g:[]),p(this,S,h),p(this,O,this.initDefaultSigner())}get signer(){return i(this,S)}waitForInit(){return c(this,null,function*(){yield i(this,O)})}initDeviceSigner(){return c(this,null,function*(){var n;let e=(n=i(this,C))==null?void 0:n.deviceSignerKeyStorage;if(e==null||this.chain==="solana")return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(s){a.error("wallet.initDeviceSigner.error",{error:s}),p(this,T,!0);return}if(i(this,T))return;let t=this.buildInternalSignerConfig(r);p(this,S,yield this.assembleFullSigner(t,e))})}initDefaultSigner(){return c(this,null,function*(){if(i(this,S)!=null||(yield this.initDeviceSigner(),i(this,S)!=null||i(this,T)))return;let e=i(this,R).length===0?i(this,w):i(this,R).length===1?i(this,R)[0]:null;if(e!=null&&this.isAutoAssemblableSignerConfig(e))try{let r=this.buildInternalSignerConfig(e);p(this,S,yield this.assembleFullSigner(r))}catch(r){a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,w).type,signerCount:i(this,R).length,error:r})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return i(e,w)}static getInitialSigners(e){return i(e,R)}get apiClient(){return i(this,u)}get options(){return i(this,C)}get recovery(){return i(this,w)}balances(e){return c(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t;switch(this.chain){case"solana":t="sol";break;case"stellar":t="xlm";break;default:t="eth";break}let n=[t,"usdc",...e!=null?e:[]],s=yield i(this,u).getBalance(this.address,{chains:[r],tokens:n});if("error"in s)throw a.error("wallet.balances.error",{error:s}),new Error(`Failed to get balances for wallet: ${JSON.stringify(s.message)}`);return a.info("wallet.balances.success"),this.transformBalanceResponse(s,t,e)})}stagingFund(e,r){return c(this,null,function*(){a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return a.info("wallet.stagingFund.success"),t})}transformBalanceResponse(e,r,t){let n=g=>{var y,m,I,K,B;let h=(y=g.chains)==null?void 0:y[this.chain],f={};return this.chain==="solana"&&h!=null&&"mintHash"in h?f={mintHash:h.mintHash}:this.chain==="stellar"&&h!=null&&"contractId"in h?f={contractId:h.contractId}:h!=null&&"contractAddress"in h&&(f={contractAddress:h.contractAddress}),b({symbol:(m=g.symbol)!=null?m:"",name:(I=g.name)!=null?I:"",amount:(K=g.amount)!=null?K:"0",decimals:g.decimals,rawAmount:(B=g.rawAmount)!=null?B:"0"},f)},s=e.find(g=>g.symbol===r),d=e.find(g=>g.symbol==="usdc"),o=e.filter(g=>{var h;return g.symbol!==r&&g.symbol!=="usdc"&&(t==null||t.includes((h=g.symbol)!=null?h:""))}),l=g=>{let h={symbol:g,name:g,amount:"0",decimals:0,rawAmount:"0"},f={};return this.chain==="solana"?f={mintHash:void 0}:this.chain==="stellar"?f={contractId:void 0}:f={contractAddress:void 0},b(b({},h),f)};return{nativeToken:s!=null?n(s):l(r),usdc:d!=null?n(d):l("usdc"),tokens:o.map(n)}}nfts(e){return c(this,null,function*(){return yield i(this,u).getNfts(F(b({},e),{chain:this.chain,address:this.address}))})}transactions(){return c(this,null,function*(){let e=yield i(this,u).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return c(this,null,function*(){let r=yield i(this,u).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return c(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return c(this,null,function*(){let s=this.resolveChainForEnvironment(),d=de(e),o=he(r,s),l=Number(t);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new Y(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);a.info("wallet.send.start",b({recipient:d,token:o,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let g=this.requireSigner(),h;(n==null?void 0:n.signer)==null?h=g.locator():typeof n.signer=="string"?h=n.signer:h=`server:${W(n.signer,this.chain,i(this,u).projectId,i(this,u).environment).derivedAddress}`;let f=b({recipient:d,amount:t,signer:h},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),y=yield i(this,u).send(this.walletLocator,o,f);if("message"in y)throw a.error("wallet.send.error",{error:y}),new Q(`Failed to send token: ${JSON.stringify(y.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:y.id}),{hash:void 0,explorerLink:void 0,transactionId:y.id};let m=yield this.approveTransactionAndWait(y.id);return a.info("wallet.send.success",{transactionId:y.id,hash:m.hash}),m})}approveTransaction(e){return c(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 c(this,null,function*(){if(a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return c(this,null,function*(){if(a.info("wallet.addSigner.start"),e.type==="device"&&this.chain==="solana")throw new q("Device signers are not currently supported for Solana wallets. Contact sales (https://www.crossmint.com/contact/sales) for access.");let t=typeof e=="object"&&"type"in e&&e.type==="server"?`server:${W(e,this.chain,i(this,u).projectId,i(this,u).environment).derivedAddress}`:e;return this.withRecoverySigner(()=>c(this,null,function*(){var h,f;let n=typeof t=="string"?t:P(t),s=yield this.getSignerState(n);if(s.signer!=null){if(this.isApprovedSignerStatus(s.signer.status))return a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(s.signer,null,r);if(s.pendingOperation!=null)return a.info("wallet.addSigner.resuming",{operationType:s.pendingOperation.type,operationId:s.pendingOperation.id}),this.completeSignerRegistration(s.signer,s.pendingOperation,r)}let d=typeof t=="string"||t.type==="passkey"?t:t.type==="device"&&"publicKey"in t&&t.publicKey!=null?{type:"device",publicKey:t.publicKey,name:t.name}:P(t),o=yield i(this,u).registerSigner(this.walletLocator,{signer:d,chain:this.getSignerRegistrationChain()});if("error"in o)throw a.error("wallet.addSigner.error",{error:o}),new Error(`Failed to register signer: ${JSON.stringify(o.message)}`);let l=j(o,this.chain);if(l==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let g=null;if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in o)||o.transaction==null)throw a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");g={type:"transaction",id:o.transaction.id}}else{if(!("chains"in o))throw a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((f=(h=o.chains)==null?void 0:h[this.chain])==null?void 0:f.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);g=_(o,this.chain)}return this.completeSignerRegistration(l,g,r)}))})}completeSignerRegistration(e,r,t){return c(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return b({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return a.info("wallet.addSigner.prepared",n),b(b({},e),n)}case"signature":{let n={signatureId:r.id};return a.info("wallet.addSigner.prepared",n),b(b({},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),a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else a.info("wallet.addSigner.success");return F(b({},e),{status:"success"})})}removeSigner(e,r){return c(this,null,function*(){let t=this.resolveSignerLocator(e);return a.info("wallet.removeSigner.start",{signerLocator:t}),this.withRecoverySigner(()=>c(this,null,function*(){let n=yield i(this,u).removeSigner(this.walletLocator,t,{chain:this.getSignerRegistrationChain()});if("error"in n)throw a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let s=n.id;return r!=null&&r.prepareOnly?(a.info("wallet.removeSigner.prepared",{transactionId:s}),{transactionId:s,status:void 0}):(yield this.approveTransactionAndWait(s),a.info("wallet.removeSigner.success",{transactionId:s}),{transactionId:s,status:"success"})}))})}useSigner(e){return c(this,null,function*(){a.info("wallet.useSigner.start"),this.validateSignerInput(e),e.type==="device"?yield this.resolveDeviceSignerAvailability(e):yield this.resolveNonDeviceSigner(e);let r=this.buildInternalSignerConfig(e),t=P(e);p(this,S,yield this.assembleFullSigner(r)),a.info("wallet.useSigner.success",{signerLocator:t})})}resolveNonDeviceSigner(e){return c(this,null,function*(){if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e)){p(this,T,!1);return}throw new Error("No passkey signer is registered on this wallet.")}let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r)){p(this,T,!1);return}if(this.isRecoverySigner(e)){p(this,T,!1);return}throw new Error(`Signer "${r}" is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return c(this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){if(e.type==="server"){let{derivedAddress:r}=W(e,this.chain,i(this,u).projectId,i(this,u).environment);return`server:${r}`}return P(e)}getSignerRegistrationChain(){if(!(this.chain==="solana"||this.chain==="stellar"))return this.chain}withRecoverySigner(e){return c(this,null,function*(){var n;let r=this.signer;if(D(i(this,w)))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(i(this,w)!=null&&i(this,w).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(i(this,w)))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let t=this.buildInternalSignerConfig(i(this,w));p(this,S,$(this.chain,t,(n=i(this,C))==null?void 0:n.deviceSignerKeyStorage));try{return yield e()}finally{p(this,S,r)}})}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return c(this,null,function*(){return(yield this.signers()).some(t=>t.locator===e)})}isSignerApproved(e){return c(this,null,function*(){var t;let r=yield this.getSignerState(e);return this.isApprovedSignerStatus((t=r.signer)==null?void 0:t.status)})}isApprovedSignerStatus(e){return e==="success"||e==="active"}needsRecovery(){return i(this,T)}recover(){return c(this,null,function*(){var s,d;if(a.info("wallet.recover.start"),i(this,N)){a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}let e=()=>{p(this,T,!1),p(this,N,!0)};if(((s=i(this,S))==null?void 0:s.type)==="device"&&(yield this.checkAndResumeDeviceSigner(i(this,S)))){e();return}if(i(this,S)!=null&&i(this,S).type!=="device"){a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),p(this,T,!1);return}let r=(d=i(this,C))==null?void 0:d.deviceSignerKeyStorage;if(r==null){if(!i(this,T))return;throw new Error("Device signer key storage is required to recover a device signer")}if(this.chain==="solana"){a.warn("wallet.recover.skipped",{reason:"Device signers are not supported on Solana"});return}let t=yield this.findLocalDeviceSigner(r);if(t!=null&&(yield this.checkAndResumeDeviceSigner(t))){p(this,S,t),e();let o=t.locator().replace("device:","");try{yield r.mapAddressToKey(this.address,o)}catch(l){a.warn("wallet.recover.mapAddressToKey.error",{error:l})}return}let n=yield oe(r,this.address);try{yield this.addSigner(n)}catch(o){if(o instanceof Error&&o.message.toLowerCase().includes("delegated signer")&&o.message.toLowerCase().includes("already")&&o.message.toLowerCase().includes("approved"))a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:n.locator});else throw o instanceof ae||o instanceof Error&&o.name==="AuthRejectedError"?(a.info("wallet.recover.device.authRejected",{signerLocator:n.locator}),o):(a.error("wallet.recover.device.error",{error:o}),yield r.deleteKey(this.address),o)}p(this,S,yield this.assembleFullSigner({type:"device",locator:n.locator,address:this.address},r)),i(this,S).type==="device"&&(i(this,S).status="success"),a.info("wallet.recover.device.success",{signerLocator:n.locator}),e()})}checkAndResumeDeviceSigner(e){return c(this,null,function*(){var t;if(this.isApprovedSignerStatus(e.status))return a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let r=yield this.getSignerState(e.locator());return e.status=(t=r.signer)==null?void 0:t.status,r.pendingOperation!=null?(yield this.resumePendingDeviceSignerApproval(e,r.pendingOperation),!0):this.isApprovedSignerStatus(e.status)?(a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})}resumePendingDeviceSignerApproval(e,r){return c(this,null,function*(){var s;let t=i(this,S);if(D(i(this,w)))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(i(this,w)!=null&&i(this,w).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(i(this,w)))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let n=this.buildInternalSignerConfig(i(this,w));p(this,S,$(this.chain,n,(s=i(this,C))==null?void 0:s.deviceSignerKeyStorage));try{r.type==="signature"?yield this.approveSignatureAndWait(r.id):yield this.approveTransactionAndWait(r.id)}catch(d){throw p(this,S,e),d}finally{i(this,S)!==e&&p(this,S,t)}e.status="success",a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0})})}findLocalDeviceSigner(e){return c(this,null,function*(){let t=(yield this.signers()).filter(n=>n.locator.startsWith("device:"));for(let n of t){let s=n.locator.replace("device:","");try{if(yield e.hasKey(s)){let o=$(this.chain,{type:"device",locator:n.locator,address:this.address},e);return a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:n.locator}),o}}catch(d){a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:n.locator,error:d})}}return null})}signers(){return c(this,null,function*(){var s,d;a.info("wallet.signers.start");let e=yield i(this,u).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new U(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new M(`Wallet type ${e.type} not supported`);let r=(d=(s=e==null?void 0:e.config)==null?void 0:s.delegatedSigners)!=null?d:[],n=(yield Promise.all(r.map(o=>c(this,null,function*(){try{return(yield this.getSignerState(o.locator)).signer}catch(l){return null}})))).filter(o=>o!=null);return a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,u).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(i(this,S)==null)throw i(this,R).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):i(this,w).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
1
+ import{a as oe}from"./chunk-N4IWDL6M.js";import{a as P}from"./chunk-GOXB2RBF.js";import{b as j,c as _}from"./chunk-VADIEIDS.js";import{a as $}from"./chunk-FLT6EMX3.js";import{b as W}from"./chunk-RBSMBO4T.js";import{a as se}from"./chunk-BKBD4C7T.js";import{a as ae,b as D}from"./chunk-6RX65NOA.js";import{f as ne}from"./chunk-DLLP4CTN.js";import{B as ie,d as M,e as U,j as q,n as V,q as H,r as z,s as Y,t as Q,u as G,v as X,w as Z,x as ee,y as re,z as te}from"./chunk-EXC7TCGL.js";import{a}from"./chunk-HUWBO6P7.js";import{d as J}from"./chunk-WJ6Z7KVH.js";import{a as b,b as F,c as E,d as i,e as x,f as p,g as c}from"./chunk-J3R36SGJ.js";import{isValidAddress as le,WithLoggerContext as k}from"@crossmint/common-sdk-base";var S,C,u,w,R,T,N,O,L,A=class{constructor(e,r){x(this,S);x(this,C);x(this,u);x(this,w);x(this,R);x(this,T,!1);x(this,N,!1);x(this,O);x(this,L,null);let{chain:t,address:n,owner:s,options:d,alias:o,recovery:l,signers:g,signer:h}=e;p(this,u,r),this.chain=t,this.address=n,this.owner=s,p(this,C,d),this.alias=o,p(this,w,l),p(this,R,g!=null?g:[]),p(this,S,h),p(this,O,this.initDefaultSigner())}get signer(){return i(this,S)}waitForInit(){return c(this,null,function*(){yield i(this,O)})}initDeviceSigner(){return c(this,null,function*(){var n;let e=(n=i(this,C))==null?void 0:n.deviceSignerKeyStorage;if(e==null||this.chain==="solana")return;let r={type:"device"};try{yield this.resolveDeviceSignerAvailability(r)}catch(s){a.error("wallet.initDeviceSigner.error",{error:s}),p(this,T,!0);return}if(i(this,T))return;let t=this.buildInternalSignerConfig(r);p(this,S,yield this.assembleFullSigner(t,e))})}initDefaultSigner(){return c(this,null,function*(){if(i(this,S)!=null||(yield this.initDeviceSigner(),i(this,S)!=null||i(this,T)))return;let e=i(this,R).length===0?i(this,w):i(this,R).length===1?i(this,R)[0]:null;if(e!=null&&this.isAutoAssemblableSignerConfig(e))try{let r=this.buildInternalSignerConfig(e);p(this,S,yield this.assembleFullSigner(r))}catch(r){a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,w).type,signerCount:i(this,R).length,error:r})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return i(e,w)}static getInitialSigners(e){return i(e,R)}get apiClient(){return i(this,u)}get options(){return i(this,C)}get recovery(){return i(this,w)}balances(e){return c(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t;switch(this.chain){case"solana":t="sol";break;case"stellar":t="xlm";break;default:t="eth";break}let n=[t,"usdc",...e!=null?e:[]],s=yield i(this,u).getBalance(this.address,{chains:[r],tokens:n});if("error"in s)throw a.error("wallet.balances.error",{error:s}),new Error(`Failed to get balances for wallet: ${JSON.stringify(s.message)}`);return a.info("wallet.balances.success"),this.transformBalanceResponse(s,t,e)})}stagingFund(e,r){return c(this,null,function*(){a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return a.info("wallet.stagingFund.success"),t})}transformBalanceResponse(e,r,t){let n=g=>{var y,m,I,K,B;let h=(y=g.chains)==null?void 0:y[this.chain],f={};return this.chain==="solana"&&h!=null&&"mintHash"in h?f={mintHash:h.mintHash}:this.chain==="stellar"&&h!=null&&"contractId"in h?f={contractId:h.contractId}:h!=null&&"contractAddress"in h&&(f={contractAddress:h.contractAddress}),b({symbol:(m=g.symbol)!=null?m:"",name:(I=g.name)!=null?I:"",amount:(K=g.amount)!=null?K:"0",decimals:g.decimals,rawAmount:(B=g.rawAmount)!=null?B:"0"},f)},s=e.find(g=>g.symbol===r),d=e.find(g=>g.symbol==="usdc"),o=e.filter(g=>{var h;return g.symbol!==r&&g.symbol!=="usdc"&&(t==null||t.includes((h=g.symbol)!=null?h:""))}),l=g=>{let h={symbol:g,name:g,amount:"0",decimals:0,rawAmount:"0"},f={};return this.chain==="solana"?f={mintHash:void 0}:this.chain==="stellar"?f={contractId:void 0}:f={contractAddress:void 0},b(b({},h),f)};return{nativeToken:s!=null?n(s):l(r),usdc:d!=null?n(d):l("usdc"),tokens:o.map(n)}}nfts(e){return c(this,null,function*(){return yield i(this,u).getNfts(F(b({},e),{chain:this.chain,address:this.address}))})}transactions(){return c(this,null,function*(){let e=yield i(this,u).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return c(this,null,function*(){let r=yield i(this,u).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.error)}`);return r})}transfers(e){return c(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return c(this,null,function*(){let s=this.resolveChainForEnvironment(),d=de(e),o=he(r,s),l=Number(t);if(Number.isNaN(l)||!Number.isFinite(l)||l<=0)throw new Y(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);a.info("wallet.send.start",b({recipient:d,token:o,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let g=this.requireSigner(),h;(n==null?void 0:n.signer)==null?h=g.locator():typeof n.signer=="string"?h=n.signer:h=`server:${W(n.signer,this.chain,i(this,u).projectId,i(this,u).environment).derivedAddress}`;let f=b({recipient:d,amount:t,signer:h},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),y=yield i(this,u).send(this.walletLocator,o,f);if("message"in y)throw a.error("wallet.send.error",{error:y}),new Q(`Failed to send token: ${JSON.stringify(y.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:y.id}),{hash:void 0,explorerLink:void 0,transactionId:y.id};let m=yield this.approveTransactionAndWait(y.id);return a.info("wallet.send.success",{transactionId:y.id,hash:m.hash}),m})}approveTransaction(e){return c(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 c(this,null,function*(){if(a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return c(this,null,function*(){if(a.info("wallet.addSigner.start"),e.type==="device"&&this.chain==="solana")throw new q("Device signers are not currently supported for Solana wallets. Contact sales (https://www.crossmint.com/contact/sales) for access.");let t=typeof e=="object"&&"type"in e&&e.type==="server"?`server:${W(e,this.chain,i(this,u).projectId,i(this,u).environment).derivedAddress}`:e;return this.withRecoverySigner(()=>c(this,null,function*(){var h,f;let n=typeof t=="string"?t:P(t),s=yield this.getSignerState(n);if(s.signer!=null){if(this.isApprovedSignerStatus(s.signer.status))return a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(s.signer,null,r);if(s.pendingOperation!=null)return a.info("wallet.addSigner.resuming",{operationType:s.pendingOperation.type,operationId:s.pendingOperation.id}),this.completeSignerRegistration(s.signer,s.pendingOperation,r)}let d=typeof t=="string"||t.type==="passkey"?t:t.type==="device"&&"publicKey"in t&&t.publicKey!=null?{type:"device",publicKey:t.publicKey,name:t.name}:P(t),o=yield i(this,u).registerSigner(this.walletLocator,{signer:d,chain:this.getSignerRegistrationChain()});if("error"in o)throw a.error("wallet.addSigner.error",{error:o}),new Error(`Failed to register signer: ${JSON.stringify(o.message)}`);let l=j(o,this.chain);if(l==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let g=null;if(this.chain==="solana"||this.chain==="stellar"){if(!("transaction"in o)||o.transaction==null)throw a.error("wallet.addSigner.error",{error:"Expected transaction in response for Solana/Stellar chain"}),new Error("Expected transaction in response for Solana/Stellar chain");g={type:"transaction",id:o.transaction.id}}else{if(!("chains"in o))throw a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((f=(h=o.chains)==null?void 0:h[this.chain])==null?void 0:f.status)==="failed")throw new Error(`Signer registration failed for chain ${this.chain}`);g=_(o,this.chain)}return this.completeSignerRegistration(l,g,r)}))})}completeSignerRegistration(e,r,t){return c(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return b({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return a.info("wallet.addSigner.prepared",n),b(b({},e),n)}case"signature":{let n={signatureId:r.id};return a.info("wallet.addSigner.prepared",n),b(b({},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),a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else a.info("wallet.addSigner.success");return F(b({},e),{status:"success"})})}removeSigner(e,r){return c(this,null,function*(){let t=this.resolveSignerLocator(e);return a.info("wallet.removeSigner.start",{signerLocator:t}),this.withRecoverySigner(()=>c(this,null,function*(){let n=yield i(this,u).removeSigner(this.walletLocator,t,{chain:this.getSignerRegistrationChain()});if("error"in n)throw a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let s=n.id;return r!=null&&r.prepareOnly?(a.info("wallet.removeSigner.prepared",{transactionId:s}),{transactionId:s,status:void 0}):(yield this.approveTransactionAndWait(s),a.info("wallet.removeSigner.success",{transactionId:s}),{transactionId:s,status:"success"})}))})}useSigner(e){return c(this,null,function*(){a.info("wallet.useSigner.start"),this.validateSignerInput(e),e.type==="device"?yield this.resolveDeviceSignerAvailability(e):yield this.resolveNonDeviceSigner(e);let r=this.buildInternalSignerConfig(e),t=P(e);p(this,S,yield this.assembleFullSigner(r)),a.info("wallet.useSigner.success",{signerLocator:t})})}resolveNonDeviceSigner(e){return c(this,null,function*(){if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e)){p(this,T,!1);return}throw new Error("No passkey signer is registered on this wallet.")}let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r)){p(this,T,!1);return}if(this.isRecoverySigner(e)){p(this,T,!1);return}throw new Error(`Signer "${r}" is not registered in this wallet.`)})}tryAutoSelectPasskey(e){return c(this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){if(e.type==="server"){let{derivedAddress:r}=W(e,this.chain,i(this,u).projectId,i(this,u).environment);return`server:${r}`}return P(e)}getSignerRegistrationChain(){if(!(this.chain==="solana"||this.chain==="stellar"))return this.chain}withRecoverySigner(e){return c(this,null,function*(){var n;let r=this.signer;if(D(i(this,w)))throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(i(this,w)!=null&&i(this,w).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(i(this,w)))throw new Error('Cannot assemble external wallet signer: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let t=this.buildInternalSignerConfig(i(this,w));p(this,S,$(this.chain,t,(n=i(this,C))==null?void 0:n.deviceSignerKeyStorage));try{return yield e()}finally{p(this,S,r)}})}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return c(this,null,function*(){return(yield this.signers()).some(t=>t.locator===e)})}isSignerApproved(e){return c(this,null,function*(){var t;let r=yield this.getSignerState(e);return this.isApprovedSignerStatus((t=r.signer)==null?void 0:t.status)})}isApprovedSignerStatus(e){return e==="success"||e==="active"}needsRecovery(){return i(this,T)}recover(){return c(this,null,function*(){var s,d;if(a.info("wallet.recover.start"),i(this,N)){a.info("wallet.recover.skipped",{reason:"Device signer already approved (cached)"});return}let e=()=>{p(this,T,!1),p(this,N,!0)};if(((s=i(this,S))==null?void 0:s.type)==="device"&&(yield this.checkAndResumeDeviceSigner(i(this,S)))){e();return}if(i(this,S)!=null&&i(this,S).type!=="device"){a.warn("wallet.recover.skipped",{reason:"Recovery is only supported for device signers"}),p(this,T,!1);return}let r=(d=i(this,C))==null?void 0:d.deviceSignerKeyStorage;if(r==null){if(!i(this,T))return;throw new Error("Device signer key storage is required to recover a device signer")}if(this.chain==="solana"){a.warn("wallet.recover.skipped",{reason:"Device signers are not supported on Solana"});return}let t=yield this.findLocalDeviceSigner(r);if(t!=null&&(yield this.checkAndResumeDeviceSigner(t))){p(this,S,t),e();let o=t.locator().replace("device:","");try{yield r.mapAddressToKey(this.address,o)}catch(l){a.warn("wallet.recover.mapAddressToKey.error",{error:l})}return}let n=yield oe(r,this.address);try{yield this.addSigner(n)}catch(o){if(o instanceof Error&&o.message.toLowerCase().includes("delegated signer")&&o.message.toLowerCase().includes("already")&&o.message.toLowerCase().includes("approved"))a.info("wallet.recover.skipped",{reason:"Device signer already approved",signerLocator:n.locator});else throw o instanceof ae||o instanceof Error&&o.name==="AuthRejectedError"?(a.info("wallet.recover.device.authRejected",{signerLocator:n.locator}),o):(a.error("wallet.recover.device.error",{error:o}),yield r.deleteKey(this.address),o)}p(this,S,yield this.assembleFullSigner({type:"device",locator:n.locator,address:this.address},r)),i(this,S).type==="device"&&(i(this,S).status="success"),a.info("wallet.recover.device.success",{signerLocator:n.locator}),e()})}checkAndResumeDeviceSigner(e){return c(this,null,function*(){var t;if(this.isApprovedSignerStatus(e.status))return a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0;let r=yield this.getSignerState(e.locator());return e.status=(t=r.signer)==null?void 0:t.status,r.pendingOperation!=null?(yield this.resumePendingDeviceSignerApproval(e,r.pendingOperation),!0):this.isApprovedSignerStatus(e.status)?(a.info("wallet.recover.skipped",{reason:"Device signer already approved"}),!0):!1})}resumePendingDeviceSignerApproval(e,r){return c(this,null,function*(){var s;let t=i(this,S);if(D(i(this,w)))throw new Error('Cannot resume pending approval: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');if(i(this,w)!=null&&i(this,w).type==="external-wallet"&&!this.isAutoAssemblableSignerConfig(i(this,w)))throw new Error('Cannot resume pending approval: no onSign callback available. Call wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... }) first.');let n=this.buildInternalSignerConfig(i(this,w));p(this,S,$(this.chain,n,(s=i(this,C))==null?void 0:s.deviceSignerKeyStorage));try{r.type==="signature"?yield this.approveSignatureAndWait(r.id):yield this.approveTransactionAndWait(r.id)}catch(d){throw p(this,S,e),d}finally{i(this,S)!==e&&p(this,S,t)}e.status="success",a.info("wallet.recover.device.success",{signerLocator:e.locator(),resumed:!0})})}findLocalDeviceSigner(e){return c(this,null,function*(){let t=(yield this.signers()).filter(n=>n.locator.startsWith("device:"));for(let n of t){let s=n.locator.replace("device:","");try{if(yield e.hasKey(s)){let o=$(this.chain,{type:"device",locator:n.locator,address:this.address},e);return a.info("wallet.recover.foundLocalDeviceSigner",{signerLocator:n.locator}),o}}catch(d){a.warn("wallet.recover.findLocalDeviceSigner.keyCheckError",{signerLocator:n.locator,error:d})}}return null})}signers(){return c(this,null,function*(){var s,d;a.info("wallet.signers.start");let e=yield i(this,u).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new U(JSON.stringify(e));if(e.type!=="smart"||e.chainType!=="evm"&&e.chainType!=="solana"&&e.chainType!=="stellar")throw a.error("wallet.signers.error",{error:`Wallet type ${e.type} not supported`}),new M(`Wallet type ${e.type} not supported`);let r=(d=(s=e==null?void 0:e.config)==null?void 0:s.delegatedSigners)!=null?d:[],n=(yield Promise.all(r.map(o=>c(this,null,function*(){try{return(yield this.getSignerState(o.locator)).signer}catch(l){return null}})))).filter(o=>o!=null);return a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,u).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(i(this,S)==null)throw i(this,R).length>1?new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations."):i(this,w).type==="server"?new Error(`No signer is set. Server wallets require calling wallet.useSigner() with the server secret before signing operations.
2
2
  Example: wallet.useSigner({ type: "server", secret: process.env.YOUR_SERVER_SECRET })`):i(this,w).type==="external-wallet"||!this.isAutoAssemblableSignerConfig(i(this,w))?new Error(`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
3
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 i(this,S)}preAuthIfNeeded(){return c(this,null,function*(){yield i(this,O),i(this,L)==null&&p(this,L,this.recover());try{yield i(this,L)}finally{p(this,L,null)}let e=this.requireSigner();e instanceof se&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=i(this,w);if(r==null||r.type!==e.type||e.type==="device")return!1;if(e.type==="passkey")return!0;if(e.type==="server"&&r.type==="server"){let t=d=>D(d)?d.address:W(d,this.chain,i(this,u).projectId,i(this,u).environment).derivedAddress,n=t(e),s=t(r);if(n!==s)return!1}else if(P(e)!==P(r))return!1;return p(this,w,e),!0}validateSignerInput(e){switch(e.type){case"email":if(!("email"in e)||e.email==null)throw new Error("Email signer requires an email address");break;case"phone":if(!("phone"in e)||e.phone==null)throw new Error("Phone signer requires a phone number");break;case"external-wallet":if(!("address"in e)||e.address==null)throw new Error("External wallet signer requires a wallet address");if(!("onSign"in e)||typeof e.onSign!="function")throw new Error("External wallet signer requires an onSign callback");break;case"passkey":case"device":case"api-key":break;default:break}}resolveDeviceSignerAvailability(e){return c(this,null,function*(){var d;let r=(d=i(this,C))==null?void 0:d.deviceSignerKeyStorage;if(r==null)throw new Error("Device signer key storage is required for device signers");let t=yield r.getKey(this.address);if(t!=null){e.locator=`device:${t}`;return}let s=(yield this.signers()).filter(o=>o.locator.startsWith("device:"));for(let o of s){let l=o.locator.replace("device:","");if(yield r.hasKey(l)){yield r.mapAddressToKey(this.address,l),e.locator=o.locator;return}}p(this,T,!0),p(this,N,!1)})}assembleFullSigner(n){return c(this,arguments,function*(e,r=(t=>(t=i(this,C))==null?void 0:t.deviceSignerKeyStorage)()){var o;let s=$(this.chain,e,r),d=yield this.getSignerState(s.locator());return s.status=(o=d.signer)==null?void 0:o.status,s})}getSignerState(e){return c(this,null,function*(){let r=null;try{r=yield i(this,u).getSigner(this.walletLocator,e)}catch(n){return{response:null,signer:null,pendingOperation:null}}if(r==null||typeof r!="object"||"error"in r)return{response:null,signer:null,pendingOperation:null};let t=j(r,this.chain);return{response:r,signer:t,pendingOperation:_(r,this.chain)}})}buildInternalSignerConfig(e){var r,t,n,s,d,o;switch(e.type){case"email":return{type:"email",email:e.email,locator:`email:${e.email}`,address:this.address,crossmint:i(this,u).crossmint,clientTEEConnection:(r=i(this,C))==null?void 0:r.clientTEEConnection,onAuthRequired:(n=(t=i(this,C))==null?void 0:t.callbacks)==null?void 0:n.onAuthRequired};case"phone":return{type:"phone",phone:e.phone,locator:`phone:${e.phone}`,address:this.address,crossmint:i(this,u).crossmint,clientTEEConnection:(s=i(this,C))==null?void 0:s.clientTEEConnection,onAuthRequired:(o=(d=i(this,C))==null?void 0:d.callbacks)==null?void 0:o.onAuthRequired};case"passkey":{let l="id"in e&&e.id?e.id:"";return{type:"passkey",id:l,locator:`passkey:${l}`,name:"name"in e?e.name:void 0,publicKey:"publicKey"in e?e.publicKey:void 0,onCreatePasskey:e.onCreatePasskey,onSignWithPasskey:e.onSignWithPasskey}}case"device":return{type:"device",locator:"locator"in e&&e.locator?e.locator:void 0,address:this.address};case"external-wallet":return F(b({},e),{locator:`external-wallet:${e.address}`});case"api-key":return{type:"api-key",locator:"api-key",address:this.address};case"server":{let{derivedKeyBytes:l,derivedAddress:g}=W(e,this.chain,i(this,u).projectId,i(this,u).environment);return{type:"server",derivedKeyBytes:l,locator:`server:${g}`,address:g}}default:throw new Error(`Unknown signer type: ${e==null?void 0:e.type}`)}}isAutoAssemblableSignerConfig(e){var r;switch(e.type){case"email":case"phone":case"passkey":case"api-key":return!0;case"device":return((r=i(this,C))==null?void 0:r.deviceSignerKeyStorage)!=null;case"server":return!D(e);case"external-wallet":return"onSign"in e&&typeof e.onSign=="function";default:return!1}}get isSolanaWallet(){return this.chain==="solana"}resolveChainForEnvironment(){let e=ne(this.chain,i(this,u).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return c(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return c(this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return c(this,null,function*(){var l,g;if(this.isSolanaWallet)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=this.requireSigner(),n=yield i(this,u).getSignature(this.walletLocator,e);if("error"in n)throw new H(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let h=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,h)}let s=(l=n.approvals)==null?void 0:l.pending;if(s==null)return n;let d=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],t],o=yield Promise.all(s.map(h=>c(this,null,function*(){let f=d.find(m=>m.locator()===h.signer.locator);if(f==null)throw new q(`Signer ${h.signer.locator} not found in pending approvals`);let y=yield f.signMessage(h.message);return F(b({},y),{signer:f.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,o)})}approveTransactionInternal(e,r){return c(this,null,function*(){var l,g,h,f,y;let t=yield i(this,u).getTransaction(this.walletLocator,e);if("error"in t)throw new G(JSON.stringify(t));yield(h=(g=(l=i(this,C))==null?void 0:l.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:h.call(g);let n=this.requireSigner();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let m=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,m)}let s=(f=t.approvals)==null?void 0:f.pending;if(s==null)return t;let d=[...(y=r==null?void 0:r.additionalSigners)!=null?y:[],n],o=yield Promise.all(s.map(m=>c(this,null,function*(){let I=d.find(ge=>ge.locator()===m.signer.locator);if(I==null)throw new q(`Signer ${m.signer.locator} not found in pending approvals`);let K=I.type==="device",B=t.chainType==="solana"&&"transaction"in t.onChain&&!K?t.onChain.transaction:m.message,ce=yield I.signTransaction(B);return F(b({},ce),{signer:I.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,o)})}executeApproveTransactionWithErrorHandling(e,r){return c(this,null,function*(){a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,u).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw new te(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return c(this,null,function*(){let t=yield i(this,u).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw new z(JSON.stringify(t));return t})}waitForSignature(e){return c(this,null,function*(){let r=null;do if(yield new Promise(t=>setTimeout(t,J)),r=yield i(this,u).getSignature(this.walletLocator,e),"error"in r)throw new H(JSON.stringify(r));while(r===null||r.status==="pending");if(r.status==="failed")throw new V("Signature signing failed");if(!r.outputSignature)throw new H("Signature not available");return{signature:r.outputSignature,signatureId:e}})}waitForTransaction(d){return c(this,arguments,function*(e,r=6e4,{backoffMultiplier:t=1.1,maxBackoffMs:n=2e3,initialBackoffMs:s=J}={}){var f,y;a.info("wallet.approve: waiting for transaction confirmation",{transactionId:e,timeoutMs:r});let o=Date.now(),l;do{if(Date.now()-o>r)throw new X("Transaction confirmation timeout");if(l=yield i(this,u).getTransaction(this.walletLocator,e),l.error)throw new G(JSON.stringify(l));yield this.sleep(s),s=Math.min(s*t,n)}while(l.status==="pending");if(l.status==="failed")throw new Z(`Transaction sending failed: ${JSON.stringify(l.error)}`);if(l.status==="awaiting-approval")throw new ee("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let g="txHash"in l.onChain&&typeof l.onChain.txHash=="string"?l.onChain.txHash:void 0,h=(f=l.onChain.txId)!=null?f:g;if(h==null)throw new re("Transaction hash not found on transaction response");return{hash:h,explorerLink:(y=l.onChain.explorerLink)!=null?y:"",transactionId:l.id}})}sleep(e){return c(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};S=new WeakMap,C=new WeakMap,u=new WeakMap,w=new WeakMap,R=new WeakMap,T=new WeakMap,N=new WeakMap,O=new WeakMap,L=new WeakMap,E([k({logger:a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),E([k({logger:a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),E([k({logger:a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),E([k({logger:a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),E([k({logger:a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),E([k({logger:a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"removeSigner",1),E([k({logger:a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),E([k({logger:a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),E([k({logger:a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function de(v){if(typeof v=="string"){if(!le(v))throw new ie(`Invalid recipient address: "${v}". Expected a valid EVM (0x...), Solana (base58), or Stellar (G.../C...) address.`);return v}if("email"in v)return`email:${v.email}`;if("x"in v)return`x:${v.x}`;if("twitter"in v)return`twitter:${v.twitter}`;if("phone"in v)return`phoneNumber:${v.phone}`;if("userId"in v)return`userId:${v.userId}`;throw new Error("Invalid recipient locator")}function he(v,e){return le(v)?`${e}:${v}`:`${e}:${v.toLowerCase()}`}export{A as a};
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkQJGO3XB4cjs = require('./chunk-QJGO3XB4.cjs');var _chunk6DCPC33Fcjs = require('./chunk-6DCPC33F.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkQJGO3XB4cjs.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","");_chunk6DCPC33Fcjs.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:_chunkQJGO3XB4cjs.b});if(_chunk6DCPC33Fcjs.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 _chunkTFC7TYGWcjs = require('./chunk-TFC7TYGW.cjs');var _chunkUZWS4OLZcjs = require('./chunk-UZWS4OLZ.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunkTFC7TYGWcjs.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","");_chunkUZWS4OLZcjs.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:_chunkTFC7TYGWcjs.b});if(_chunkUZWS4OLZcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};exports.a = c;
@@ -1 +1 @@
1
- import{a as s,b as o}from"./chunk-4RI43OYI.js";import{a as r}from"./chunk-46PT2BD6.js";import{g as t}from"./chunk-J3R36SGJ.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
1
+ import{a as s,b as o}from"./chunk-BKBD4C7T.js";import{a as r}from"./chunk-HUWBO6P7.js";import{g as t}from"./chunk-J3R36SGJ.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};