@crossmint/wallets-sdk 1.8.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/api/__tests__/test-utils.cjs +1 -1
- package/dist/api/__tests__/test-utils.js +1 -1
- package/dist/api/client.cjs +1 -1
- package/dist/api/client.js +1 -1
- package/dist/api/index.cjs +1 -1
- package/dist/api/index.js +1 -1
- package/dist/chains/adapters/evm.cjs +1 -1
- package/dist/chains/adapters/evm.js +1 -1
- package/dist/chains/adapters/solana.cjs +1 -1
- package/dist/chains/adapters/solana.js +1 -1
- package/dist/chains/adapters/stellar.cjs +1 -1
- package/dist/chains/adapters/stellar.js +1 -1
- package/dist/chains/chain-adapter.cjs +1 -1
- package/dist/chains/chain-adapter.js +1 -1
- package/dist/chains/chains.cjs +1 -1
- package/dist/chains/chains.js +1 -1
- package/dist/{chunk-ACJUNZGV.js → chunk-222WHEBO.js} +1 -1
- package/dist/{chunk-ILJXME26.cjs → chunk-23X5QOE6.cjs} +1 -1
- package/dist/{chunk-QEIZABXJ.cjs → chunk-2F6CGFVL.cjs} +1 -1
- package/dist/chunk-2SUPM5NU.js +1 -0
- package/dist/chunk-2TVSRZ42.js +1 -0
- package/dist/{chunk-Y7XDNVFX.js → chunk-2UL2H43T.js} +1 -1
- package/dist/{chunk-R3LWLFO3.js → chunk-464D53RC.js} +1 -1
- package/dist/chunk-4T45LK43.cjs +1 -0
- package/dist/{chunk-UCZT2O73.cjs → chunk-532BF2RA.cjs} +1 -1
- package/dist/{chunk-SXB2JOPU.js → chunk-5KGXMZFJ.js} +1 -1
- package/dist/{chunk-MEJ7ZHBM.js → chunk-5M4L42QQ.js} +1 -1
- package/dist/{chunk-UKNAZVRC.js → chunk-5OGNXLOH.js} +1 -1
- package/dist/{chunk-AAWVNX5D.cjs → chunk-5UR3TR3H.cjs} +1 -1
- package/dist/chunk-6DEQI3XT.cjs +1 -0
- package/dist/chunk-7AE4UN5A.cjs +1 -0
- package/dist/{chunk-VKXHD6UP.js → chunk-7HVCPMZA.js} +1 -1
- package/dist/{chunk-577FVL6N.cjs → chunk-AERFTEJI.cjs} +1 -1
- package/dist/{chunk-MQE44PAR.cjs → chunk-AOVIJZ3W.cjs} +2 -2
- package/dist/{chunk-HTZPHRO2.js → chunk-BDQ6PRDN.js} +1 -1
- package/dist/{chunk-NML6ZUFM.cjs → chunk-BGQZNCXO.cjs} +1 -1
- package/dist/{chunk-J6ETRZYR.cjs → chunk-CGQR7B2H.cjs} +1 -1
- package/dist/chunk-CTJQUZUF.js +1 -0
- package/dist/{chunk-UULZ22RQ.cjs → chunk-D36TJPDF.cjs} +1 -1
- package/dist/{chunk-FDKID63Z.js → chunk-DFIZFCX4.js} +1 -1
- package/dist/{chunk-PHKB5VRX.js → chunk-DVTKFD3K.js} +1 -1
- package/dist/{chunk-6FHMUKOW.js → chunk-DX2WEUVJ.js} +1 -1
- package/dist/{chunk-DXVNNTYG.js → chunk-DZAG4SRY.js} +1 -1
- package/dist/{chunk-NFX2WUB6.js → chunk-E2GL7NJM.js} +1 -1
- package/dist/{chunk-6MQ7FVEV.cjs → chunk-E7Z24LRS.cjs} +1 -1
- package/dist/{chunk-IZMSUJUW.cjs → chunk-EOXMCIRY.cjs} +1 -1
- package/dist/{chunk-SEXK7X55.cjs → chunk-EUNVW5NM.cjs} +1 -1
- package/dist/{chunk-R7S55N7J.cjs → chunk-EXOY4ZCV.cjs} +1 -1
- package/dist/{chunk-M4U7HAZ6.js → chunk-EZ6E5QGL.js} +1 -1
- package/dist/{chunk-CIIIXKSM.js → chunk-HBGLYYE4.js} +1 -1
- package/dist/{chunk-XNCZYX2V.cjs → chunk-HJIKAOPC.cjs} +1 -1
- package/dist/{chunk-INBDFSBN.cjs → chunk-HRRPQMFM.cjs} +1 -1
- package/dist/{chunk-UMQI4GDZ.js → chunk-HXN3ZART.js} +1 -1
- package/dist/{chunk-M7QSZTNV.js → chunk-IASKJ4WS.js} +1 -1
- package/dist/chunk-IBQQA6L3.js +1 -0
- package/dist/{chunk-JUVF537D.cjs → chunk-IHJXAM3H.cjs} +1 -1
- package/dist/{chunk-XRLBGNNW.cjs → chunk-ILCNZB3A.cjs} +1 -1
- package/dist/{chunk-DF753J5G.cjs → chunk-J42KB6M4.cjs} +1 -1
- package/dist/{chunk-H7FDW5J4.js → chunk-J4L3FCIC.js} +1 -1
- package/dist/chunk-J5W5S2WG.cjs +1 -0
- package/dist/{chunk-SAZKNE6N.js → chunk-J64QG3LS.js} +1 -1
- package/dist/{chunk-HUD23LSC.cjs → chunk-K2W3NIDO.cjs} +1 -1
- package/dist/{chunk-WVCLDF55.cjs → chunk-KZ62YXDQ.cjs} +1 -1
- package/dist/chunk-LHAOCUXT.cjs +1 -0
- package/dist/chunk-LKYOZL7U.cjs +1 -0
- package/dist/{chunk-YUCK3VTX.cjs → chunk-LOZ4BC3H.cjs} +1 -1
- package/dist/{chunk-P4P3Q7F2.js → chunk-MLUAGHMI.js} +1 -1
- package/dist/{chunk-VE25YNP3.js → chunk-N5LPV5FV.js} +1 -1
- package/dist/{chunk-V3BCKXZ6.js → chunk-NBM25TBK.js} +1 -1
- package/dist/{chunk-3WDIJIBZ.js → chunk-NVIW3CJW.js} +1 -1
- package/dist/{chunk-PH5XGZFF.cjs → chunk-O5SASZOH.cjs} +1 -1
- package/dist/{chunk-2GKFULT7.cjs → chunk-OHR5JRFH.cjs} +1 -1
- package/dist/{chunk-GNON524X.js → chunk-PJKTUGX2.js} +1 -1
- package/dist/{chunk-5CGCTYQJ.cjs → chunk-PZC2L2XZ.cjs} +1 -1
- package/dist/chunk-QYNJ3CQP.cjs +1 -0
- package/dist/{chunk-DBWMNPH7.cjs → chunk-RJZ6ZFLX.cjs} +1 -1
- package/dist/chunk-SLPKMZNW.js +1 -0
- package/dist/{chunk-FOHYTIML.js → chunk-SRN6KQRK.js} +1 -1
- package/dist/{chunk-IYQVWJXN.js → chunk-SSC676RL.js} +1 -1
- package/dist/chunk-TVD45ZZM.cjs +1 -0
- package/dist/{chunk-XKMIK6EW.js → chunk-VMXMHGSE.js} +1 -1
- package/dist/{chunk-J5SLH6DG.js → chunk-VWYK4DKI.js} +1 -1
- package/dist/{chunk-GAGWB24A.js → chunk-WLTYJRB5.js} +1 -1
- package/dist/{chunk-D3KX5W6W.js → chunk-YLMVZCBF.js} +1 -1
- package/dist/{chunk-XMN42YI5.cjs → chunk-Z5GCNZZH.cjs} +1 -1
- package/dist/{chunk-RZNLDJBS.cjs → chunk-Z7GMI25O.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +2 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/logger/index.cjs +1 -1
- package/dist/logger/index.js +1 -1
- package/dist/logger/init.cjs +1 -1
- package/dist/logger/init.js +1 -1
- package/dist/sdk.cjs +1 -1
- package/dist/sdk.d.cts +1 -0
- package/dist/sdk.d.ts +1 -0
- package/dist/sdk.js +1 -1
- package/dist/signers/descriptors/api-key.cjs +1 -1
- package/dist/signers/descriptors/api-key.js +1 -1
- package/dist/signers/descriptors/device.cjs +1 -1
- package/dist/signers/descriptors/device.js +1 -1
- package/dist/signers/descriptors/email.cjs +1 -1
- package/dist/signers/descriptors/email.js +1 -1
- package/dist/signers/descriptors/external-wallet.cjs +1 -1
- package/dist/signers/descriptors/external-wallet.js +1 -1
- package/dist/signers/descriptors/index.cjs +1 -1
- package/dist/signers/descriptors/index.js +1 -1
- package/dist/signers/descriptors/phone.cjs +1 -1
- package/dist/signers/descriptors/phone.js +1 -1
- package/dist/signers/index.cjs +1 -1
- package/dist/signers/index.js +1 -1
- package/dist/signers/non-custodial/index.cjs +1 -1
- package/dist/signers/non-custodial/index.js +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.js +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.cjs +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
- package/dist/signers/solana-external-wallet.cjs +1 -1
- package/dist/signers/solana-external-wallet.js +1 -1
- package/dist/utils/constants.cjs +1 -1
- package/dist/utils/constants.d.cts +1 -1
- package/dist/utils/constants.d.ts +1 -1
- package/dist/utils/constants.js +1 -1
- package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.cjs +1 -1
- package/dist/utils/device-signers/IframeDeviceSignerKeyStorage.js +1 -1
- package/dist/utils/device-signers/index.cjs +1 -1
- package/dist/utils/device-signers/index.js +1 -1
- package/dist/utils/errors.cjs +1 -1
- package/dist/utils/errors.d.cts +11 -3
- package/dist/utils/errors.d.ts +11 -3
- package/dist/utils/errors.js +1 -1
- package/dist/utils/locators.cjs +1 -1
- package/dist/utils/locators.js +1 -1
- package/dist/utils/signer-locator.cjs +1 -1
- package/dist/utils/signer-locator.js +1 -1
- package/dist/utils/signer-validation.cjs +1 -1
- package/dist/utils/signer-validation.js +1 -1
- package/dist/wallets/__tests__/test-helpers.cjs +1 -1
- package/dist/wallets/__tests__/test-helpers.d.cts +1 -0
- package/dist/wallets/__tests__/test-helpers.d.ts +1 -0
- package/dist/wallets/__tests__/test-helpers.js +1 -1
- package/dist/wallets/evm.cjs +1 -1
- package/dist/wallets/evm.d.cts +1 -0
- package/dist/wallets/evm.d.ts +1 -0
- package/dist/wallets/evm.js +1 -1
- package/dist/wallets/services/balance-formatter.cjs +1 -1
- package/dist/wallets/services/balance-formatter.js +1 -1
- package/dist/wallets/services/device-recovery-service.cjs +1 -1
- package/dist/wallets/services/device-recovery-service.js +1 -1
- package/dist/wallets/services/operation-poller.cjs +1 -1
- package/dist/wallets/services/operation-poller.d.cts +1 -0
- package/dist/wallets/services/operation-poller.d.ts +1 -0
- package/dist/wallets/services/operation-poller.js +1 -1
- package/dist/wallets/services/signer-manager.cjs +1 -1
- package/dist/wallets/services/signer-manager.js +1 -1
- package/dist/wallets/solana.cjs +1 -1
- package/dist/wallets/solana.d.cts +1 -0
- package/dist/wallets/solana.d.ts +1 -0
- package/dist/wallets/solana.js +1 -1
- package/dist/wallets/stellar.cjs +1 -1
- package/dist/wallets/stellar.d.cts +1 -0
- package/dist/wallets/stellar.d.ts +1 -0
- package/dist/wallets/stellar.js +1 -1
- package/dist/wallets/wallet-factory.cjs +1 -1
- package/dist/wallets/wallet-factory.d.cts +4 -6
- package/dist/wallets/wallet-factory.d.ts +4 -6
- package/dist/wallets/wallet-factory.js +1 -1
- package/dist/wallets/wallet.cjs +1 -1
- package/dist/wallets/wallet.d.cts +2 -5
- package/dist/wallets/wallet.d.ts +2 -5
- package/dist/wallets/wallet.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-2FEUZYLP.cjs +0 -1
- package/dist/chunk-3F4FMM3R.cjs +0 -1
- package/dist/chunk-BXXQTV75.cjs +0 -1
- package/dist/chunk-EXFV7SBW.cjs +0 -1
- package/dist/chunk-FQZQGXWS.js +0 -1
- package/dist/chunk-H3XK3D3Y.js +0 -1
- package/dist/chunk-IVKPY3XN.js +0 -1
- package/dist/chunk-KIZY54AZ.cjs +0 -1
- package/dist/chunk-KWILWKSM.cjs +0 -1
- package/dist/chunk-LFVAI5O6.cjs +0 -1
- package/dist/chunk-OZ6ZUQ4E.cjs +0 -1
- package/dist/chunk-TGFHY5PL.js +0 -1
- package/dist/chunk-V5VXKWOL.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ33QM2IDcjs = require('../../chunk-J33QM2ID.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJ33QM2IDcjs = require('../../chunk-J33QM2ID.cjs');var _chunkAERFTEJIcjs = require('../../chunk-AERFTEJI.cjs');require('../../chunk-LHAOCUXT.cjs');require('../../chunk-ILCNZB3A.cjs');require('../../chunk-J5W5S2WG.cjs');var _chunkDSIFRRBScjs = require('../../chunk-DSIFRRBS.cjs');var _vitest = require('vitest');var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:_vitest.vi.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j= exports.createMockSuccessResponse =e=>P({data:e}),b= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B= exports.createMockCrossmint =(e={})=>{let t=_chunkDSIFRRBScjs.a.call(void 0, {apiKey:_chunkJ33QM2IDcjs.m},e);return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},t),{setJwt:_vitest.vi.fn().mockReturnThis()})},L= exports.createTestApiClient =e=>new (0, _chunkAERFTEJIcjs.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)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();_vitest.expect.call(void 0, l(a)).toBe(!0),l(a)&&(_vitest.expect.call(void 0, a.error).toBe(!0),n.message&&_vitest.expect.call(void 0, a.message).toBe(n.message))}),Z= exports.testCommonHttpErrors =(s,a,...o)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of _chunkJ33QM2IDcjs.a){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();_vitest.expect.call(void 0, l(m)).toBe(!0)}}),Q= exports.testNetworkError =(e,t)=>_chunkDSIFRRBScjs.h.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)=>_chunkDSIFRRBScjs.h.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)=>_chunkDSIFRRBScjs.h.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)=>_chunkDSIFRRBScjs.h.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={})=>_chunkDSIFRRBScjs.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={})=>_chunkDSIFRRBScjs.a.call(void 0, {id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),re= exports.isValidEthereumAddress =e=>/^0x[a-fA-F0-9]{40}$/.test(e),ae= exports.isValidSolanaAddress =e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ie= exports.createIntegrationApiClient =(e,t,n={})=>{let s=_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {apiKey:e},t&&{overrideBaseUrl:t}),n),a=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},s),{setJwt:()=>a});return new (0, _chunkAERFTEJIcjs.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 _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(_chunkDSIFRRBScjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function pe(e,t,n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function le(e,t){_vitest.expect.call(void 0, l(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function ue(e){_vitest.expect.call(void 0, C(e)).toBe(!0)}function de(e){_vitest.expect.call(void 0, $(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(_chunkJ33QM2IDcjs.i),c}),U= exports.approveTransaction =(a,o,c,...g)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,[a,o,c,...g],function*(e,t,n,s=_chunkJ33QM2IDcjs.l.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),me= exports.fundWalletAndWait =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){return I(e,t,n,s,a)}),fe= exports.sendTokenAndApprove =(e,t,n,s,a)=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),ge= exports.ensureWalletFunded =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunkDSIFRRBScjs.h.call(void 0, void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});exports.TestDataFactory = v; exports.approveTransaction = U; exports.createIntegrationApiClient = ie; exports.createMockCrossmint = B; exports.createMockErrorResponse = b; exports.createMockResponse = P; exports.createMockSendResponse = oe; exports.createMockSuccessResponse = j; exports.createMockWalletResponse = se; exports.createServerSideApiClient = K; exports.createTestApiClient = L; exports.createTestWallet = pe; exports.delay = x; exports.ensureWalletExists = ce; exports.ensureWalletFunded = ge; exports.expectCommonHeaders = V; exports.expectErrorResponse = le; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = ue; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = l; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = C; exports.isValidEthereumAddress = re; exports.isValidSolanaAddress = ae; exports.sendTokenAndApprove = fe; exports.testCommonHttpErrors = Z; exports.testHttpErrorResponse = X; exports.testInvalidJsonResponse = ee; exports.testMalformedResponse = ne; exports.testNetworkError = Q; exports.testTimeoutError = te; exports.validateRequest = z;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as A,b as F,i as R,j as W,k as E,l as M,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-
|
|
1
|
+
import{a as A,b as F,i as R,j as W,k as E,l as M,m as S}from"../../chunk-DIGDDKSF.js";import{a as w}from"../../chunk-HBGLYYE4.js";import"../../chunk-SLPKMZNW.js";import"../../chunk-HXN3ZART.js";import"../../chunk-IBQQA6L3.js";import{a as p,b as k,h as i}from"../../chunk-NU7VF7MC.js";import{expect as r,vi as y}from"vitest";var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>P({data:e}),b=(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B=(e={})=>{let t=p({apiKey:S},e);return k(p({},t),{setJwt:y.fn().mockReturnThis()})},L=e=>new w(e||B()),Y=()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},z=e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N=(e,t)=>{r(e==null?void 0:e.path).toBe(t)},V=e=>{r(e["Content-Type"]).toBe("application/json")},q=(e,t)=>{r(e.body).toBe(JSON.stringify(t))},X=(e,t,n)=>{r(e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},Z=(e,t,n,s)=>i(void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();r(l(a)).toBe(!0),l(a)&&(r(a.error).toBe(!0),n.message&&r(a.message).toBe(n.message))}),Q=(s,a,...o)=>i(void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of A){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();r(l(m)).toBe(!0)}}),ee=(e,t)=>i(void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield r(e()).rejects.toThrow("Network error")}),te=(e,t)=>i(void 0,null,function*(){let n={json:y.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield r(e()).rejects.toThrow()}),ne=(e,t)=>i(void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield r(e()).rejects.toThrow("Request timeout")}),se=(e,t,n)=>i(void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();r(s).toEqual(n)}),oe=(e={})=>p({address:F.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:E.EVM_TEST}}},e),re=(e={})=>p({id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),ae=e=>/^0x[a-fA-F0-9]{40}$/.test(e),ie=e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ce=(e,t,n={})=>{let s=p(p({apiKey:e},t&&{overrideBaseUrl:t}),n),a=k(p({},s),{setJwt:()=>a});return new w(a)},v=class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function pe(s,a){return i(this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function le(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function ue(e,t){r(l(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(C(e)).toBe(!0)}function me(e){r($(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(R),c}),U=(a,o,c,...g)=>i(void 0,[a,o,c,...g],function*(e,t,n,s=M.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(W);continue}yield x(R)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),fe=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){return I(e,t,n,s,a)}),ge=(e,t,n,s,a)=>i(void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),Te=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});export{v as TestDataFactory,U as approveTransaction,ce as createIntegrationApiClient,B as createMockCrossmint,b as createMockErrorResponse,P as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,le as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,ue as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,l as isErrorResponse,$ as isSuccessTransactionResponse,C as isSuccessWalletResponse,ae as isValidEthereumAddress,ie as isValidSolanaAddress,ge as sendTokenAndApprove,Q as testCommonHttpErrors,Z as testHttpErrorResponse,te as testInvalidJsonResponse,se as testMalformedResponse,ee as testNetworkError,ne as testTimeoutError,X as validateRequest};
|
package/dist/api/client.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkAERFTEJIcjs = require('../chunk-AERFTEJI.cjs');require('../chunk-LHAOCUXT.cjs');require('../chunk-ILCNZB3A.cjs');require('../chunk-J5W5S2WG.cjs');require('../chunk-DSIFRRBS.cjs');exports.ApiClient = _chunkAERFTEJIcjs.a;
|
package/dist/api/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-HBGLYYE4.js";import"../chunk-SLPKMZNW.js";import"../chunk-HXN3ZART.js";import"../chunk-IBQQA6L3.js";import"../chunk-NU7VF7MC.js";export{a as ApiClient};
|
package/dist/api/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('../chunk-6HXIZLEQ.cjs');var _chunkAERFTEJIcjs = require('../chunk-AERFTEJI.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-LHAOCUXT.cjs');require('../chunk-ILCNZB3A.cjs');require('../chunk-J5W5S2WG.cjs');require('../chunk-DSIFRRBS.cjs');exports.ApiClient = _chunkAERFTEJIcjs.a;
|
package/dist/api/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-
|
|
1
|
+
import"../chunk-5IFDVB4Y.js";import{a}from"../chunk-HBGLYYE4.js";import"../chunk-KBJA7JDT.js";import"../chunk-SLPKMZNW.js";import"../chunk-HXN3ZART.js";import"../chunk-IBQQA6L3.js";import"../chunk-NU7VF7MC.js";export{a as ApiClient};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk23X5QOE6cjs = require('../../chunk-23X5QOE6.cjs');require('../../chunk-TM77X7C3.cjs');require('../../chunk-LHAOCUXT.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-ILCNZB3A.cjs');require('../../chunk-J5W5S2WG.cjs');require('../../chunk-DSIFRRBS.cjs');exports.evmChainAdapter = _chunk23X5QOE6cjs.a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-5KGXMZFJ.js";import"../../chunk-6HB4WO5J.js";import"../../chunk-SLPKMZNW.js";import"../../chunk-455NK5LB.js";import"../../chunk-HXN3ZART.js";import"../../chunk-IBQQA6L3.js";import"../../chunk-NU7VF7MC.js";export{a as evmChainAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkKZ62YXDQcjs = require('../../chunk-KZ62YXDQ.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-ILCNZB3A.cjs');require('../../chunk-J5W5S2WG.cjs');require('../../chunk-DSIFRRBS.cjs');exports.solanaChainAdapter = _chunkKZ62YXDQcjs.a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-DZAG4SRY.js";import"../../chunk-455NK5LB.js";import"../../chunk-HXN3ZART.js";import"../../chunk-IBQQA6L3.js";import"../../chunk-NU7VF7MC.js";export{a as solanaChainAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkPZC2L2XZcjs = require('../../chunk-PZC2L2XZ.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-ILCNZB3A.cjs');require('../../chunk-J5W5S2WG.cjs');require('../../chunk-DSIFRRBS.cjs');exports.stellarChainAdapter = _chunkPZC2L2XZcjs.a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-IASKJ4WS.js";import"../../chunk-455NK5LB.js";import"../../chunk-HXN3ZART.js";import"../../chunk-IBQQA6L3.js";import"../../chunk-NU7VF7MC.js";export{a as stellarChainAdapter};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk6DEQI3XTcjs = require('../chunk-6DEQI3XT.cjs');require('../chunk-23X5QOE6.cjs');require('../chunk-KZ62YXDQ.cjs');require('../chunk-PZC2L2XZ.cjs');require('../chunk-TM77X7C3.cjs');require('../chunk-ENU3EKBG.cjs');require('../chunk-LHAOCUXT.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-ILCNZB3A.cjs');require('../chunk-J5W5S2WG.cjs');require('../chunk-DSIFRRBS.cjs');exports.getChainAdapter = _chunk6DEQI3XTcjs.a; exports.isSupportedChainType = _chunk6DEQI3XTcjs.b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../chunk-
|
|
1
|
+
import{a,b}from"../chunk-SSC676RL.js";import"../chunk-5KGXMZFJ.js";import"../chunk-DZAG4SRY.js";import"../chunk-IASKJ4WS.js";import"../chunk-6HB4WO5J.js";import"../chunk-OQZTL6ZG.js";import"../chunk-SLPKMZNW.js";import"../chunk-455NK5LB.js";import"../chunk-HXN3ZART.js";import"../chunk-IBQQA6L3.js";import"../chunk-NU7VF7MC.js";export{a as getChainAdapter,b as isSupportedChainType};
|
package/dist/chains/chains.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkE7Z24LRScjs = require('../chunk-E7Z24LRS.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-LHAOCUXT.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-ILCNZB3A.cjs');require('../chunk-J5W5S2WG.cjs');require('../chunk-DSIFRRBS.cjs');exports.isMainnetChain = _chunkE7Z24LRScjs.c; exports.isTestnetChain = _chunkE7Z24LRScjs.b; exports.isValidChain = _chunkE7Z24LRScjs.e; exports.mainnetToTestnet = _chunkE7Z24LRScjs.d; exports.toViemChain = _chunkE7Z24LRScjs.a; exports.validateChainForEnvironment = _chunkE7Z24LRScjs.f;
|
package/dist/chains/chains.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f}from"../chunk-
|
|
1
|
+
import{a,b,c,d,e,f}from"../chunk-WLTYJRB5.js";import"../chunk-FT5EVMLB.js";import"../chunk-SVIKBM3S.js";import"../chunk-KKQBZXFE.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-SLPKMZNW.js";import"../chunk-455NK5LB.js";import"../chunk-HXN3ZART.js";import"../chunk-IBQQA6L3.js";import"../chunk-NU7VF7MC.js";export{c as isMainnetChain,b as isTestnetChain,e as isValidChain,d as mainnetToTestnet,a as toViemChain,f as validateChainForEnvironment};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as s,b as o}from"./chunk-
|
|
1
|
+
import{a as s,b as o}from"./chunk-5OGNXLOH.js";import{a as r}from"./chunk-HXN3ZART.js";import{h as t}from"./chunk-NU7VF7MC.js";import{VersionedTransaction as u}from"@solana/web3.js";import a from"bs58";var g=class c extends s{constructor(n){super(n)}signMessage(){return t(this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for email signer"))})}signTransaction(n){return t(this,null,function*(){var i;yield this.handleAuthRequired();let d=this.getJwtOrThrow(),m=a.decode(n),y=u.deserialize(m).message.serialize();r.info("sign: sending request",{keyType:"ed25519"});let l=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:d,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:a.encode(new Uint8Array(y)),encoding:"base58"}},options:o});if(r.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-l}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");return c.verifyPublicKeyFormat(e.publicKey),{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base58"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base58 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"base58"}}};export{g as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTM77X7C3cjs = require('./chunk-TM77X7C3.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTM77X7C3cjs = require('./chunk-TM77X7C3.cjs');var _chunkLHAOCUXTcjs = require('./chunk-LHAOCUXT.cjs');var _chunkILCNZB3Acjs = require('./chunk-ILCNZB3A.cjs');var f={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw _chunkILCNZB3Acjs.a.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw _chunkILCNZB3Acjs.a.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new (0, _chunkLHAOCUXTcjs.j)(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return _chunkTM77X7C3cjs.c.call(void 0, e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};exports.a = f;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTVD45ZZMcjs = require('./chunk-TVD45ZZM.cjs');var _chunkQYNJ3CQPcjs = require('./chunk-QYNJ3CQP.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkTM77X7C3cjs = require('./chunk-TM77X7C3.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a,n,d,g,S,C,u,h,v,y,x= exports.a =class{constructor(r){_chunkDSIFRRBScjs.e.call(void 0, this,a);_chunkDSIFRRBScjs.e.call(void 0, this,n);_chunkDSIFRRBScjs.e.call(void 0, this,d);_chunkDSIFRRBScjs.e.call(void 0, this,g);_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,C);_chunkDSIFRRBScjs.e.call(void 0, this,u);_chunkDSIFRRBScjs.e.call(void 0, this,h);_chunkDSIFRRBScjs.e.call(void 0, this,v);_chunkDSIFRRBScjs.e.call(void 0, this,y);_chunkDSIFRRBScjs.f.call(void 0, this,d,r.apiClient),_chunkDSIFRRBScjs.f.call(void 0, this,g,r.options),_chunkDSIFRRBScjs.f.call(void 0, this,S,r.chain),_chunkDSIFRRBScjs.f.call(void 0, this,C,r.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,u,r.walletLocator),_chunkDSIFRRBScjs.f.call(void 0, this,h,r.serverSignerResolver),_chunkDSIFRRBScjs.f.call(void 0, this,n,r.recovery),_chunkDSIFRRBScjs.f.call(void 0, this,v,r.initialSigners),_chunkDSIFRRBScjs.f.call(void 0, this,y,r.signers),_chunkDSIFRRBScjs.f.call(void 0, this,a,r.signer)}get activeSigner(){return _chunkDSIFRRBScjs.d.call(void 0, this,a)}setActiveSigner(r){_chunkDSIFRRBScjs.f.call(void 0, this,a,r)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,n)}descriptorContext(){var r,i,t,l,c;return{chain:_chunkDSIFRRBScjs.d.call(void 0, this,S),walletAddress:_chunkDSIFRRBScjs.d.call(void 0, this,C),crossmint:_chunkDSIFRRBScjs.d.call(void 0, this,d).crossmint,clientTEEConnection:(r=_chunkDSIFRRBScjs.d.call(void 0, this,g))==null?void 0:r.clientTEEConnection,resetSignerFrame:(i=_chunkDSIFRRBScjs.d.call(void 0, this,g))==null?void 0:i.resetSignerFrame,onAuthRequired:(l=(t=_chunkDSIFRRBScjs.d.call(void 0, this,g))==null?void 0:t.callbacks)==null?void 0:l.onAuthRequired,deviceSignerKeyStorage:(c=_chunkDSIFRRBScjs.d.call(void 0, this,g))==null?void 0:c.deviceSignerKeyStorage,serverSigners:_chunkDSIFRRBScjs.d.call(void 0, this,h)}}adoptRecoveryConfig(r){_chunkDSIFRRBScjs.f.call(void 0, this,n,r)}stripSecretFromRecovery(){let r=_chunkDSIFRRBScjs.d.call(void 0, this,h).resolvedRecoveryAddress;_chunkDSIFRRBScjs.d.call(void 0, this,n)!=null&&_chunkDSIFRRBScjs.d.call(void 0, this,n).type==="server"&&!_chunkQPCZFIUVcjs.f.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,n))&&r!=null&&_chunkDSIFRRBScjs.f.call(void 0, this,n,{type:"server",address:r})}assemble(r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var l,c;let t=_chunkQYNJ3CQPcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,S),r,(l=_chunkDSIFRRBScjs.d.call(void 0, this,g))==null?void 0:l.deviceSignerKeyStorage);if(i!=null&&i.isAdminSigner)t.status="active";else{let f=yield this.getSignerState(t.locator());t.status=(c=f.signer)==null?void 0:c.status}return t})}require(){if(_chunkDSIFRRBScjs.d.call(void 0, this,a)==null){if(_chunkDSIFRRBScjs.d.call(void 0, this,v).length>1)throw new Error("No signer is set. This wallet has multiple signers configured. Call wallet.useSigner() to select which signer to use before signing operations.");let r=_chunkTVD45ZZMcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,n).type),i=r.signerUnavailableReason();throw i!=null?new Error(i):r.canAutoAssemble(_chunkDSIFRRBScjs.d.call(void 0, this,n),this.descriptorContext())?new Error("This wallet is read-only because no signer was provided. Operations that require signing (send, approve, addSigner, etc.) are not available."):new Error("No signer is set. This wallet requires calling wallet.useSigner() before signing operations.")}return _chunkDSIFRRBScjs.d.call(void 0, this,a)}withRecoverySigner(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var f;let i=_chunkDSIFRRBScjs.d.call(void 0, this,a);if(_chunkQPCZFIUVcjs.f.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,n))&&!_chunkDSIFRRBScjs.d.call(void 0, this,h).hasRecoveryResolution)throw new Error('Cannot assemble server signer: no secret available. Call wallet.useSigner({ type: "server", secret: ... }) first with the recovery server secret.');let t=_chunkTVD45ZZMcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,n).type),l=this.descriptorContext();if(_chunkDSIFRRBScjs.d.call(void 0, this,n)!=null&&_chunkDSIFRRBScjs.d.call(void 0, this,n).type==="external-wallet"&&!t.canAutoAssemble(_chunkDSIFRRBScjs.d.call(void 0, this,n),l))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 c=t.buildInternalConfig(_chunkDSIFRRBScjs.d.call(void 0, this,n),l);_chunkDSIFRRBScjs.f.call(void 0, this,a,_chunkQYNJ3CQPcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,S),c,(f=_chunkDSIFRRBScjs.d.call(void 0, this,g))==null?void 0:f.deviceSignerKeyStorage));try{return yield r()}finally{_chunkDSIFRRBScjs.f.call(void 0, this,a,i)}})}getSignerState(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let i=null;try{i=yield _chunkDSIFRRBScjs.d.call(void 0, this,d).getSigner(_chunkDSIFRRBScjs.d.call(void 0, this,u).call(this),r)}catch(l){return{response:null,signer:null,pendingOperation:null}}if(i==null||typeof i!="object"||"error"in i)return{response:null,signer:null,pendingOperation:null};let t=_chunkTM77X7C3cjs.b.call(void 0, i,_chunkDSIFRRBScjs.d.call(void 0, this,S));return{response:i,signer:t,pendingOperation:_chunkTM77X7C3cjs.c.call(void 0, i,_chunkDSIFRRBScjs.d.call(void 0, this,S))}})}signerIsRegistered(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield _chunkDSIFRRBScjs.d.call(void 0, this,y).call(this)).some(t=>t.locator===r)})}isSignerApproved(r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var t;let i=yield this.getSignerState(r);return this.isApprovedSignerStatus((t=i.signer)==null?void 0:t.status)})}isApprovedSignerStatus(r){return r==="success"||r==="active"}};a=new WeakMap,n=new WeakMap,d=new WeakMap,g=new WeakMap,S=new WeakMap,C=new WeakMap,u=new WeakMap,h=new WeakMap,v=new WeakMap,y=new WeakMap;exports.a = x;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as x,B as A,C as y,D as k,H as w,r as M,u as m,w as b,z as C}from"./chunk-SLPKMZNW.js";import{a as E}from"./chunk-HXN3ZART.js";import{d as S}from"./chunk-IBQQA6L3.js";import{h as l}from"./chunk-NU7VF7MC.js";function W(i,o,a,r){return l(this,null,function*(){var h,d;let{timeoutMs:e=6e4,initialBackoffMs:u=500,backoffMultiplier:n=1.5,maxBackoffMs:f=2e3,fastWindowMs:L=5e3}=r!=null?r:{};E.info("wallet.approve: waiting for transaction confirmation",{transactionId:a,timeoutMs:e});let p=Date.now(),c=u,t;do{if(Date.now()-p>e)throw new x("Transaction confirmation timeout");let s=Date.now();if(t=yield i.getTransaction(o,a),t.error)throw w(t),new C(JSON.stringify(t));if(t.status!=="pending")break;let T=Date.now()-p;T>L&&(c=Math.min(Math.round(c*n),f));let v=Date.now()-s;yield D(Math.max(1,Math.min(c-v,e-T)))}while(!0);if(t.status==="failed")throw new A(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new y("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let P="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(h=t.onChain.txId)!=null?h:P;if(g==null)throw new k("Transaction hash not found on transaction response");return{hash:g,explorerLink:(d=t.onChain.explorerLink)!=null?d:"",transactionId:t.id}})}function B(i,o,a,r){return l(this,null,function*(){let{timeoutMs:e=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>e)throw new b("Signature confirmation timeout");if(yield new Promise(f=>setTimeout(f,S)),n=yield i.getSignature(o,a),"error"in n)throw w(n),new m(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new M("Signature signing failed");if(!n.outputSignature)throw new m("Signature not available");return{signature:n.outputSignature,signatureId:a}})}function D(i){return l(this,null,function*(){return new Promise(o=>setTimeout(o,i))})}export{W as a,B as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as se}from"./chunk-N5LPV5FV.js";import{a as ae,b as oe}from"./chunk-2SUPM5NU.js";import{a as ne}from"./chunk-DX2WEUVJ.js";import{a as ie}from"./chunk-5M4L42QQ.js";import{a as ee}from"./chunk-OMTJMVSG.js";import{a as F}from"./chunk-E2GL7NJM.js";import{a as D}from"./chunk-PJKTUGX2.js";import{a as re,b as te}from"./chunk-VMXMHGSE.js";import{a as Z}from"./chunk-5OGNXLOH.js";import{f as J}from"./chunk-DCKFFFPG.js";import{a as X,b as Y}from"./chunk-SSC676RL.js";import{b as Q}from"./chunk-6HB4WO5J.js";import{f as K}from"./chunk-WLTYJRB5.js";import{E as V,H as O,d as M,e as _,j as k,l as G,m as U,u as H,v as j,x as q,y as B,z}from"./chunk-SLPKMZNW.js";import{a as s}from"./chunk-HXN3ZART.js";import{a as f,b as N,c as R,d as i,e as b,f as m,h as o}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as W}from"@crossmint/common-sdk-base";var I,c,T,P,l,w,E,L,x,A=class{constructor(e,r){b(this,I);b(this,c);b(this,T);b(this,P);b(this,l);b(this,w);b(this,E,[]);b(this,L);b(this,x,null);let{chain:t,address:n,owner:a,options:u,alias:S,recovery:p,apiRecoveryServerSignerAddress:g,apiDelegatedServerSignerAddresses:d,signers:y,signer:h}=e;m(this,c,r),this.chain=t,this.address=n,this.owner=a,m(this,I,u),this.alias=S;let C=null;g!=null?C=g:p.type==="server"&&J(p)&&(C=p.address),m(this,E,d!=null?d:[]),m(this,T,y!=null?y:[]),m(this,P,new ee({chain:t,projectId:i(this,c).projectId,environment:i(this,c).environment,apiRecoveryAddress:C,apiDelegatedAddresses:i(this,E),knownOnChainAddresses:()=>[...i(this,T).filter(v=>v.type==="server"&&J(v)).map(v=>v.address),...i(this,E)]})),m(this,l,new ne({apiClient:r,options:u,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:i(this,P),recovery:p,initialSigners:i(this,T),signers:()=>this.signers(),signer:h})),m(this,w,new se({chain:t,walletAddress:this.address,options:u,signerManager:i(this,l),serverSignerResolver:i(this,P),signers:()=>this.signers(),addSigner:v=>this.addSigner(v),approveSignature:v=>this.approveSignatureAndWait(v),approveTransaction:v=>this.approveTransactionAndWait(v)})),m(this,L,this.initDefaultSigner())}get signer(){return i(this,l).activeSigner}waitForInit(){return o(this,null,function*(){yield i(this,L)})}initDefaultSigner(){return o(this,null,function*(){if(i(this,l).activeSigner!=null||(yield i(this,w).initDeviceSigner(),i(this,l).activeSigner!=null||i(this,w).needsRecovery))return;let e=i(this,T).length===0?i(this,l).recovery:i(this,T).length===1?i(this,T)[0]:null;if(e==null)return;let r=F(e.type),t=i(this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===i(this,l).recovery;try{let a=r.buildInternalConfig(e,t);i(this,l).setActiveSigner(yield i(this,l).assemble(a,{isAdminSigner:n}))}catch(a){s.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,l).recovery.type,signerCount:i(this,T).length,error:a})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return i(e,l).recovery}static getInitialSigners(e){return i(e,T)}static getApiRecoveryServerSignerAddress(e){var r;return(r=i(e,P).apiRecoveryAddress)!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return i(e,E)}get apiClient(){return i(this,c)}get options(){return i(this,I)}get chainAdapter(){return X(this.chain)}resolveServerSignerApiLocator(e){return i(this,P).apiLocator(e)}get recovery(){return i(this,l).recovery}balances(e){return o(this,null,function*(){s.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],a=yield i(this,c).getBalance(this.address,{chains:[r],tokens:n});if("error"in a)throw s.error("wallet.balances.error",{error:a}),new Error(`Failed to get balances for wallet: ${JSON.stringify(a.message)}`);return s.info("wallet.balances.success"),ie(a,this.chain,t,e)})}stagingFund(e,r){return o(this,null,function*(){s.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 s.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return s.info("wallet.stagingFund.success"),t})}nfts(e){return o(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield i(this,c).getNfts(N(f({},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw s.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return o(this,null,function*(){let e=yield i(this,c).getTransactions(this.walletLocator);if("error"in e)throw new Error(`Failed to get transactions: ${JSON.stringify(e.message)}`);return e})}transaction(e){return o(this,null,function*(){let r=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in r)throw new Error(`Failed to get transaction: ${JSON.stringify(r.message)}`);return r})}transfers(e){return o(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 o(this,null,function*(){let a=Number(t);if(Number.isNaN(a)||!Number.isFinite(a)||a<=0)throw new q(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let u=re(e),S=this.resolveChainForEnvironment(),p=te(r,S);s.info("wallet.send.start",f({recipient:u,token:p,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let g=i(this,l).require(),d;(n==null?void 0:n.signer)==null?d=g.locator():typeof n.signer=="string"?d=n.signer:d=this.resolveServerSignerApiLocator(n.signer);let y=f({recipient:u,amount:t,signer:d},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),h=yield i(this,c).send(this.walletLocator,p,y);if("message"in h)throw s.error("wallet.send.error",{error:h}),new B(`Failed to send token: ${JSON.stringify(h.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return s.info("wallet.send.prepared",{transactionId:h.id}),{hash:void 0,explorerLink:void 0,transactionId:h.id};let C=yield this.approveTransactionAndWait(h.id);return s.info("wallet.send.success",{transactionId:h.id,hash:C.hash}),C})}approveTransaction(e){return o(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 o(this,null,function*(){if(s.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 s.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return s.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw s.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 o(this,null,function*(){s.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return i(this,l).withRecoverySigner(()=>o(this,null,function*(){var h;let n=typeof t=="string"?t:D(t),a=yield i(this,l).getSignerState(n);if(a.signer!=null){if(i(this,l).isApprovedSignerStatus(a.signer.status))return(r==null?void 0:r.scopes)!=null&&s.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:n}),s.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(a.signer,null,r);if(a.pendingOperation!=null){if((r==null?void 0:r.scopes)!=null)throw new Error("Cannot apply scopes when resuming a pending signer registration. Remove the pending signer and register it again with the desired scopes.");return s.info("wallet.addSigner.resuming",{operationType:a.pendingOperation.type,operationId:a.pendingOperation.id}),this.completeSignerRegistration(a.signer,a.pendingOperation,r)}}let u=typeof t=="string"?t:F(t.type).addSignerPayload(t,i(this,l).descriptorContext()),p=this.chain!=="solana"&&this.chain!=="stellar"?(h=r==null?void 0:r.deployImmediately)!=null?h:!0:void 0,g=yield i(this,c).registerSigner(this.walletLocator,f(f({signer:u,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),p!=null&&{deployImmediately:p}));if("error"in g)throw s.error("wallet.addSigner.error",{error:g}),g.code===G?new U(g.message):new k(`Failed to register signer: ${JSON.stringify(g.message)}`);let d=Q(g,this.chain);if(d==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let y=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:n,type:e.type});return this.completeSignerRegistration(d,y,r)}))})}completeSignerRegistration(e,r,t){return o(this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return f({},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return s.info("wallet.addSigner.prepared",n),f(f({},e),n)}case"signature":{let n={signatureId:r.id};return s.info("wallet.addSigner.prepared",n),f(f({},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),s.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),s.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else s.info("wallet.addSigner.success");return N(f({},e),{status:"success"})})}removeSigner(e,r){return o(this,null,function*(){let t=this.resolveSignerLocator(e);return s.info("wallet.removeSigner.start",{signerLocator:t}),i(this,l).withRecoverySigner(()=>o(this,null,function*(){let n=yield i(this,c).removeSigner(this.walletLocator,t,{chain:this.chainAdapter.addSignerChain(this.chain)});if("error"in n)throw s.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let a=n.id;return r!=null&&r.prepareOnly?(s.info("wallet.removeSigner.prepared",{transactionId:a}),{transactionId:a,status:void 0}):(yield this.approveTransactionAndWait(a),s.info("wallet.removeSigner.success",{transactionId:a}),{transactionId:a,status:"success"})}))})}useSigner(e){return o(this,null,function*(){s.info("wallet.useSigner.start"),e.type==="server"&&i(this,P).resetDelegatedCache(),F(e.type).validateConfig(e);let r=!1;e.type==="device"?yield i(this,w).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=F(e.type).buildInternalConfig(e,i(this,l).descriptorContext()),n=D(e);i(this,l).setActiveSigner(yield i(this,l).assemble(t,{isAdminSigner:r})),s.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return o(this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return i(this,w).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return i(this,w).onSignerSelected(),!0;throw new Error("No passkey signer is registered on this wallet.")}if(e.type==="server")return this.resolveServerSigner(e);let r=this.resolveSignerLocator(e);if(yield this.signerIsRegistered(r))return i(this,w).onSignerSelected(),!1;if(this.isRecoverySigner(e))return i(this,w).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return o(this,null,function*(){let t=(yield this.signers()).map(a=>a.locator),n=i(this,P).resolveForUseSigner(e,t,()=>this.isRecoverySigner(e));switch(n.kind){case"delegated":return i(this,w).onSignerSelected(),!1;case"recovery":return i(this,l).stripSecretFromRecovery(),i(this,w).onSignerSelected(),!0;case"unregistered":throw new Error(n.message)}})}tryAutoSelectPasskey(e){return o(this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):D(e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return o(this,null,function*(){return i(this,l).signerIsRegistered(e)})}isSignerApproved(e){return o(this,null,function*(){return i(this,l).isSignerApproved(e)})}needsRecovery(){return i(this,w).needsRecovery}recover(){return o(this,null,function*(){yield i(this,w).recover()})}signers(){return o(this,null,function*(){var a,u;s.info("wallet.signers.start");let e=yield i(this,c).getWallet(this.walletLocator);if("error"in e)throw s.error("wallet.signers.error",{error:e}),new _(JSON.stringify(e));if(!pe(e)){let S=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw s.error("wallet.signers.error",{error:S}),new M(S)}let r=(u=(a=e==null?void 0:e.config)==null?void 0:a.delegatedSigners)!=null?u:[],n=(yield Promise.all(r.map(S=>o(this,null,function*(){try{return(yield i(this,l).getSignerState(S.locator)).signer}catch(p){return null}})))).filter(S=>S!=null);return s.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(i(this,c).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return i(this,l)}preAuthIfNeeded(){return o(this,null,function*(){yield i(this,L),i(this,x)==null&&m(this,x,this.recover());try{yield i(this,x)}finally{m(this,x,null)}let e=i(this,l).require();e instanceof Z&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=i(this,l).recovery;if(r==null||r.type!==e.type)return!1;let t=F(e.type);return t.matchesRecovery(e,r,i(this,l).descriptorContext())?(t.adoptsRecoveryConfigOnMatch&&i(this,l).adoptRecoveryConfig(e),!0):!1}resolveChainForEnvironment(){let e=K(this.chain,i(this,c).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return o(this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return o(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 o(this,null,function*(){var p,g;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=i(this,l).require(),n=yield i(this,c).getSignature(this.walletLocator,e);if("error"in n)throw O(n),new H(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let d=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,d)}let a=(p=n.approvals)==null?void 0:p.pending;if(a==null||a.length===0)return n;let u=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],t],S=yield Promise.all(a.map(d=>o(this,null,function*(){let y=u.find(C=>C.locator()===d.signer.locator);if(y==null)throw new k(`Signer ${d.signer.locator} not found in pending approvals`);let h=yield y.signMessage(d.message);return N(f({},h),{signer:y.locator()})})));return yield this.executeApproveSignatureWithErrorHandling(e,S)})}approveTransactionInternal(e,r){return o(this,null,function*(){var p,g,d,y,h;let t=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in t)throw O(t),new z(JSON.stringify(t));yield(d=(g=(p=i(this,I))==null?void 0:p.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:d.call(g);let n=i(this,l).require();if(n.type==="api-key")return t;if((r==null?void 0:r.approval)!=null){let C=[r.approval];return yield this.executeApproveTransactionWithErrorHandling(e,C)}let a=(y=t.approvals)==null?void 0:y.pending;if(a==null||a.length===0)return t;let u=[...(h=r==null?void 0:r.additionalSigners)!=null?h:[],n],S=yield Promise.all(a.map(C=>o(this,null,function*(){let v=u.find(de=>de.locator()===C.signer.locator);if(v==null)throw new k(`Signer ${C.signer.locator} not found in pending approvals`);let le=v.type==="device",ce=t.chainType==="solana"&&"transaction"in t.onChain&&!le?t.onChain.transaction:C.message,ge=yield v.signTransaction(ce);return N(f({},ge),{signer:v.locator()})})));return yield this.executeApproveTransactionWithErrorHandling(e,S)})}executeApproveTransactionWithErrorHandling(e,r){return o(this,null,function*(){s.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield i(this,c).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw O(t),new V(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return o(this,null,function*(){let t=yield i(this,c).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw O(t),new j(JSON.stringify(t));return t})}waitForSignature(e){return o(this,null,function*(){return yield oe(i(this,c),this.walletLocator,e)})}waitForTransaction(n){return o(this,arguments,function*(e,r=6e4,t={}){return yield ae(i(this,c),this.walletLocator,e,f({timeoutMs:r},t))})}sleep(e){return o(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};I=new WeakMap,c=new WeakMap,T=new WeakMap,P=new WeakMap,l=new WeakMap,w=new WeakMap,E=new WeakMap,L=new WeakMap,x=new WeakMap,R([W({logger:s,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"balances",1),R([W({logger:s,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"stagingFund",1),R([W({logger:s,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"send",1),R([W({logger:s,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"approve",1),R([W({logger:s,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"addSigner",1),R([W({logger:s,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"removeSigner",1),R([W({logger:s,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"useSigner",1),R([W({logger:s,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"recover",1),R([W({logger:s,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],A.prototype,"signers",1);function pe($){return $.type==="smart"&&Y($.chainType)}export{A as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as g}from"./chunk-
|
|
1
|
+
import{a,b as g}from"./chunk-5OGNXLOH.js";import{a as s}from"./chunk-HXN3ZART.js";import{h as t}from"./chunk-NU7VF7MC.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
1
|
+
import{a as n}from"./chunk-CTJQUZUF.js";import{a as s}from"./chunk-5LNDUSMZ.js";import{a as l}from"./chunk-HBGLYYE4.js";import{a,b as i}from"./chunk-HXN3ZART.js";import{h as r}from"./chunk-NU7VF7MC.js";import{createCrossmint as C}from"@crossmint/common-sdk-base";import{WebAuthnP256 as p}from"ox";var o=class c{constructor(e){i(e.apiKey);let t=new l(e);this.walletFactory=new n(t),a.info("wallets.sdk.initialized")}static from(e){return new c(e)}getWallet(e,t){return r(this,null,function*(){if(typeof e=="string"){if(t==null)throw new Error("Args parameter is required when walletLocator is provided");return yield this.walletFactory.getWallet(e,t)}return yield this.walletFactory.getWallet(e)})}createWallet(e){return r(this,null,function*(){return yield this.walletFactory.createWallet(e)})}createDeviceSigner(e,t){return r(this,null,function*(){return yield s(e,t)})}createPasskeySigner(e){return r(this,null,function*(){let t=yield p.createCredential({name:e});return{type:"passkey",id:t.id,name:e,publicKey:{x:t.publicKey.x.toString(),y:t.publicKey.y.toString()}}})}};export{C as a,o as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkLHAOCUXTcjs = require('./chunk-LHAOCUXT.cjs');var _chunkILCNZB3Acjs = require('./chunk-ILCNZB3A.cjs');var _chunkJ5W5S2WGcjs = require('./chunk-J5W5S2WG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function R(i,o,a,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var h,d;let{timeoutMs:e=6e4,initialBackoffMs:u=500,backoffMultiplier:n=1.5,maxBackoffMs:f=2e3,fastWindowMs:L=5e3}=r!=null?r:{};_chunkILCNZB3Acjs.a.info("wallet.approve: waiting for transaction confirmation",{transactionId:a,timeoutMs:e});let p=Date.now(),c=u,t;do{if(Date.now()-p>e)throw new (0, _chunkLHAOCUXTcjs.A)("Transaction confirmation timeout");let s=Date.now();if(t=yield i.getTransaction(o,a),t.error)throw _chunkLHAOCUXTcjs.H.call(void 0, t),new (0, _chunkLHAOCUXTcjs.z)(JSON.stringify(t));if(t.status!=="pending")break;let T=Date.now()-p;T>L&&(c=Math.min(Math.round(c*n),f));let v=Date.now()-s;yield D(Math.max(1,Math.min(c-v,e-T)))}while(!0);if(t.status==="failed")throw new (0, _chunkLHAOCUXTcjs.B)(`Transaction sending failed: ${JSON.stringify(t)}`);if(t.status==="awaiting-approval")throw new (0, _chunkLHAOCUXTcjs.C)("Transaction is awaiting approval. Please submit required approvals before waiting for completion.");let P="txHash"in t.onChain&&typeof t.onChain.txHash=="string"?t.onChain.txHash:void 0,g=(h=t.onChain.txId)!=null?h:P;if(g==null)throw new (0, _chunkLHAOCUXTcjs.D)("Transaction hash not found on transaction response");return{hash:g,explorerLink:(d=t.onChain.explorerLink)!=null?d:"",transactionId:t.id}})}function W(i,o,a,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let{timeoutMs:e=6e4}=r!=null?r:{},u=Date.now(),n=null;do{if(Date.now()-u>e)throw new (0, _chunkLHAOCUXTcjs.w)("Signature confirmation timeout");if(yield new Promise(f=>setTimeout(f,_chunkJ5W5S2WGcjs.d)),n=yield i.getSignature(o,a),"error"in n)throw _chunkLHAOCUXTcjs.H.call(void 0, n),new (0, _chunkLHAOCUXTcjs.u)(JSON.stringify(n))}while(n===null||n.status==="pending");if(n.status==="failed")throw new (0, _chunkLHAOCUXTcjs.r)("Signature signing failed");if(!n.outputSignature)throw new (0, _chunkLHAOCUXTcjs.u)("Signature not available");return{signature:n.outputSignature,signatureId:a}})}function D(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(o=>setTimeout(o,i))})}exports.a = R; exports.b = W;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk5UR3TR3Hcjs = require('./chunk-5UR3TR3H.cjs');var _chunkILCNZB3Acjs = require('./chunk-ILCNZB3A.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a=class g extends _chunk5UR3TR3Hcjs.a{constructor(n){super(n)}signMessage(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.reject(new Error("signMessage method not implemented for stellar signer"))})}signTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;yield this.handleAuthRequired();let c=this.getJwtOrThrow();_chunkILCNZB3Acjs.a.info("sign: sending request",{keyType:"ed25519"});let d=Date.now(),e=yield(i=this.config.clientTEEConnection)==null?void 0:i.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:c,apiKey:this.config.crossmint.apiKey},data:{keyType:"ed25519",bytes:n,encoding:"base64"}},options:_chunk5UR3TR3Hcjs.b});if(_chunkILCNZB3Acjs.a.info("sign: response received",{status:e==null?void 0:e.status,durationMs:Date.now()-d}),(e==null?void 0:e.status)==="error")throw new Error(e.error);if((e==null?void 0:e.signature)==null)throw new Error("Failed to sign transaction");if(g.verifyPublicKeyFormat(e.publicKey),e.signature.encoding!=="base64")throw new Error("Wrong encoding for signature. Expected base64, got "+e.signature.encoding);return{signature:e.signature.bytes}})}static verifyPublicKeyFormat(n){if(n==null)throw new Error("No public key found");if(n.encoding!=="base64"||n.keyType!=="ed25519"||n.bytes==null)throw new Error("Not supported. Expected public key to be in base64 encoding and ed25519 key type. Got: "+JSON.stringify(n))}getChainKeyParams(){return{scheme:"ed25519",encoding:"strkey"}}};exports.a = a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as g}from"./chunk-6HB4WO5J.js";import{j as s}from"./chunk-
|
|
1
|
+
import{c as g}from"./chunk-6HB4WO5J.js";import{j as s}from"./chunk-SLPKMZNW.js";import{a as i}from"./chunk-HXN3ZART.js";var h={nativeToken:"eth",walletLocatorPrefix:"me:evm:smart",supportsSignatures:!0,addSignerChain(e){return e},extractAddSignerOperation(e,r,n){var a,t,o,d;if(!("chains"in e))throw i.error("wallet.addSigner.error",{error:"Expected chains in response for EVM chain"}),new Error("Expected chains in response for EVM chain");if(((t=(a=e.chains)==null?void 0:a[r])==null?void 0:t.status)==="failed")throw i.error("wallet.addSigner.failed",{chain:r,signerType:n.type,signerLocator:n.locator,chainStatus:(o=e.chains)==null?void 0:o[r]}),new s(`Signer registration failed for chain ${r} (signer: ${n.locator})`,JSON.stringify((d=e.chains)==null?void 0:d[r]));return g(e,r)},balanceTokenFields(e){return e!=null&&"contractAddress"in e?{contractAddress:e.contractAddress}:{}},emptyBalanceTokenFields(){return{contractAddress:void 0}}};export{h as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as m}from"./chunk-
|
|
1
|
+
import{a as m}from"./chunk-SSC676RL.js";import{a as C}from"./chunk-OQZTL6ZG.js";import{a as u}from"./chunk-NU7VF7MC.js";function d(s,n){var e,l,r,i,a;let t=(e=s.chains)==null?void 0:e[n],o=m(n).balanceTokenFields(t);return u({symbol:(l=s.symbol)!=null?l:"",name:(r=s.name)!=null?r:"",amount:(i=s.amount)!=null?i:"0",decimals:s.decimals,rawAmount:(a=s.rawAmount)!=null?a:"0"},o)}function h(s,n){let t={symbol:s,name:s,amount:"0",decimals:0,rawAmount:"0"},o=m(n).emptyBalanceTokenFields();return u(u({},t),o)}function B(s,n,t){var r,i,a,f,p;if(n==null)return!0;let o=((r=s.symbol)!=null?r:"").toLowerCase();if(n.has(o))return!0;let e=(i=s.chains)==null?void 0:i[t];if(e==null)return!1;let l=C(t);if(l==="solana"&&"mintHash"in e){let c=(a=e.mintHash)==null?void 0:a.toLowerCase();return c!=null&&(n.has(c)||n.has(`solana:${c}`))}if(l==="stellar"&&"contractId"in e){let c=(f=e.contractId)==null?void 0:f.toLowerCase();return c!=null&&(n.has(c)||n.has(`stellar:${c}`))}if("contractAddress"in e){let c=(p=e.contractAddress)==null?void 0:p.toLowerCase();return c!=null&&(n.has(c)||n.has(`${t}:${c}`))}return!1}function g(s,n,t,o){let e=s.find(a=>a.symbol===t),l=s.find(a=>a.symbol==="usdc"),r=o!=null?new Set(o.map(a=>a.toLowerCase())):null,i=s.filter(a=>a.symbol!==t&&a.symbol!=="usdc"&&B(a,r,n));return{nativeToken:e!=null?d(e,n):h(t,n),usdc:l!=null?d(l,n):h("usdc",n),tokens:i.map(a=>d(a,n))}}export{g as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as f}from"./chunk-IHMMTMFG.js";import{a as u,b as g,c as w,d as v,e as y}from"./chunk-DCKFFFPG.js";import{a as r}from"./chunk-
|
|
1
|
+
import{a as f}from"./chunk-IHMMTMFG.js";import{a as u,b as g,c as w,d as v,e as y}from"./chunk-DCKFFFPG.js";import{a as r}from"./chunk-HXN3ZART.js";import{c as E,h}from"./chunk-NU7VF7MC.js";import{validateAPIKey as P,WithLoggerContext as A}from"@crossmint/common-sdk-base";var m=class{constructor(i){this.config=i;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return h(this,null,function*(){try{if(this.config.clientTEEConnection==null){let i=P(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new f({environment:i.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return h(this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return h(this,null,function*(){r.info("TEE connection not initialized, initializing now");let i=P(this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new f({environment:i.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");r.info("TEE connection initialized successfully")})}handleAuthRequired(){return h(this,null,function*(){var d;let i=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);r.info("get-status: sending request");let t=Date.now(),e=yield i.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),n=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw r.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:n}),new w(c,p)}if(r.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:n}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;r.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:o,reject:a}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:o,reject:a},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>h(this,null,function*(){r.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new u)})),a(new u)}))}catch(c){r.error("handleAuthRequired error",{error:c}),a(c)}try{yield s}catch(c){throw r.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return h(this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null)throw new Error("JWT is required");return i}createAuthPromise(){let i,t;return{promise:new Promise((n,s)=>{i=n,t=s}),resolve:i,reject:t}}sendMessageWithOtp(){return h(this,null,function*(){var o;let i=yield this.getTEEConnection(),t=this.getAuthId();r.info("start-onboarding: sending request");let e=Date.now(),n=yield i.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(o=this.config.crossmint.jwt)!=null?o:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:l}),s=Date.now()-e;if(this._onboardingConnectionGeneration=i.connectionGeneration,r.info("start-onboarding: response received",{status:n==null?void 0:n.status,durationMs:s}),(n==null?void 0:n.status)==="success"&&n.signerStatus==="ready"){this._needsAuth=!1;return}if((n==null?void 0:n.status)==="error")throw r.error("start-onboarding: failed",{error:n.error,code:n.code}),new g(n.error||"Failed to initiate OTP process.",n.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(i){return h(this,null,function*(){var s,o;let t;try{let a=yield this.getTEEConnection();r.info("complete-onboarding: sending request");let d=Date.now();t=yield a.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:i}}},options:l}),r.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(a){return r.error("complete-onboarding: error",{error:a}),yield this.handleOnboardingVerificationFailure(a)}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(),a=>this.verifyOtp(a),()=>{var a;return(a=this._authPromise)==null?void 0:a.reject(new u)})),(o=this._authPromise)==null||o.resolve();return}r.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",n=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new g(e,n))})}handleOnboardingVerificationFailure(i){return h(this,null,function*(){var n,s,o;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){r.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(a){throw(n=this._authPromise)==null||n.reject(a),a}if(!this._needsAuth){(s=this._authPromise)==null||s.resolve();return}throw new y}throw(o=this._authPromise)==null||o.reject(i),i})}_exportPrivateKey(i,t){return h(this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:n,encoding:s}=this.getChainKeyParams();if(t!=null){let a=i.on("event:key-exported",d=>{i.off(a),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let o=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:s,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((o==null?void 0:o.status)==="error")throw r.error("export-signer: failed",{error:o.error,code:o.code}),new v(o.error||"Failed to export private key",o.code)})}};E([A({logger:r,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};export{m as a,l as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkATIC4ENGcjs = require('./chunk-ATIC4ENG.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkATIC4ENGcjs = require('./chunk-ATIC4ENG.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkILCNZB3Acjs = require('./chunk-ILCNZB3A.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var m=class{constructor(i){this.config=i;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;this._onboardingConnectionGeneration=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let i=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:i.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkILCNZB3Acjs.a.info("TEE connection not initialized, initializing now");let i=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new (0, _chunkATIC4ENGcjs.a)({environment:i.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkILCNZB3Acjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d;let i=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);_chunkILCNZB3Acjs.a.info("get-status: sending request");let t=Date.now(),e=yield i.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(d=this.config.crossmint.jwt)!=null?d:"",apiKey:this.config.crossmint.apiKey}},options:l}),n=Date.now()-t;if((e==null?void 0:e.status)!=="success"){let c=(e==null?void 0:e.status)==="error"&&e.error||"Failed to retrieve signer status",p=(e==null?void 0:e.status)==="error"?e.code:void 0;throw _chunkILCNZB3Acjs.a.error("get-status: failed",{status:e==null?void 0:e.status,error:(e==null?void 0:e.status)==="error"?e.error:void 0,code:p,durationMs:n}),new (0, _chunkQPCZFIUVcjs.c)(c,p)}if(_chunkILCNZB3Acjs.a.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:n}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkILCNZB3Acjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:s,resolve:o,reject:a}=this.createAuthPromise();if(this._authPromise={promise:s,resolve:o,reject:a},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkILCNZB3Acjs.a.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),c=>this.verifyOtp(c),()=>{var c;return(c=this._authPromise)==null?void 0:c.reject(new _chunkQPCZFIUVcjs.a)})),a(new _chunkQPCZFIUVcjs.a)}))}catch(c){_chunkILCNZB3Acjs.a.error("handleAuthRequired error",{error:c}),a(c)}try{yield s}catch(c){throw _chunkILCNZB3Acjs.a.error("handleAuthRequired promise error",{error:c}),c}})}ensureAuthenticated(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){this.config.resetSignerFrame!=null&&(yield this.config.resetSignerFrame()),yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null)throw new Error("JWT is required");return i}createAuthPromise(){let i,t;return{promise:new Promise((n,s)=>{i=n,t=s}),resolve:i,reject:t}}sendMessageWithOtp(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o;let i=yield this.getTEEConnection(),t=this.getAuthId();_chunkILCNZB3Acjs.a.info("start-onboarding: sending request");let e=Date.now(),n=yield i.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(o=this.config.crossmint.jwt)!=null?o:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:l}),s=Date.now()-e;if(this._onboardingConnectionGeneration=i.connectionGeneration,_chunkILCNZB3Acjs.a.info("start-onboarding: response received",{status:n==null?void 0:n.status,durationMs:s}),(n==null?void 0:n.status)==="success"&&n.signerStatus==="ready"){this._needsAuth=!1;return}if((n==null?void 0:n.status)==="error")throw _chunkILCNZB3Acjs.a.error("start-onboarding: failed",{error:n.error,code:n.code}),new (0, _chunkQPCZFIUVcjs.b)(n.error||"Failed to initiate OTP process.",n.code)})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var s,o;let t;try{let a=yield this.getTEEConnection();_chunkILCNZB3Acjs.a.info("complete-onboarding: sending request");let d=Date.now();t=yield a.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:i}}},options:l}),_chunkILCNZB3Acjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(a){return _chunkILCNZB3Acjs.a.error("complete-onboarding: error",{error:a}),yield this.handleOnboardingVerificationFailure(a)}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(),a=>this.verifyOtp(a),()=>{var a;return(a=this._authPromise)==null?void 0:a.reject(new _chunkQPCZFIUVcjs.a)})),(o=this._authPromise)==null||o.resolve();return}_chunkILCNZB3Acjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status,error:(t==null?void 0:t.status)==="error"?t.error:void 0,code:(t==null?void 0:t.status)==="error"?t.code:void 0});let e=(t==null?void 0:t.status)==="error"&&t.error||"Failed to validate encrypted OTP",n=(t==null?void 0:t.status)==="error"?t.code:void 0;return yield this.handleOnboardingVerificationFailure(new (0, _chunkQPCZFIUVcjs.b)(e,n))})}handleOnboardingVerificationFailure(i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var n,s,o;this._needsAuth=!0;let t=this.config.clientTEEConnection;if(this._onboardingConnectionGeneration!=null&&t!=null&&t.connectionGeneration!==this._onboardingConnectionGeneration){_chunkILCNZB3Acjs.a.warn("tee.signer.onboarding.reissued",{reason:"signer frame reloaded mid-onboarding, re-issuing OTP",onboardingGeneration:this._onboardingConnectionGeneration,currentGeneration:t==null?void 0:t.connectionGeneration});try{yield this.sendMessageWithOtp()}catch(a){throw(n=this._authPromise)==null||n.reject(a),a}if(!this._needsAuth){(s=this._authPromise)==null||s.resolve();return}throw new _chunkQPCZFIUVcjs.e}throw(o=this._authPromise)==null||o.reject(i),i})}_exportPrivateKey(i,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield this.ensureAuthenticated();let e=this.getJwtOrThrow(),{scheme:n,encoding:s}=this.getChainKeyParams();if(t!=null){let a=i.on("event:key-exported",d=>{i.off(a),d.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let o=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:e,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:s,walletAddress:this.config.address,authId:this.getAuthId()}},options:l});if((o==null?void 0:o.status)==="error")throw _chunkILCNZB3Acjs.a.error("export-signer: failed",{error:o.error,code:o.code}),new (0, _chunkQPCZFIUVcjs.d)(o.error||"Failed to export private key",o.code)})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkILCNZB3Acjs.a,methodName:"handleAuthRequired"})],m.prototype,"handleAuthRequired",1);var l={timeoutMs:3e4};exports.a = m; exports.b = l;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk23X5QOE6cjs = require('./chunk-23X5QOE6.cjs');var _chunkKZ62YXDQcjs = require('./chunk-KZ62YXDQ.cjs');var _chunkPZC2L2XZcjs = require('./chunk-PZC2L2XZ.cjs');var _chunkENU3EKBGcjs = require('./chunk-ENU3EKBG.cjs');var i={evm:_chunk23X5QOE6cjs.a,solana:_chunkKZ62YXDQcjs.a,stellar:_chunkPZC2L2XZcjs.a};function h(e){return i[_chunkENU3EKBGcjs.a.call(void 0, e)]}function g(e){return Object.prototype.hasOwnProperty.call(i,e)}exports.a = h; exports.b = g;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkLKYOZL7Ucjs = require('./chunk-LKYOZL7U.cjs');var _chunkGMU3ZYLScjs = require('./chunk-GMU3ZYLS.cjs');var _chunkEXOY4ZCVcjs = require('./chunk-EXOY4ZCV.cjs');var _chunkEUNVW5NMcjs = require('./chunk-EUNVW5NM.cjs');var _chunkQ66YRLSWcjs = require('./chunk-Q66YRLSW.cjs');var _chunkE7Z24LRScjs = require('./chunk-E7Z24LRS.cjs');var _chunkLHAOCUXTcjs = require('./chunk-LHAOCUXT.cjs');var _chunkILCNZB3Acjs = require('./chunk-ILCNZB3A.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var $="When 'signers' is provided to a method that may fetch an existing wallet, each specified signer must exist in that wallet's configuration.",u= exports.a =class{constructor(e){this.apiClient=e}getWallet(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r,i;if(typeof e=="string"){if(!this.apiClient.isServerSide)throw new (0, _chunkLHAOCUXTcjs.g)("getWallet with walletLocator is only available on the server side. Use getWallet(args) instead.");if(t==null)throw new (0, _chunkLHAOCUXTcjs.g)("Wallet configuration is required when using walletLocator: https://docs.crossmint.com/sdk-reference/wallets/type-aliases/WalletArgsFor");r=e,i=t}else{if(this.apiClient.isServerSide)throw new (0, _chunkLHAOCUXTcjs.g)("getWallet on server side requires a walletLocator parameter. Use getWallet(walletLocator, args) instead.");i=e,r=this.getWalletLocator(i)}let n=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},i),{chain:_chunkE7Z24LRScjs.f.call(void 0, i.chain,this.apiClient.environment)});_chunkILCNZB3Acjs.a.info("walletFactory.getWallet.start");let a=yield this.apiClient.getWallet(r);if("error"in a)throw _chunkILCNZB3Acjs.a.warn("walletFactory.getWallet.notFound",{error:a.error}),new (0, _chunkLHAOCUXTcjs.e)(JSON.stringify(a));return _chunkILCNZB3Acjs.a.info("walletFactory.getWallet.success",{address:a.address}),yield this.createWalletInstance(a,n)})}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o,c,p,h,y,R;let t=_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{chain:_chunkE7Z24LRScjs.f.call(void 0, e.chain,this.apiClient.environment)});if(yield(p=(c=(o=t.options)==null?void 0:o.callbacks)==null?void 0:c.onWalletCreationStart)==null?void 0:p.call(c),_chunkILCNZB3Acjs.a.info("walletFactory.createWallet.start"),!this.apiClient.isServerSide&&t.owner!=null)throw _chunkILCNZB3Acjs.a.error("walletFactory.createWallet.error",{error:"Owner field cannot be specified in client-side createWallet calls"}),new (0, _chunkLHAOCUXTcjs.g)("Owner field cannot be specified in client-side createWallet calls. Owner is determined from JWT authentication.");let r=(h=t.signers)!=null?h:[],i=((y=t.options)==null?void 0:y.deviceSignerKeyStorage)!=null&&!r.some(m=>m.type==="device"),n=i?[...r,{type:"device"}]:r,a=yield this.registerSigners(n,t.chain,(R=t.options)==null?void 0:R.deviceSignerKeyStorage),s;if(t.recovery.type==="passkey"&&t.recovery.id==null)s=yield this.createPasskeySigner(t.recovery);else if(t.recovery.type==="server"){let{derivedAddress:m}=_chunkQ66YRLSWcjs.b.call(void 0, t.recovery,t.chain,this.apiClient.projectId,this.apiClient.environment);s={type:"server",address:m}}else s=t.recovery;let l=yield this.createSmartWallet(t,s,a,i);if("error"in l)throw _chunkILCNZB3Acjs.a.error("walletFactory.createWallet.error",{error:l.error}),new (0, _chunkLHAOCUXTcjs.g)(JSON.stringify(l));return _chunkILCNZB3Acjs.a.info("walletFactory.createWallet.success",{address:l.address}),yield this.createWalletInstance(l,t)})}createSmartWallet(e,t,r,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=o=>{var c,p;return{type:"smart",chainType:this.getChainType(e.chain),config:_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {adminSigner:t},e.plugins?{plugins:e.plugins}:{}),o!=null?{delegatedSigners:o}:{}),owner:(c=e.owner)!=null?c:void 0,alias:(p=e.alias)!=null?p:void 0}},a=yield this.apiClient.createWallet(n(r));if(!(i&&"error"in a&&a.code===_chunkLHAOCUXTcjs.l))return a;_chunkILCNZB3Acjs.a.info("walletFactory.createWallet.deviceSignerUnsupported.retryWithoutDeviceSigner",{chain:e.chain});let l=r.filter(o=>!this.isBuiltDeviceSigner(o));return yield this.apiClient.createWallet(n(l))})}isBuiltDeviceSigner(e){let t=e.signer;return typeof t=="object"&&t!=null&&t.type==="device"}createWalletInstance(e,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var p,h;this.validateExistingWalletConfig(e,t);let r=t,i=e.config.adminSigner,n=((p=r.recovery)==null?void 0:p.type)==="server"||((h=r.recovery)==null?void 0:h.type)==="external-wallet"?r.recovery:i,a=e.config.delegatedSigners,s=a;s!=null&&s.length===1&&(s[0].type==="server"||s[0].type==="external-wallet")&&(s=r.signers);let l=i.type==="server"&&"address"in i&&!("secret"in i)?i.address:void 0,o=(a!=null?a:[]).filter(y=>y.type==="server"&&"address"in y&&!("secret"in y)).map(y=>y.address),c=new (0, _chunkLKYOZL7Ucjs.a)({chain:t.chain,address:e.address,owner:e.owner,options:t.options,alias:t.alias,recovery:n,apiRecoveryServerSignerAddress:l,apiDelegatedServerSignerAddresses:o,signers:s!=null?s:[]},this.apiClient);return yield c.waitForInit(),c})}getWalletLocator(e){return`me:${this.getChainType(e.chain)}:smart`+(e.alias!=null?`:alias:${e.alias}`:"")}createPasskeySigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;if(e.type!=="passkey")throw new Error("Signer is not a passkey");let t=(i=e.name)!=null?i:`Crossmint Wallet ${Date.now()}`,r=e.onCreatePasskey?yield e.onCreatePasskey(t):yield _ox.WebAuthnP256.createCredential({name:t});return{type:"passkey",id:r.id,name:t,publicKey:{x:r.publicKey.x.toString(),y:r.publicKey.y.toString()}}})}validateExistingWalletConfig(e,t){if(t.owner!=null&&e.owner!=null&&_chunkEUNVW5NMcjs.b.call(void 0, t.owner)!==_chunkEUNVW5NMcjs.b.call(void 0, e.owner))throw new (0, _chunkLHAOCUXTcjs.g)("Wallet owner does not match existing wallet's linked user");if(t.chain==="solana"&&e.chainType!=="solana"||t.chain!=="solana"&&e.chainType==="solana"||t.chain==="stellar"&&e.chainType!=="stellar"||t.chain!=="stellar"&&e.chainType==="stellar")throw new (0, _chunkLHAOCUXTcjs.g)(`Wallet chain does not match existing wallet's chain. You must use chain: ${e.chainType}.`);if(e.type!=="smart")return;let r=t;if(r.recovery!=null||r.signers!=null){let i=e.config,n=i==null?void 0:i.adminSigner;if(r.recovery!=null&&n!=null){if(r.recovery.type!==n.type)throw new (0, _chunkLHAOCUXTcjs.g)("The wallet recovery signer type does not match the existing wallet's recovery signer type");_chunkEUNVW5NMcjs.c.call(void 0, r.recovery,n)}let a=r.signers;a!=null&&this.validateSigners(e,a,t.chain)}}validateSigners(e,t,r){let i=e.config,n=i==null?void 0:i.delegatedSigners;if(t.length!==0){if(n==null||n.length===0)throw new (0, _chunkLHAOCUXTcjs.g)(`${t.length} signer(s) specified, but wallet "${e.address}" has no signers. ${$}`);for(let a of t){let s=n.find(l=>{if(this.isMatchingPasskeySigner(a,l,i)||l.type==="device"&&a.type==="device")return!0;if(a.type==="server"){let{primary:o,legacy:c}=_chunkQ66YRLSWcjs.c.call(void 0, a,r,this.apiClient.projectId,this.apiClient.environment);return l.locator===`server:${o.derivedAddress}`||c!=null&&l.locator===`server:${c.derivedAddress}`}return l.locator===_chunkEXOY4ZCVcjs.a.call(void 0, a)});if(s==null){let l=n.map(o=>o.locator).join(", ");throw new (0, _chunkLHAOCUXTcjs.g)(`Signer '${a.type}' does not exist in wallet "${e.address}". Available signers: ${l}. ${$}`)}_chunkEUNVW5NMcjs.c.call(void 0, a,s)}}}isMatchingPasskeySigner(e,t,r){var n,a;let i=((a=(n=r.delegatedSigners)==null?void 0:n.filter(s=>s.type==="passkey").length)!=null?a:0)+(r.adminSigner.type==="passkey"?1:0);if(e.type==="passkey"){if(e.id==null&&i===1)return t.type==="passkey";if(e.id==null&&i>1)throw new (0, _chunkLHAOCUXTcjs.g)("When creating a wallet with multiple passkeys, you must provide the passkey ID for each passkey.")}return!1}registerSigners(e,t,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var i;return yield Promise.all((i=e==null?void 0:e.map(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(n.type==="passkey")return n.id==null?{signer:yield this.createPasskeySigner(n)}:{signer:n};if(n.type==="device"){if(n.publicKey!=null)return{signer:{type:"device",publicKey:n.publicKey,name:n.name}};if(n.locator!=null)return{signer:n.locator};if(r==null)throw new (0, _chunkLHAOCUXTcjs.g)("Device signer key storage is required for device signers");let a=yield _chunkGMU3ZYLScjs.a.call(void 0, r);return{signer:{type:"device",publicKey:a.publicKey,name:a.name}}}if(n.type==="server"&&t!=null){let{derivedAddress:a}=_chunkQ66YRLSWcjs.b.call(void 0, n,t,this.apiClient.projectId,this.apiClient.environment);return{signer:`server:${a}`}}return{signer:_chunkEXOY4ZCVcjs.a.call(void 0, n)}})))!=null?i:[])})}getChainType(e){return e==="solana"?"solana":e==="stellar"?"stellar":"evm"}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkILCNZB3Acjs.a,methodName:"walletFactory.getWallet",buildContext(e,t){if(typeof t[0]=="string"){let i=t[1];return{walletLocator:t[0],chain:i==null?void 0:i.chain}}let r=t[0];return{chain:r==null?void 0:r.chain}}})],u.prototype,"getWallet",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkILCNZB3Acjs.a,methodName:"walletFactory.createWallet",buildContext(e,t){return{chain:t[0].chain}}})],u.prototype,"createWallet",1);exports.a = u;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
1
|
+
import{a as n}from"./chunk-PJKTUGX2.js";var s={type:"email",validateConfig(e){if(!("email"in e)||e.email==null)throw new Error("Email signer requires an email address")},buildInternalConfig(e,i){let r=e,o=n(e);return{type:"email",email:r.email,locator:o,address:i.walletAddress,crossmint:i.crossmint,clientTEEConnection:i.clientTEEConnection,resetSignerFrame:i.resetSignerFrame,onAuthRequired:i.onAuthRequired}},canAutoAssemble(){return!0},addSignerPayload(e){return n(e)},matchesRecovery(e,i){return n(e)===n(i)},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>null};export{s as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkLHAOCUXTcjs = require('./chunk-LHAOCUXT.cjs');var _chunkILCNZB3Acjs = require('./chunk-ILCNZB3A.cjs');var _chunkJ5W5S2WGcjs = require('./chunk-J5W5S2WG.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var h=class extends _commonsdkbase.CrossmintApiClient{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:_chunkJ5W5S2WGcjs.c,version:_chunkJ5W5S2WGcjs.b}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;_chunkILCNZB3Acjs.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?_chunkILCNZB3Acjs.a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&_chunkILCNZB3Acjs.a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkILCNZB3Acjs.a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?_chunkILCNZB3Acjs.a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&_chunkILCNZB3Acjs.a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.json()})}getSignature(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(this.environment===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkILCNZB3Acjs.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?_chunkILCNZB3Acjs.a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&_chunkILCNZB3Acjs.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, _chunkLHAOCUXTcjs.a)("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new (0, _chunkLHAOCUXTcjs.a)("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};exports.a = h;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
2
|
-
Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`,l= exports.b ={type:"external-wallet",validateConfig(e){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")},buildInternalConfig(e){let n=e;return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},n),{locator:`external-wallet:${n.address}`})},canAutoAssemble(e){return"onSign"in e&&typeof e.onSign=="function"},addSignerPayload(e){return
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkEXOY4ZCVcjs = require('./chunk-EXOY4ZCV.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var o=`No signer is set. External wallet signers require calling wallet.useSigner() with the onSign callback before signing operations.
|
|
2
|
+
Example: wallet.useSigner({ type: "external-wallet", address: "0x...", onSign: async (tx) => ... })`,l= exports.b ={type:"external-wallet",validateConfig(e){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")},buildInternalConfig(e){let n=e;return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},n),{locator:`external-wallet:${n.address}`})},canAutoAssemble(e){return"onSign"in e&&typeof e.onSign=="function"},addSignerPayload(e){return _chunkEXOY4ZCVcjs.a.call(void 0, e)},matchesRecovery(e,n){return _chunkEXOY4ZCVcjs.a.call(void 0, e)===_chunkEXOY4ZCVcjs.a.call(void 0, n)},adoptsRecoveryConfigOnMatch:!0,signerUnavailableReason:()=>o};exports.a = o; exports.b = l;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as P}from"./chunk-NZXYWQE5.js";import{a as v}from"./chunk-IOSADDL5.js";import{n as w}from"./chunk-
|
|
1
|
+
import{a as P}from"./chunk-NZXYWQE5.js";import{a as v}from"./chunk-IOSADDL5.js";import{n as w}from"./chunk-SLPKMZNW.js";import{a as l}from"./chunk-HXN3ZART.js";import{c as m,h as n}from"./chunk-NU7VF7MC.js";import{getEnvironmentForKey as K,APIKeyEnvironmentPrefix as h,WithLoggerContext as u}from"@crossmint/common-sdk-base";import{WebAuthnP256 as b}from"ox";var R={[h.DEVELOPMENT]:"https://development.devicekey.store",[h.STAGING]:"https://staging.devicekey.store",[h.PRODUCTION]:"https://devicekey.store"},E=6e4,L="indexeddb-fatal",c=class extends v{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;if(typeof window!="undefined"&&!P())throw new w("Device signer requires a browser with third-party storage partitioning (Chrome \u2265 115, Firefox \u2265 103, or Safari). Without storage partitioning, different embedders of the same iframe can share IndexedDB, allowing cross-site key access. See https://developer.chrome.com/blog/storage-partitioning");let r=K(e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=R[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return n(this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return n(this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return n(this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return n(this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return n(this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return n(this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return n(this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){l.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return n(this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${E}ms`))},E);function p(y){let d=y.data;d==null||d.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),d.type==="error"&&d.code===L?s({fatal:!0}):d.type==="error"?o(new Error(d.error)):s({value:d.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return n(this,null,function*(){if(this.reloading!=null)return this.reloading;let e=n(this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>n(this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield b.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield b.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};m([u({logger:l,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),m([u({logger:l,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);export{c as a};
|