@crossmint/wallets-sdk 1.1.1 → 1.1.2
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__/constants.d.cts +1 -1
- package/dist/api/__tests__/constants.d.ts +1 -1
- package/dist/api/__tests__/test-utils.cjs +1 -1
- package/dist/api/__tests__/test-utils.d.cts +1 -1
- package/dist/api/__tests__/test-utils.d.ts +1 -1
- package/dist/api/__tests__/test-utils.js +1 -1
- package/dist/api/client.cjs +1 -1
- package/dist/api/client.d.cts +1 -1
- package/dist/api/client.d.ts +1 -1
- package/dist/api/client.js +1 -1
- package/dist/api/index.cjs +1 -1
- package/dist/api/index.d.cts +1 -1
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +1 -1
- package/dist/api/types.d.cts +1 -1
- package/dist/api/types.d.ts +1 -1
- package/dist/chains/chains.cjs +1 -1
- package/dist/chains/chains.js +1 -1
- package/dist/{chunk-A3CW6G3D.cjs → chunk-2B2VKXMR.cjs} +1 -1
- package/dist/{chunk-T6EM7RKO.cjs → chunk-2R7ORD74.cjs} +1 -1
- package/dist/{chunk-RBSMBO4T.js → chunk-2UQ3HUS6.js} +1 -1
- package/dist/{chunk-MG4Y6I7Q.js → chunk-4LWG7FIM.js} +1 -1
- package/dist/{chunk-RQYFBGQD.cjs → chunk-4O34QU74.cjs} +1 -1
- package/dist/{chunk-QO6YNC6N.js → chunk-BMLREMLL.js} +1 -1
- package/dist/{chunk-2O4UWD4Z.cjs → chunk-CCAPUWFB.cjs} +1 -1
- package/dist/{chunk-RSQAX3JE.cjs → chunk-F2TXDKPB.cjs} +1 -1
- package/dist/{chunk-LKL6NBJS.js → chunk-FFOVF23E.js} +1 -1
- package/dist/{chunk-76F327NK.cjs → chunk-FMWVS32K.cjs} +1 -1
- package/dist/{chunk-5FVPLT56.cjs → chunk-GDRSDCM6.cjs} +2 -2
- package/dist/{chunk-3VSFHDFH.cjs → chunk-GQHU6TH5.cjs} +1 -1
- package/dist/{chunk-TXJ4LU5K.cjs → chunk-IMTOUORZ.cjs} +1 -1
- package/dist/{chunk-QDXLE57M.js → chunk-JHE6LNLM.js} +1 -1
- package/dist/{chunk-7V7Y2XDA.js → chunk-K2OP3UKD.js} +2 -2
- package/dist/{chunk-QPDUUKN6.js → chunk-KOO4IQ3M.js} +1 -1
- package/dist/{chunk-Z3FS2L3S.cjs → chunk-KPB77YNY.cjs} +1 -1
- package/dist/{chunk-2PRGSMTK.js → chunk-KVTLS4H7.js} +1 -1
- package/dist/{chunk-OXYFXOPU.js → chunk-LBKX6JJV.js} +1 -1
- package/dist/chunk-LGDJURYY.js +1 -0
- package/dist/{chunk-A66TOJYU.cjs → chunk-LITEQGNE.cjs} +1 -1
- package/dist/{chunk-DE5B5PD6.js → chunk-MVT4TQPN.js} +1 -1
- package/dist/chunk-P2IW4ZL6.cjs +1 -0
- package/dist/{chunk-DYQSARFM.js → chunk-PE2ZTLGK.js} +1 -1
- package/dist/{chunk-JUNCHOU4.js → chunk-PR2M7QAF.js} +1 -1
- package/dist/{chunk-VGJF6V2I.cjs → chunk-PT356WGC.cjs} +1 -1
- package/dist/{chunk-RLD3OL3C.cjs → chunk-RMKQ35ZD.cjs} +1 -1
- package/dist/chunk-RTS4N5HQ.js +1 -0
- package/dist/{chunk-PMBSFTVS.cjs → chunk-SRPDUX6H.cjs} +1 -1
- package/dist/{chunk-KISYLMOO.js → chunk-TTT6T3VE.js} +1 -1
- package/dist/{chunk-KB3MJ6GT.js → chunk-TYVOOI35.js} +1 -1
- package/dist/{chunk-H5ZYPLFV.js → chunk-VU63FANF.js} +1 -1
- package/dist/{chunk-2SRITPJI.cjs → chunk-X2FNNYCG.cjs} +1 -1
- package/dist/{chunk-WJ3VUMAW.cjs → chunk-YL6OIWBR.cjs} +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -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 -1
- package/dist/sdk.d.ts +1 -1
- package/dist/sdk.js +1 -1
- package/dist/signers/device.d.cts +1 -1
- package/dist/signers/device.d.ts +1 -1
- package/dist/signers/evm-api-key.d.cts +1 -1
- package/dist/signers/evm-api-key.d.ts +1 -1
- package/dist/signers/evm-external-wallet.d.cts +1 -1
- package/dist/signers/evm-external-wallet.d.ts +1 -1
- package/dist/signers/external-wallet-signer.d.cts +1 -1
- package/dist/signers/external-wallet-signer.d.ts +1 -1
- package/dist/signers/index.cjs +1 -1
- package/dist/signers/index.d.cts +1 -1
- package/dist/signers/index.d.ts +1 -1
- package/dist/signers/index.js +1 -1
- package/dist/signers/non-custodial/index.cjs +1 -1
- package/dist/signers/non-custodial/index.d.cts +1 -1
- package/dist/signers/non-custodial/index.d.ts +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.d.cts +1 -1
- package/dist/signers/non-custodial/ncs-evm-signer.d.ts +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.d.cts +1 -1
- package/dist/signers/non-custodial/ncs-signer.d.ts +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.d.cts +1 -1
- package/dist/signers/non-custodial/ncs-solana-signer.d.ts +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.d.cts +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.d.ts +1 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.js +1 -1
- package/dist/signers/passkey.d.cts +1 -1
- package/dist/signers/passkey.d.ts +1 -1
- package/dist/signers/server/assemble-server-signer.cjs +1 -1
- package/dist/signers/server/assemble-server-signer.d.cts +1 -1
- package/dist/signers/server/assemble-server-signer.d.ts +1 -1
- package/dist/signers/server/assemble-server-signer.js +1 -1
- package/dist/signers/server/evm-server-signer.d.cts +1 -1
- package/dist/signers/server/evm-server-signer.d.ts +1 -1
- package/dist/signers/server/helpers/derive-server-signer.cjs +1 -1
- package/dist/signers/server/helpers/derive-server-signer.d.cts +1 -1
- package/dist/signers/server/helpers/derive-server-signer.d.ts +1 -1
- package/dist/signers/server/helpers/derive-server-signer.js +1 -1
- package/dist/signers/server/helpers/index.cjs +1 -1
- package/dist/signers/server/helpers/index.d.cts +1 -1
- package/dist/signers/server/helpers/index.d.ts +1 -1
- package/dist/signers/server/helpers/index.js +1 -1
- package/dist/signers/server/index.cjs +1 -1
- package/dist/signers/server/index.d.cts +1 -1
- package/dist/signers/server/index.d.ts +1 -1
- package/dist/signers/server/index.js +1 -1
- package/dist/signers/server/solana-server-signer.d.cts +1 -1
- package/dist/signers/server/solana-server-signer.d.ts +1 -1
- package/dist/signers/server/stellar-server-signer.d.cts +1 -1
- package/dist/signers/server/stellar-server-signer.d.ts +1 -1
- package/dist/signers/solana-api-key.d.cts +1 -1
- package/dist/signers/solana-api-key.d.ts +1 -1
- package/dist/signers/solana-external-wallet.d.cts +1 -1
- package/dist/signers/solana-external-wallet.d.ts +1 -1
- package/dist/signers/stellar-external-wallet.d.cts +1 -1
- package/dist/signers/stellar-external-wallet.d.ts +1 -1
- package/dist/signers/types.d.cts +1 -1
- package/dist/signers/types.d.ts +1 -1
- package/dist/{types-DZWn68Po.d.cts → types-Nc5kinaI.d.cts} +1 -1
- package/dist/{types-CtOIG5sn.d.ts → types-NmTwqiYW.d.ts} +1 -1
- package/dist/utils/constants.cjs +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/createDeviceSigner.d.cts +1 -1
- package/dist/utils/device-signers/createDeviceSigner.d.ts +1 -1
- package/dist/utils/device-signers/index.cjs +1 -1
- package/dist/utils/device-signers/index.d.cts +1 -1
- package/dist/utils/device-signers/index.d.ts +1 -1
- package/dist/utils/device-signers/index.js +1 -1
- package/dist/utils/signer-locator.d.cts +1 -1
- package/dist/utils/signer-locator.d.ts +1 -1
- package/dist/utils/signer-mapping.d.cts +1 -1
- package/dist/utils/signer-mapping.d.ts +1 -1
- package/dist/wallets/__tests__/test-helpers.cjs +1 -1
- package/dist/wallets/__tests__/test-helpers.d.cts +1 -1
- package/dist/wallets/__tests__/test-helpers.d.ts +1 -1
- package/dist/wallets/__tests__/test-helpers.js +1 -1
- package/dist/wallets/evm.cjs +1 -1
- package/dist/wallets/evm.d.cts +1 -1
- package/dist/wallets/evm.d.ts +1 -1
- package/dist/wallets/evm.js +1 -1
- package/dist/wallets/solana.cjs +1 -1
- package/dist/wallets/solana.d.cts +1 -1
- package/dist/wallets/solana.d.ts +1 -1
- package/dist/wallets/solana.js +1 -1
- package/dist/wallets/stellar.cjs +1 -1
- package/dist/wallets/stellar.d.cts +1 -1
- package/dist/wallets/stellar.d.ts +1 -1
- package/dist/wallets/stellar.js +1 -1
- package/dist/wallets/types.d.cts +1 -1
- package/dist/wallets/types.d.ts +1 -1
- package/dist/wallets/wallet-factory.cjs +1 -1
- package/dist/wallets/wallet-factory.d.cts +1 -1
- package/dist/wallets/wallet-factory.d.ts +1 -1
- package/dist/wallets/wallet-factory.js +1 -1
- package/dist/wallets/wallet.cjs +1 -1
- package/dist/wallets/wallet.d.cts +1 -1
- package/dist/wallets/wallet.d.ts +1 -1
- package/dist/wallets/wallet.js +1 -1
- package/package.json +4 -4
- package/dist/chunk-JUUK4TW3.cjs +0 -1
- package/dist/chunk-XWFHS6TV.js +0 -1
- package/dist/chunk-ZLOXOCRY.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 _chunkP2IW4ZL6cjs = require('../../chunk-P2IW4ZL6.cjs');require('../../chunk-T3U46LK3.cjs');require('../../chunk-CCAPUWFB.cjs');require('../../chunk-X2FNNYCG.cjs');var _chunk2GKPWQBQcjs = require('../../chunk-2GKPWQBQ.cjs');var _vitest = require('vitest');var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:_vitest.vi.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j= exports.createMockSuccessResponse =e=>P({data:e}),b= exports.createMockErrorResponse =(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B= exports.createMockCrossmint =(e={})=>{let t=_chunk2GKPWQBQcjs.a.call(void 0, {apiKey:_chunkJ33QM2IDcjs.m},e);return _chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},t),{setJwt:_vitest.vi.fn().mockReturnThis()})},L= exports.createTestApiClient =e=>new (0, _chunkP2IW4ZL6cjs.a)(e||B()),K= exports.createServerSideApiClient =()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},Y= exports.extractFetchCall =e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N= exports.expectRequestPath =(e,t)=>{_vitest.expect.call(void 0, e==null?void 0:e.path).toBe(t)},V= exports.expectCommonHeaders =e=>{_vitest.expect.call(void 0, e["Content-Type"]).toBe("application/json")},q= exports.expectRequestBody =(e,t)=>{_vitest.expect.call(void 0, e.body).toBe(JSON.stringify(t))},z= exports.validateRequest =(e,t,n)=>{_vitest.expect.call(void 0, e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},X= exports.testHttpErrorResponse =(e,t,n,s)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();_vitest.expect.call(void 0, l(a)).toBe(!0),l(a)&&(_vitest.expect.call(void 0, a.error).toBe(!0),n.message&&_vitest.expect.call(void 0, a.message).toBe(n.message))}),Z= exports.testCommonHttpErrors =(s,a,...o)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of _chunkJ33QM2IDcjs.a){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();_vitest.expect.call(void 0, l(m)).toBe(!0)}}),Q= exports.testNetworkError =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Network error")}),ee= exports.testInvalidJsonResponse =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let n={json:_vitest.vi.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield _vitest.expect.call(void 0, e()).rejects.toThrow()}),te= exports.testTimeoutError =(e,t)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield _vitest.expect.call(void 0, e()).rejects.toThrow("Request timeout")}),ne= exports.testMalformedResponse =(e,t,n)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();_vitest.expect.call(void 0, s).toEqual(n)}),se= exports.createMockWalletResponse =(e={})=>_chunk2GKPWQBQcjs.a.call(void 0, {address:_chunkJ33QM2IDcjs.b.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:_chunkJ33QM2IDcjs.k.EVM_TEST}}},e),oe= exports.createMockSendResponse =(e={})=>_chunk2GKPWQBQcjs.a.call(void 0, {id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),re= exports.isValidEthereumAddress =e=>/^0x[a-fA-F0-9]{40}$/.test(e),ae= exports.isValidSolanaAddress =e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ie= exports.createIntegrationApiClient =(e,t,n={})=>{let s=_chunk2GKPWQBQcjs.a.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {apiKey:e},t&&{overrideBaseUrl:t}),n),a=_chunk2GKPWQBQcjs.b.call(void 0, _chunk2GKPWQBQcjs.a.call(void 0, {},s),{setJwt:()=>a});return new (0, _chunkP2IW4ZL6cjs.a)(a)},v= exports.TestDataFactory =class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function ce(s,a){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(_chunk2GKPWQBQcjs.a.call(void 0, {chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function pe(e,t,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function le(e,t){_vitest.expect.call(void 0, l(e)).toBe(!0),t&&_vitest.expect.call(void 0, e.message).toBeDefined()}function ue(e){_vitest.expect.call(void 0, C(e)).toBe(!0)}function de(e){_vitest.expect.call(void 0, $(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(_chunkJ33QM2IDcjs.i),c}),U= exports.approveTransaction =(a,o,c,...g)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,[a,o,c,...g],function*(e,t,n,s=_chunkJ33QM2IDcjs.l.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(_chunkJ33QM2IDcjs.j);continue}yield x(_chunkJ33QM2IDcjs.i)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),me= exports.fundWalletAndWait =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){return I(e,t,n,s,a)}),fe= exports.sendTokenAndApprove =(e,t,n,s,a)=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),ge= exports.ensureWalletFunded =(e,t,n=1,s="usdxm",a="base-sepolia")=>_chunk2GKPWQBQcjs.g.call(void 0, void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});exports.TestDataFactory = v; exports.approveTransaction = U; exports.createIntegrationApiClient = ie; exports.createMockCrossmint = B; exports.createMockErrorResponse = b; exports.createMockResponse = P; exports.createMockSendResponse = oe; exports.createMockSuccessResponse = j; exports.createMockWalletResponse = se; exports.createServerSideApiClient = K; exports.createTestApiClient = L; exports.createTestWallet = pe; exports.delay = x; exports.ensureWalletExists = ce; exports.ensureWalletFunded = ge; exports.expectCommonHeaders = V; exports.expectErrorResponse = le; exports.expectRequestBody = q; exports.expectRequestPath = N; exports.expectSuccessTransactionResponse = de; exports.expectSuccessWalletResponse = ue; exports.extractFetchCall = Y; exports.fundWallet = I; exports.fundWalletAndWait = me; exports.isErrorResponse = l; exports.isSuccessTransactionResponse = $; exports.isSuccessWalletResponse = C; exports.isValidEthereumAddress = re; exports.isValidSolanaAddress = ae; exports.sendTokenAndApprove = fe; exports.testCommonHttpErrors = Z; exports.testHttpErrorResponse = X; exports.testInvalidJsonResponse = ee; exports.testMalformedResponse = ne; exports.testNetworkError = Q; exports.testTimeoutError = te; exports.validateRequest = z;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MockedFunction } from 'vitest';
|
|
2
2
|
import { Crossmint } from '@crossmint/common-sdk-base';
|
|
3
3
|
import { ApiClient } from '../client.cjs';
|
|
4
|
-
import { a8 as WalletLocator, aa as GetTransactionResponse, ab as SendResponse, ac as CreateWalletResponse, ad as CreateWalletParams, a0 as FundWalletResponse } from '../../types-
|
|
4
|
+
import { a8 as WalletLocator, aa as GetTransactionResponse, ab as SendResponse, ac as CreateWalletResponse, ad as CreateWalletParams, a0 as FundWalletResponse } from '../../types-Nc5kinaI.cjs';
|
|
5
5
|
import '../../chains/chains.cjs';
|
|
6
6
|
import 'viem';
|
|
7
7
|
import '../gen/types.gen.cjs';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { MockedFunction } from 'vitest';
|
|
2
2
|
import { Crossmint } from '@crossmint/common-sdk-base';
|
|
3
3
|
import { ApiClient } from '../client.js';
|
|
4
|
-
import { a8 as WalletLocator, aa as GetTransactionResponse, ab as SendResponse, ac as CreateWalletResponse, ad as CreateWalletParams, a0 as FundWalletResponse } from '../../types-
|
|
4
|
+
import { a8 as WalletLocator, aa as GetTransactionResponse, ab as SendResponse, ac as CreateWalletResponse, ad as CreateWalletParams, a0 as FundWalletResponse } from '../../types-NmTwqiYW.js';
|
|
5
5
|
import '../../chains/chains.js';
|
|
6
6
|
import 'viem';
|
|
7
7
|
import '../gen/types.gen.js';
|
|
@@ -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-LGDJURYY.js";import"../../chunk-EXC7TCGL.js";import"../../chunk-TTT6T3VE.js";import"../../chunk-RTS4N5HQ.js";import{a as p,b as k,g as i}from"../../chunk-J3R36SGJ.js";import{expect as r,vi as y}from"vitest";var P=({data:e,status:t=200,ok:n=!0,statusText:s="OK"})=>({json:y.fn().mockResolvedValue(e),ok:n,status:t,statusText:s}),j=e=>P({data:e}),b=(e,t=400,n="Bad Request")=>P({data:e,status:t,ok:!1,statusText:n}),B=(e={})=>{let t=p({apiKey:S},e);return k(p({},t),{setJwt:y.fn().mockReturnThis()})},L=e=>new w(e||B()),Y=()=>{let e=L();return Object.defineProperty(e,"isServerSide",{get:()=>!0,configurable:!0}),e},z=e=>{let t=e.mock.calls;if(t.length===0)return;let n=t[t.length-1];return{path:n[0],options:n[1]}},N=(e,t)=>{r(e==null?void 0:e.path).toBe(t)},V=e=>{r(e["Content-Type"]).toBe("application/json")},q=(e,t)=>{r(e.body).toBe(JSON.stringify(t))},X=(e,t,n)=>{r(e).toBeDefined(),e&&(N(e,t),e.options.headers&&V(e.options.headers),n!==void 0&&e.options&&q(e.options,n))},Z=(e,t,n,s)=>i(void 0,null,function*(){t.mockResolvedValue(b(n,s));let a=yield e();r(l(a)).toBe(!0),l(a)&&(r(a.error).toBe(!0),n.message&&r(a.message).toBe(n.message))}),Q=(s,a,...o)=>i(void 0,[s,a,...o],function*(e,t,n=[]){for(let{status:c,message:g}of A){if(n.includes(c))continue;let u={error:!0,message:g};t.mockResolvedValueOnce(b(u,c));let m=yield e();r(l(m)).toBe(!0)}}),ee=(e,t)=>i(void 0,null,function*(){t.mockRejectedValue(new Error("Network error")),yield r(e()).rejects.toThrow("Network error")}),te=(e,t)=>i(void 0,null,function*(){let n={json:y.fn().mockRejectedValue(new Error("Invalid JSON")),ok:!0,status:200};t.mockResolvedValue(n),yield r(e()).rejects.toThrow()}),ne=(e,t)=>i(void 0,null,function*(){t.mockImplementation(()=>new Promise((n,s)=>setTimeout(()=>s(new Error("Request timeout")),0))),yield r(e()).rejects.toThrow("Request timeout")}),se=(e,t,n)=>i(void 0,null,function*(){t.mockResolvedValue(j(n));let s=yield e();r(s).toEqual(n)}),oe=(e={})=>p({address:F.evmAddress,chainType:"evm",type:"smart",config:{adminSigner:{type:"external-wallet",address:E.EVM_TEST}}},e),re=(e={})=>p({id:"txn-123",status:"pending",chainType:"evm",walletType:"evm-smart-wallet",params:{transaction:"0x1234567890abcdef",signer:"api-key:test"},onChain:{txId:"0xabcdef1234567890abcdef1234567890abcdef12",explorerLink:"https://explorer.example.com/tx/0xabcdef1234567890abcdef1234567890abcdef12"},createdAt:Date.now()},e);function l(e){return typeof e=="object"&&e!==null&&"error"in e&&e.error===!0}function C(e){return typeof e=="object"&&e!==null&&"address"in e&&"chainType"in e&&"type"in e}function $(e){return typeof e=="object"&&e!==null&&"id"in e&&"status"in e&&"chainType"in e}var x=e=>new Promise(t=>setTimeout(t,e)),ae=e=>/^0x[a-fA-F0-9]{40}$/.test(e),ie=e=>/^[1-9A-HJ-NP-Za-km-z]{32,44}$/.test(e),ce=(e,t,n={})=>{let s=p(p({apiKey:e},t&&{overrideBaseUrl:t}),n),a=k(p({},s),{setJwt:()=>a});return new w(a)},v=class{constructor(){this.wallets=[];this.transactions=[]}addWallet(t){t&&!this.wallets.includes(t)&&this.wallets.push(t)}addTransaction(t){t&&!this.transactions.includes(t)&&this.transactions.push(t)}getWallet(t=0){return this.wallets[t]}getTransaction(t=0){return this.transactions[t]}hasWallets(){return this.wallets.length>0}clear(){this.wallets=[],this.transactions=[]}};function pe(s,a){return i(this,arguments,function*(e,t,n={}){if(t.hasWallets())return t.getWallet();let{chainType:o="evm",type:c="mpc",owner:g,testName:u="default"}=n,m=g||`userId:integration-${u}-${Date.now()}`,f=yield e.createWallet(p({chainType:o,type:c},g&&{owner:m}));if(C(f))return t.addWallet(f.address),f.address})}function le(e,t,n){return i(this,null,function*(){let s=yield e.createWallet(n);return C(s)&&t.addWallet(s.address),s})}function ue(e,t){r(l(e)).toBe(!0),t&&r(e.message).toBeDefined()}function de(e){r(C(e)).toBe(!0)}function me(e){r($(e)).toBe(!0)}var I=(e,t,n,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){let o={amount:n,token:s,chain:a},c=yield e.fundWallet(t,o);if(l(c))throw new Error(`Failed to fund wallet: ${c.message||"Unknown error"}`);return yield x(R),c}),U=(a,o,c,...g)=>i(void 0,[a,o,c,...g],function*(e,t,n,s=M.APPROVE_TRANSACTION_MAX_RETRIES){var m;for(let f=0;f<s;f++){let d=yield e.getTransaction(t,n);if(l(d))throw new Error(`Transaction not found: ${d.message||"Unknown error"}`);if("status"in d&&(d.status==="success"||d.status==="failed"))return d;let T="approvals"in d?(m=d.approvals)==null?void 0:m.pending:void 0;if(T&&T.length>0){let O={approvals:T.map(_=>({signer:_.signer.locator,signature:""}))},h=yield e.approveTransaction(t,n,O);if(l(h))throw new Error(`Failed to approve transaction: ${h.message||"Unknown error"}`);yield x(W);continue}yield x(R)}let u=yield e.getTransaction(t,n);if(l(u))throw new Error(`Transaction not found after retries: ${u.message||"Unknown error"}`);if(!("status"in u))throw new Error("Transaction response missing status property");return u}),fe=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){return I(e,t,n,s,a)}),ge=(e,t,n,s,a)=>i(void 0,null,function*(){let o=yield e.send(t,n,{recipient:s,amount:a});if(l(o))throw new Error(`Failed to send token: ${o.message||"Unknown error"}`);if(typeof o=="object"&&o!==null&&"id"in o&&typeof o.id=="string")return U(e,t,o.id);throw new Error("Transaction ID not found in send response")}),Te=(e,t,n=1,s="usdxm",a="base-sepolia")=>i(void 0,null,function*(){try{yield I(e,t,n,s,a)}catch(o){let c=o instanceof Error?o.message:String(o);if(!c.includes("already funded")&&!c.includes("insufficient"))throw o}});export{v as TestDataFactory,U as approveTransaction,ce as createIntegrationApiClient,B as createMockCrossmint,b as createMockErrorResponse,P as createMockResponse,re as createMockSendResponse,j as createMockSuccessResponse,oe as createMockWalletResponse,Y as createServerSideApiClient,L as createTestApiClient,le as createTestWallet,x as delay,pe as ensureWalletExists,Te as ensureWalletFunded,V as expectCommonHeaders,ue as expectErrorResponse,q as expectRequestBody,N as expectRequestPath,me as expectSuccessTransactionResponse,de as expectSuccessWalletResponse,z as extractFetchCall,I as fundWallet,fe as fundWalletAndWait,l as isErrorResponse,$ as isSuccessTransactionResponse,C as isSuccessWalletResponse,ae as isValidEthereumAddress,ie as isValidSolanaAddress,ge as sendTokenAndApprove,Q as testCommonHttpErrors,Z as testHttpErrorResponse,te as testInvalidJsonResponse,se as testMalformedResponse,ee as testNetworkError,ne as testTimeoutError,X as validateRequest};
|
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 _chunkP2IW4ZL6cjs = require('../chunk-P2IW4ZL6.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CCAPUWFB.cjs');require('../chunk-X2FNNYCG.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkP2IW4ZL6cjs.a;
|
package/dist/api/client.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CrossmintApiClient, Crossmint, APIKeyEnvironmentPrefix } from '@crossmint/common-sdk-base';
|
|
2
|
-
import { ad as CreateWalletParams, ac as CreateWalletResponse, a8 as WalletLocator, ai as GetWalletResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, aa as GetTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, aq as GetSignatureResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, as as GetBalanceResponse, at as FundWalletParams, a0 as FundWalletResponse, au as RegisterSignerParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, ay as GetSignerResponse, az as SendParams, ab as SendResponse } from '../types-
|
|
2
|
+
import { ad as CreateWalletParams, ac as CreateWalletResponse, a8 as WalletLocator, ai as GetWalletResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, aa as GetTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, aq as GetSignatureResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, as as GetBalanceResponse, at as FundWalletParams, a0 as FundWalletResponse, au as RegisterSignerParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, ay as GetSignerResponse, az as SendParams, ab as SendResponse } from '../types-Nc5kinaI.cjs';
|
|
3
3
|
import { Chain } from '../chains/chains.cjs';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import './gen/types.gen.cjs';
|
package/dist/api/client.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { CrossmintApiClient, Crossmint, APIKeyEnvironmentPrefix } from '@crossmint/common-sdk-base';
|
|
2
|
-
import { ad as CreateWalletParams, ac as CreateWalletResponse, a8 as WalletLocator, ai as GetWalletResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, aa as GetTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, aq as GetSignatureResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, as as GetBalanceResponse, at as FundWalletParams, a0 as FundWalletResponse, au as RegisterSignerParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, ay as GetSignerResponse, az as SendParams, ab as SendResponse } from '../types-
|
|
2
|
+
import { ad as CreateWalletParams, ac as CreateWalletResponse, a8 as WalletLocator, ai as GetWalletResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, aa as GetTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, aq as GetSignatureResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, as as GetBalanceResponse, at as FundWalletParams, a0 as FundWalletResponse, au as RegisterSignerParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, ay as GetSignerResponse, az as SendParams, ab as SendResponse } from '../types-NmTwqiYW.js';
|
|
3
3
|
import { Chain } from '../chains/chains.js';
|
|
4
4
|
import 'viem';
|
|
5
5
|
import './gen/types.gen.js';
|
package/dist/api/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-LGDJURYY.js";import"../chunk-EXC7TCGL.js";import"../chunk-TTT6T3VE.js";import"../chunk-RTS4N5HQ.js";import"../chunk-J3R36SGJ.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 _chunkP2IW4ZL6cjs = require('../chunk-P2IW4ZL6.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CCAPUWFB.cjs');require('../chunk-X2FNNYCG.cjs');require('../chunk-2GKPWQBQ.cjs');exports.ApiClient = _chunkP2IW4ZL6cjs.a;
|
package/dist/api/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ApiClient } from './client.cjs';
|
|
2
|
-
export { ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, aA as CreateTransactionSuccessResponse, ad as CreateWalletParams, ac as CreateWalletResponse, at as FundWalletParams, a0 as FundWalletResponse, as as GetBalanceResponse, aB as GetBalanceSuccessResponse, aq as GetSignatureResponse, ay as GetSignerResponse, aC as GetSignersResponse, aa as GetTransactionResponse, a2 as GetTransactionSuccessResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, ai as GetWalletResponse, aD as GetWalletSuccessResponse, aE as RecoverySignerConfig, aF as RegisterSignerChain, au as RegisterSignerParams, R as RegisterSignerPasskeyParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, az as SendParams, ab as SendResponse,
|
|
2
|
+
export { ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, aA as CreateTransactionSuccessResponse, ad as CreateWalletParams, ac as CreateWalletResponse, at as FundWalletParams, a0 as FundWalletResponse, as as GetBalanceResponse, aB as GetBalanceSuccessResponse, aq as GetSignatureResponse, ay as GetSignerResponse, aC as GetSignersResponse, aa as GetTransactionResponse, a2 as GetTransactionSuccessResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, ai as GetWalletResponse, aD as GetWalletSuccessResponse, aE as RecoverySignerConfig, aF as RegisterSignerChain, au as RegisterSignerParams, R as RegisterSignerPasskeyParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, az as SendParams, ab as SendResponse, _ as Signer, x as Transfers, a8 as WalletLocator } from '../types-Nc5kinaI.cjs';
|
|
3
3
|
import '@crossmint/common-sdk-base';
|
|
4
4
|
import '../chains/chains.cjs';
|
|
5
5
|
import 'viem';
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { ApiClient } from './client.js';
|
|
2
|
-
export { ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, aA as CreateTransactionSuccessResponse, ad as CreateWalletParams, ac as CreateWalletResponse, at as FundWalletParams, a0 as FundWalletResponse, as as GetBalanceResponse, aB as GetBalanceSuccessResponse, aq as GetSignatureResponse, ay as GetSignerResponse, aC as GetSignersResponse, aa as GetTransactionResponse, a2 as GetTransactionSuccessResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, ai as GetWalletResponse, aD as GetWalletSuccessResponse, aE as RecoverySignerConfig, aF as RegisterSignerChain, au as RegisterSignerParams, R as RegisterSignerPasskeyParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, az as SendParams, ab as SendResponse,
|
|
2
|
+
export { ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, aA as CreateTransactionSuccessResponse, ad as CreateWalletParams, ac as CreateWalletResponse, at as FundWalletParams, a0 as FundWalletResponse, as as GetBalanceResponse, aB as GetBalanceSuccessResponse, aq as GetSignatureResponse, ay as GetSignerResponse, aC as GetSignersResponse, aa as GetTransactionResponse, a2 as GetTransactionSuccessResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, ai as GetWalletResponse, aD as GetWalletSuccessResponse, aE as RecoverySignerConfig, aF as RegisterSignerChain, au as RegisterSignerParams, R as RegisterSignerPasskeyParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, az as SendParams, ab as SendResponse, _ as Signer, x as Transfers, a8 as WalletLocator } from '../types-NmTwqiYW.js';
|
|
3
3
|
import '@crossmint/common-sdk-base';
|
|
4
4
|
import '../chains/chains.js';
|
|
5
5
|
import 'viem';
|
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-LGDJURYY.js";import"../chunk-KBJA7JDT.js";import"../chunk-EXC7TCGL.js";import"../chunk-TTT6T3VE.js";import"../chunk-RTS4N5HQ.js";import"../chunk-J3R36SGJ.js";export{a as ApiClient};
|
package/dist/api/types.d.cts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'viem';
|
|
2
2
|
import './gen/types.gen.cjs';
|
|
3
|
-
export { ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, aA as CreateTransactionSuccessResponse, ad as CreateWalletParams, ac as CreateWalletResponse, at as FundWalletParams, a0 as FundWalletResponse, as as GetBalanceResponse, aB as GetBalanceSuccessResponse, aq as GetSignatureResponse, ay as GetSignerResponse, aC as GetSignersResponse, aa as GetTransactionResponse, a2 as GetTransactionSuccessResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, ai as GetWalletResponse, aD as GetWalletSuccessResponse, aE as RecoverySignerConfig, aF as RegisterSignerChain, au as RegisterSignerParams, R as RegisterSignerPasskeyParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, az as SendParams, ab as SendResponse,
|
|
3
|
+
export { ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, aA as CreateTransactionSuccessResponse, ad as CreateWalletParams, ac as CreateWalletResponse, at as FundWalletParams, a0 as FundWalletResponse, as as GetBalanceResponse, aB as GetBalanceSuccessResponse, aq as GetSignatureResponse, ay as GetSignerResponse, aC as GetSignersResponse, aa as GetTransactionResponse, a2 as GetTransactionSuccessResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, ai as GetWalletResponse, aD as GetWalletSuccessResponse, aE as RecoverySignerConfig, aF as RegisterSignerChain, au as RegisterSignerParams, R as RegisterSignerPasskeyParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, az as SendParams, ab as SendResponse, _ as Signer, x as Transfers, a8 as WalletLocator } from '../types-Nc5kinaI.cjs';
|
|
4
4
|
import '../chains/chains.cjs';
|
|
5
5
|
import 'ox';
|
|
6
6
|
import '@crossmint/client-sdk-window';
|
package/dist/api/types.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import 'viem';
|
|
2
2
|
import './gen/types.gen.js';
|
|
3
|
-
export { ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, aA as CreateTransactionSuccessResponse, ad as CreateWalletParams, ac as CreateWalletResponse, at as FundWalletParams, a0 as FundWalletResponse, as as GetBalanceResponse, aB as GetBalanceSuccessResponse, aq as GetSignatureResponse, ay as GetSignerResponse, aC as GetSignersResponse, aa as GetTransactionResponse, a2 as GetTransactionSuccessResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, ai as GetWalletResponse, aD as GetWalletSuccessResponse, aE as RecoverySignerConfig, aF as RegisterSignerChain, au as RegisterSignerParams, R as RegisterSignerPasskeyParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, az as SendParams, ab as SendResponse,
|
|
3
|
+
export { ap as ApproveSignatureParams, a9 as ApproveSignatureResponse, al as ApproveTransactionParams, am as ApproveTransactionResponse, an as CreateSignatureParams, ao as CreateSignatureResponse, aj as CreateTransactionParams, ak as CreateTransactionResponse, aA as CreateTransactionSuccessResponse, ad as CreateWalletParams, ac as CreateWalletResponse, at as FundWalletParams, a0 as FundWalletResponse, as as GetBalanceResponse, aB as GetBalanceSuccessResponse, aq as GetSignatureResponse, ay as GetSignerResponse, aC as GetSignersResponse, aa as GetTransactionResponse, a2 as GetTransactionSuccessResponse, a1 as GetTransactionsResponse, ar as GetTransfersResponse, ai as GetWalletResponse, aD as GetWalletSuccessResponse, aE as RecoverySignerConfig, aF as RegisterSignerChain, au as RegisterSignerParams, R as RegisterSignerPasskeyParams, av as RegisterSignerResponse, aw as RemoveSignerParams, ax as RemoveSignerResponse, az as SendParams, ab as SendResponse, _ as Signer, x as Transfers, a8 as WalletLocator } from '../types-NmTwqiYW.js';
|
|
4
4
|
import '../chains/chains.js';
|
|
5
5
|
import 'ox';
|
|
6
6
|
import '@crossmint/client-sdk-window';
|
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 _chunkF2TXDKPBcjs = require('../chunk-F2TXDKPB.cjs');require('../chunk-GEY574TH.cjs');require('../chunk-UE3WVHTM.cjs');require('../chunk-5X4EOJFG.cjs');require('../chunk-HRUMWG2F.cjs');require('../chunk-IR5WN6FQ.cjs');require('../chunk-T3U46LK3.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-CCAPUWFB.cjs');require('../chunk-X2FNNYCG.cjs');require('../chunk-2GKPWQBQ.cjs');exports.isMainnetChain = _chunkF2TXDKPBcjs.c; exports.isTestnetChain = _chunkF2TXDKPBcjs.b; exports.isValidChain = _chunkF2TXDKPBcjs.e; exports.mainnetToTestnet = _chunkF2TXDKPBcjs.d; exports.toViemChain = _chunkF2TXDKPBcjs.a; exports.validateChainForEnvironment = _chunkF2TXDKPBcjs.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-JHE6LNLM.js";import"../chunk-S3DYQVRD.js";import"../chunk-KUP7H7X2.js";import"../chunk-FT5EVMLB.js";import"../chunk-SVIKBM3S.js";import"../chunk-KKQBZXFE.js";import"../chunk-EXC7TCGL.js";import"../chunk-455NK5LB.js";import"../chunk-TTT6T3VE.js";import"../chunk-RTS4N5HQ.js";import"../chunk-J3R36SGJ.js";export{c as isMainnetChain,b as isTestnetChain,e as isValidChain,d as mainnetToTestnet,a as toViemChain,f as validateChainForEnvironment};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJBP52JOHcjs = require('./chunk-JBP52JOH.cjs');var _chunkAS2YN2YCcjs = require('./chunk-AS2YN2YC.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkJBP52JOHcjs = require('./chunk-JBP52JOH.cjs');var _chunkAS2YN2YCcjs = require('./chunk-AS2YN2YC.cjs');var _chunkCCAPUWFBcjs = require('./chunk-CCAPUWFB.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var f=class{constructor(i){this.config=i;this._needsAuth=!0;this._authPromise=null;this._initializationPromise=null;typeof window!="undefined"&&(this._initializationPromise=this.initialize()),this.type=this.config.type}locator(){return this.config.locator}address(){return this.config.address}initialize(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{if(this.config.clientTEEConnection==null){let i=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:i.environment});this.config.clientTEEConnection=yield t.initialize()}}finally{this._initializationPromise=null}})}getTEEConnection(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.config.clientTEEConnection==null){if(this._initializationPromise){if(yield this._initializationPromise,this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");return this.config.clientTEEConnection}this._initializationPromise=this.initializeTEEConnection();try{yield this._initializationPromise}finally{this._initializationPromise=null}}if(this.config.clientTEEConnection==null)throw new Error("TEE connection is not initialized");return this.config.clientTEEConnection})}initializeTEEConnection(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkCCAPUWFBcjs.a.info("TEE connection not initialized, initializing now");let i=_commonsdkbase.validateAPIKey.call(void 0, this.config.crossmint.apiKey);if(!i.isValid)throw new Error("Invalid API key");let t=new (0, _chunkJBP52JOHcjs.a)({environment:i.environment});if(this.config.clientTEEConnection=yield t.initialize(),this.config.clientTEEConnection==null)throw new Error("Failed to initialize TEE connection");_chunkCCAPUWFBcjs.a.info("TEE connection initialized successfully")})}handleAuthRequired(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var u;let i=yield this.getTEEConnection();if(this.config.onAuthRequired==null)throw new Error(`${this.type} signer requires the onAuthRequired callback to handle OTP verification. This callback manages the authentication flow (sending OTP and verifying user input). If using our React/React Native SDK, this is handled automatically by the provider. For other environments, implement: onAuthRequired: (needsAuth, sendOtp, verifyOtp, reject) => { /* your UI logic */ }`);_chunkCCAPUWFBcjs.a.info("get-status: sending request");let t=Date.now(),r=yield i.sendAction({event:"request:get-status",responseEvent:"response:get-status",data:{authData:{jwt:(u=this.config.crossmint.jwt)!=null?u:"",apiKey:this.config.crossmint.apiKey}},options:d}),n=Date.now()-t;if((r==null?void 0:r.status)!=="success")throw _chunkCCAPUWFBcjs.a.error("get-status: failed",{status:r==null?void 0:r.status,error:r==null?void 0:r.error,durationMs:n}),new Error(r==null?void 0:r.error);if(_chunkCCAPUWFBcjs.a.info("get-status: response received",{signerStatus:r.signerStatus,durationMs:n}),r.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkCCAPUWFBcjs.a.info("Auth required, initiating OTP flow",{needsAuth:this._needsAuth});let{promise:a,resolve:s,reject:c}=this.createAuthPromise();if(this._authPromise={promise:a,resolve:s,reject:c},this.config.onAuthRequired)try{yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){_chunkCCAPUWFBcjs.a.info("Auth rejected",{authRejected:!0}),this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new _chunkAS2YN2YCcjs.a)})),c(new _chunkAS2YN2YCcjs.a)}))}catch(e){_chunkCCAPUWFBcjs.a.error("handleAuthRequired error",{error:e}),c(e)}try{yield a}catch(e){throw _chunkCCAPUWFBcjs.a.error("handleAuthRequired promise error",{error:e}),e}})}ensureAuthenticated(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired()})}getJwtOrThrow(){let i=this.config.crossmint.jwt;if(i==null)throw new Error("JWT is required");return i}createAuthPromise(){let i,t;return{promise:new Promise((n,a)=>{i=n,t=a}),resolve:i,reject:t}}sendMessageWithOtp(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var s,c;let i=yield this.getTEEConnection(),t=this.getAuthId();_chunkCCAPUWFBcjs.a.info("start-onboarding: sending request");let r=Date.now(),n=yield i.sendAction({event:"request:start-onboarding",responseEvent:"response:start-onboarding",data:{authData:{jwt:(s=this.config.crossmint.jwt)!=null?s:"",apiKey:this.config.crossmint.apiKey},data:{authId:t}},options:d}),a=Date.now()-r;if(_chunkCCAPUWFBcjs.a.info("start-onboarding: response received",{status:n==null?void 0:n.status,durationMs:a}),(n==null?void 0:n.status)==="success"&&n.signerStatus==="ready"){this._needsAuth=!1;return}(n==null?void 0:n.status)==="error"&&(_chunkCCAPUWFBcjs.a.error("start-onboarding: failed",{error:n.error}),(c=this._authPromise)==null||c.reject(new Error(n.error||"Failed to initiate OTP process.")))})}getAuthId(){return this.config.type==="email"?`email:${this.config.email}`:`phone:${this.config.phone}`}verifyOtp(i){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var a,s,c,u;let t;try{let e=yield this.getTEEConnection();_chunkCCAPUWFBcjs.a.info("complete-onboarding: sending request");let E=Date.now();t=yield e.sendAction({event:"request:complete-onboarding",responseEvent:"response:complete-onboarding",data:{authData:{jwt:(a=this.config.crossmint.jwt)!=null?a:"",apiKey:this.config.crossmint.apiKey},data:{onboardingAuthentication:{encryptedOtp:i}}},options:d}),_chunkCCAPUWFBcjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-E})}catch(e){throw _chunkCCAPUWFBcjs.a.error("complete-onboarding: error",{error:e}),this._needsAuth=!0,(s=this._authPromise)==null||s.reject(e),e}if((t==null?void 0:t.status)==="success"){this._needsAuth=!1,this.config.onAuthRequired!=null&&(yield this.config.onAuthRequired(this.config.type,this.locator(),this._needsAuth,()=>this.sendMessageWithOtp(),e=>this.verifyOtp(e),()=>{var e;return(e=this._authPromise)==null?void 0:e.reject(new _chunkAS2YN2YCcjs.a)})),(c=this._authPromise)==null||c.resolve();return}_chunkCCAPUWFBcjs.a.error("complete-onboarding: OTP validation failed",{status:t==null?void 0:t.status}),this._needsAuth=!0;let r=(t==null?void 0:t.status)==="error"?t.error:"Failed to validate encrypted OTP",n=new Error(r);throw(u=this._authPromise)==null||u.reject(n),n})}_exportPrivateKey(i,t){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.handleAuthRequired();let r=this.getJwtOrThrow(),{scheme:n,encoding:a}=this.getChainKeyParams();if(t!=null){let c=i.on("event:key-exported",u=>{i.off(c),u.status==="success"&&Promise.resolve().then(()=>t()).catch(()=>{console.error("[NCS Signer] onExport callback error")})})}let s=yield i.sendAction({event:"request:export-signer",responseEvent:"response:export-signer",data:{authData:{jwt:r,apiKey:this.config.crossmint.apiKey},data:{scheme:n,encoding:a}},options:d});if((s==null?void 0:s.status)==="error")throw new Error(s.error||"Failed to export private key")})}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCCAPUWFBcjs.a,methodName:"handleAuthRequired"})],f.prototype,"handleAuthRequired",1);var d={timeoutMs:3e4};exports.a = f; exports.b = d;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGDRSDCM6cjs = require('./chunk-GDRSDCM6.cjs');var _chunkGQHU6TH5cjs = require('./chunk-GQHU6TH5.cjs');var _chunkF2TXDKPBcjs = require('./chunk-F2TXDKPB.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkCCAPUWFBcjs = require('./chunk-CCAPUWFB.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _viem = require('viem');var _commonsdkbase = require('@crossmint/common-sdk-base');var c=class c extends _chunkGDRSDCM6cjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunkGDRSDCM6cjs.a.getOptions(e),alias:e.alias,recovery:_chunkGDRSDCM6cjs.a.getRecovery(e),signer:e.signer,signers:_chunkGDRSDCM6cjs.a.getInitialSigners(e)},_chunkGDRSDCM6cjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidEvmAddress.call(void 0, e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkCCAPUWFBcjs.a.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=this.buildTransaction(e),t=yield this.createTransaction(n,e.options);if((i=e.options)!=null&&i.prepareOnly)return _chunkCCAPUWFBcjs.a.info("evmWallet.sendTransaction.prepared",{transactionId:t.id}),{hash:void 0,explorerLink:void 0,transactionId:t.id};let a=yield this.approveTransactionAndWait(t.id);return _chunkCCAPUWFBcjs.a.info("evmWallet.sendTransaction.success",{transactionId:t.id,hash:a.hash}),a})}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var i;_chunkCCAPUWFBcjs.a.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),t=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:n.locator(),chain:this.chain}});if("error"in t)throw _chunkCCAPUWFBcjs.a.error("evmWallet.signMessage.error",{error:t}),new (0, _chunkT3U46LK3cjs.p)(JSON.stringify(t));if((i=e.options)!=null&&i.prepareOnly)return _chunkCCAPUWFBcjs.a.info("evmWallet.signMessage.prepared",{signatureId:t.id}),{signature:void 0,signatureId:t.id};let a=yield this.approveSignatureAndWait(t.id);return _chunkCCAPUWFBcjs.a.info("evmWallet.signMessage.success",{signatureId:t.id}),a})}signTypedData(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var S;_chunkCCAPUWFBcjs.a.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let n=this.requireSigner(),{domain:t,message:a,primaryType:i,types:p,chain:m}=e;if(!t||!a||!p||!m)throw _chunkCCAPUWFBcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new (0, _chunkT3U46LK3cjs.l)("Invalid typed data");let{name:y,version:v,chainId:I,verifyingContract:C,salt:M}=t;if(!y||!v||!I||!C)throw _chunkCCAPUWFBcjs.a.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new (0, _chunkT3U46LK3cjs.l)("Invalid typed data domain");let o=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:y,version:v,chainId:Number(I),verifyingContract:C,salt:M},message:T(a),primaryType:i,types:p},signer:n.locator(),chain:m}});if("error"in o)throw _chunkCCAPUWFBcjs.a.error("evmWallet.signTypedData.error",{error:o}),new (0, _chunkT3U46LK3cjs.p)(JSON.stringify(o));if((S=e.options)!=null&&S.prepareOnly)return _chunkCCAPUWFBcjs.a.info("evmWallet.signTypedData.prepared",{signatureId:o.id}),{signature:void 0,signatureId:o.id};let O=yield this.approveSignatureAndWait(o.id);return _chunkCCAPUWFBcjs.a.info("evmWallet.signTypedData.success",{signatureId:o.id}),O})}getViemClient(e){var n;return _viem.createPublicClient.call(void 0, {transport:(n=e==null?void 0:e.transport)!=null?n:_viem.http.call(void 0, ),chain:_chunkF2TXDKPBcjs.a.call(void 0, this.chain)})}createTransaction(e,n){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t;(n==null?void 0:n.signer)==null?t=this.requireSigner().locator():typeof n.signer=="string"?t=n.signer:t=`server:${_chunkGQHU6TH5cjs.b.call(void 0, n.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:t,chain:this.chain,calls:[e]}});if("error"in a)throw new (0, _chunkT3U46LK3cjs.t)(JSON.stringify(a));return a})}buildTransaction(e){var n,t,a,i,p;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(t=(n=e.value)==null?void 0:n.toString())!=null?t:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(p=(i=e.value)==null?void 0:i.toString())!=null?p:"0",data:_viem.encodeFunctionData.call(void 0, {abi:e.abi,functionName:e.functionName,args:e.args})}}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCCAPUWFBcjs.a,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCCAPUWFBcjs.a,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCCAPUWFBcjs.a,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var D=c;function T(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(T):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,n])=>[e,T(n)])):s}exports.a = D;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as d}from"./chunk-OQZTL6ZG.js";import{a as
|
|
1
|
+
import{a as d}from"./chunk-OQZTL6ZG.js";import{a as n}from"./chunk-XNZLCUTY.js";import{a as o,b as s}from"./chunk-EM3D5Q3A.js";import{privateKeyToAccount as y}from"viem/accounts";import{bytesToHex as m}from"@noble/hashes/utils";import{Keypair as f}from"@solana/web3.js";function v(r,e){switch(d(e)){case"evm":return y(`0x${m(r)}`).address;case"solana":return f.fromSeed(r).publicKey.toBase58();case"stellar":return o(s(r).publicKey)}}function b(r,e,i,a){if(typeof window!="undefined")throw new Error("Server signers can only be used from server-side code.");let p=typeof e=="string"?e:String(e),t=n(r.secret,i,a,p),c=v(t,e);return{derivedKeyBytes:t,derivedAddress:c}}export{v as a,b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as S}from"./chunk-6X5JEJD7.js";import{a as l}from"./chunk-
|
|
1
|
+
import{a as S}from"./chunk-6X5JEJD7.js";import{a as l}from"./chunk-LBKX6JJV.js";import{a as i}from"./chunk-FFOVF23E.js";import{a as t}from"./chunk-PR2M7QAF.js";import{a as C}from"./chunk-EE4ITUGS.js";import{a as u}from"./chunk-CKZYSQOK.js";import{a as p}from"./chunk-QVTKTDED.js";import{a as s}from"./chunk-XS5B3TUE.js";import{a as m}from"./chunk-M335XCYO.js";import{a as g}from"./chunk-YH7G2U6V.js";import{a as o}from"./chunk-W7LJS32A.js";import{g as a}from"./chunk-EXC7TCGL.js";function V(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new t(e):r==="stellar"?new l(e):new i(e);case"api-key":return r==="solana"?new g(e):new p(e);case"external-wallet":return r==="solana"?new o(e):r==="stellar"?new C(e):new s(e);case"server":return S(r,e);case"passkey":return new m(e);case"device":if(n==null)throw new a("Device signer key storage is required for device signers");return new u(e,n)}}export{V as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3VYGTPRFcjs = require('./chunk-3VYGTPRF.cjs');var _chunkCCAPUWFBcjs = require('./chunk-CCAPUWFB.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _ox = require('ox');var b={[_commonsdkbase.APIKeyEnvironmentPrefix.DEVELOPMENT]:"https://development.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.STAGING]:"https://staging.devicekey.store",[_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION]:"https://devicekey.store"},P=6e4,K="indexeddb-fatal",c= exports.a =class extends _chunk3VYGTPRFcjs.a{constructor(e){super(e);this.iframePromise=null;this.reloading=null;this.biometricRequestHandler=null;this.biometricListener=null;let r=_commonsdkbase.getEnvironmentForKey.call(void 0, e);if(r==null)throw new Error("Unable to determine environment from API key");this.iframeUrl=b[r]}setBiometricRequestHandler(e){this.biometricRequestHandler=e}generateKey(){return _chunk2GKPWQBQcjs.g.call(void 0, this,arguments,function*(e={biometricPolicy:"none"}){return(yield this.rpc("generateKey",e)).publicKeyBase64})}mapAddressToKey(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("mapAddressToKey",{address:e,publicKeyBase64:r})})}getKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("getKey",{address:e})).publicKeyBase64})}hasKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return(yield this.rpc("hasKey",{publicKeyBase64:e})).hasKey})}signMessage(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.rpc("signMessage",{address:e,message:r})})}deleteKey(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){yield this.rpc("deleteKey",{address:e})})}destroy(){this.biometricListener!=null&&(window.removeEventListener("message",this.biometricListener),this.biometricListener=null),this.iframePromise!=null&&(this.iframePromise.then(e=>e.remove()).catch(()=>{}),this.iframePromise=null)}rpc(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=yield this.sendRpc(e,r);if(i.fatal){_chunkCCAPUWFBcjs.a.warn(`[IframeDeviceSignerKeyStorage] Recoverable IDB error on "${e}", reloading iframe and retrying`),yield this.reloadIframe();let t=yield this.sendRpc(e,r);if(t.fatal)throw new Error(`Device signer IDB fatal error on "${e}" persisted after iframe reload`);return t.value}return i.value})}sendRpc(e,r){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let t=(yield this.getIframe()).contentWindow;if(t==null)throw new Error("Device signer iframe has no contentWindow");let g=crypto.randomUUID(),a=new URL(this.iframeUrl).origin;return new Promise((s,o)=>{let f=setTimeout(()=>{window.removeEventListener("message",p),o(new Error(`Device signer RPC "${e}" timed out after ${P}ms`))},P);function p(y){let m=y.data;m==null||m.id!==g||y.origin===a&&(clearTimeout(f),window.removeEventListener("message",p),m.type==="error"&&m.code===K?s({fatal:!0}):m.type==="error"?o(new Error(m.error)):s({value:m.result,fatal:!1}))}window.addEventListener("message",p),t.postMessage({type:e,id:g,payload:r},this.iframeUrl)})})}reloadIframe(){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(this.reloading!=null)return this.reloading;let e=_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){try{this.destroy(),yield this.getIframe()}finally{this.reloading=null}});return this.reloading=e,e})}setupBiometricListener(e){let r=new URL(this.iframeUrl).origin;this.biometricListener=i=>_chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){if(i.origin!==r)return;let t=i.data;if((t==null?void 0:t.type)!=="biometric-request")return;let g=e.contentWindow;if(g!=null)try{this.biometricRequestHandler!=null&&(yield this.biometricRequestHandler(t.action));let a=null;if(t.action==="createCredential"){let s=t.payload,o=yield _ox.WebAuthnP256.createCredential({name:s.name});a={id:o.id,publicKey:{x:`0x${o.publicKey.x.toString(16)}`,y:`0x${o.publicKey.y.toString(16)}`}}}else if(t.action==="sign"){let s=t.payload,{signature:o,metadata:f}=yield _ox.WebAuthnP256.sign({credentialId:s.credentialId,challenge:s.challenge});a={signature:{r:`0x${o.r.toString(16)}`,s:`0x${o.s.toString(16)}`},metadata:f}}g.postMessage({type:"biometric-response",id:t.id,result:a},this.iframeUrl)}catch(a){let s=a instanceof Error?a.message:"Unknown biometric error";g.postMessage({type:"biometric-response",id:t.id,error:s},this.iframeUrl)}}),window.addEventListener("message",this.biometricListener)}getIframe(){return this.iframePromise==null&&(this.iframePromise=this.createIframe().catch(e=>{throw this.iframePromise=null,e})),this.iframePromise}createIframe(){let e=document.createElement("iframe");return e.src=this.iframeUrl,Object.assign(e.style,{position:"absolute",opacity:"0",pointerEvents:"none",width:"0",height:"0",border:"none",top:"-9999px",left:"-9999px"}),new Promise((r,i)=>{e.onload=()=>{this.setupBiometricListener(e),r(e)},e.onerror=()=>i(new Error("Failed to load device signer iframe")),document.body.appendChild(e)})}getDeviceName(){var t;if(typeof navigator=="undefined")return"Unknown Device";let e=navigator.userAgent,r=this.parseDevice(e),i=this.parseBrowser(e);return r!=null&&i!=null?`${i} on ${r}`:(t=r!=null?r:i)!=null?t:"Unknown Device"}parseDevice(e){return/iPad/.test(e)?"iPad":/iPhone/.test(e)?"iPhone":/Macintosh|Mac OS X/.test(e)?"Mac":/Windows/.test(e)?"Windows":/Android/.test(e)?"Android":/Linux/.test(e)?"Linux":/CrOS/.test(e)?"ChromeOS":null}parseBrowser(e){return/Edg\//.test(e)?"Edge":/OPR\/|Opera/.test(e)?"Opera":typeof navigator!="undefined"&&"brave"in navigator?"Brave":/Chrome\//.test(e)?"Chrome":/Safari\//.test(e)&&!/Chrome\//.test(e)?"Safari":/Firefox\//.test(e)?"Firefox":null}};_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCCAPUWFBcjs.a,methodName:"deviceSignerKeyStorage.generateKey"})],c.prototype,"generateKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCCAPUWFBcjs.a,methodName:"deviceSignerKeyStorage.mapAddressToKey"})],c.prototype,"mapAddressToKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCCAPUWFBcjs.a,methodName:"deviceSignerKeyStorage.getKey"})],c.prototype,"getKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCCAPUWFBcjs.a,methodName:"deviceSignerKeyStorage.hasKey"})],c.prototype,"hasKey",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCCAPUWFBcjs.a,methodName:"deviceSignerKeyStorage.signMessage"})],c.prototype,"signMessage",1),_chunk2GKPWQBQcjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkCCAPUWFBcjs.a,methodName:"deviceSignerKeyStorage.deleteKey"})],c.prototype,"deleteKey",1);exports.a = c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as i}from"./chunk-
|
|
1
|
+
import{a as i}from"./chunk-K2OP3UKD.js";import{b as T}from"./chunk-2UQ3HUS6.js";import{a as f}from"./chunk-W7LJS32A.js";import{t as g}from"./chunk-EXC7TCGL.js";import{a as r}from"./chunk-TTT6T3VE.js";import{c as u,g as l}from"./chunk-J3R36SGJ.js";import m from"bs58";import{isValidSolanaAddress as y,WithLoggerContext as C}from"@crossmint/common-sdk-base";var o=class o extends i{constructor(n){super({chain:n.chain,address:n.address,owner:n.owner,options:i.getOptions(n),alias:n.alias,recovery:i.getRecovery(n),signer:n.signer,signers:i.getInitialSigners(n)},i.getApiClient(n))}static from(n){if(!y(n.address))throw new Error("Wallet is not a Solana wallet");return new o(n)}sendTransaction(n){return l(this,null,function*(){var d,p;r.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let e=yield this.createTransaction(n);if((d=n.options)!=null&&d.prepareOnly)return r.info("solanaWallet.sendTransaction.prepared",{transactionId:e.id}),{hash:void 0,explorerLink:void 0,transactionId:e.id};let t={additionalSigners:(p=n.additionalSigners)==null?void 0:p.map(c=>new f({type:"external-wallet",address:c.publicKey.toString(),locator:`external-wallet:${c.publicKey.toString()}`,onSign:h=>(h.sign([c]),Promise.resolve(h))}))},a=yield this.approveTransactionAndWait(e.id,t);return r.info("solanaWallet.sendTransaction.success",{transactionId:e.id,hash:a.hash}),a})}createTransaction(n){return l(this,null,function*(){var a;let e;((a=n.options)==null?void 0:a.signer)==null?e=this.requireSigner().locator():typeof n.options.signer=="string"?e=n.options.signer:e=`server:${T(n.options.signer,this.chain,this.apiClient.projectId,this.apiClient.environment).derivedAddress}`;let s;"serializedTransaction"in n?s=n.serializedTransaction:s=m.encode(n.transaction.serialize());let t=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:e}});if("error"in t)throw new g(JSON.stringify(t));return t})}};u([C({logger:r,methodName:"solanaWallet.sendTransaction",buildContext(n){return{chain:n.chain,address:n.address}}})],o.prototype,"sendTransaction",1);var S=o;export{S as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkX2FNNYCGcjs = require('./chunk-X2FNNYCG.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var t=new _commonsdkbase.SdkLogger;function v(s){let o=_commonsdkbase.detectPlatform.call(void 0, ),e=_commonsdkbase.validateAPIKey.call(void 0, s);if(!e.isValid)throw new Error(`Invalid API key: ${e.message}`);let{environment:a,projectId:c}=e;switch(t.init({packageName:_chunkX2FNNYCGcjs.c,packageVersion:_chunkX2FNNYCGcjs.b,environment:a,projectId:c,platform:o}),o){case"browser":{let r=new (0, _commonsdkbase.BrowserDatadogSink)(a);t.addSink(r);break}case"react-native":break;case"server":{let r=new (0, _commonsdkbase.ServerDatadogSink)(a);t.addSink(r);break}default:break}}exports.a = t; exports.b = v;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkGEY574THcjs = require('./chunk-GEY574TH.cjs');var _chunkUE3WVHTMcjs = require('./chunk-UE3WVHTM.cjs');var _chunk5X4EOJFGcjs = require('./chunk-5X4EOJFG.cjs');var _chunkHRUMWG2Fcjs = require('./chunk-HRUMWG2F.cjs');var _chunkIR5WN6FQcjs = require('./chunk-IR5WN6FQ.cjs');var _chunkT3U46LK3cjs = require('./chunk-T3U46LK3.cjs');var _chunkCCAPUWFBcjs = require('./chunk-CCAPUWFB.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var _chains = require('viem/chains');var b=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.CURTIS,_commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,_commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET,_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET],w=[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT,_commonsdkbase.BlockchainIncludingTestnet.APECHAIN,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM,_commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA,_commonsdkbase.BlockchainIncludingTestnet.BASE,_commonsdkbase.BlockchainIncludingTestnet.BSC,_commonsdkbase.BlockchainIncludingTestnet.FLOW,_commonsdkbase.BlockchainIncludingTestnet.MANTLE,_commonsdkbase.BlockchainIncludingTestnet.MODE,_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM,_commonsdkbase.BlockchainIncludingTestnet.PLUME,_commonsdkbase.BlockchainIncludingTestnet.POLYGON,_commonsdkbase.BlockchainIncludingTestnet.SCROLL,_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1,_commonsdkbase.BlockchainIncludingTestnet.SHAPE,_commonsdkbase.BlockchainIncludingTestnet.STORY,_commonsdkbase.BlockchainIncludingTestnet.TEMPO,_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN,_commonsdkbase.BlockchainIncludingTestnet.ZORA];function Q(t){switch(t){case _commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA:return _chains.baseSepolia;case _commonsdkbase.BlockchainIncludingTestnet.BASE:return _chains.base;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY:return _chains.polygonAmoy;case _commonsdkbase.BlockchainIncludingTestnet.POLYGON:return _chains.polygon;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA:return _chains.optimismSepolia;case _commonsdkbase.BlockchainIncludingTestnet.OPTIMISM:return _chains.optimism;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA:return _chains.arbitrumSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUM:return _chains.arbitrum;case _commonsdkbase.BlockchainIncludingTestnet.ARBITRUMNOVA:return _chains.arbitrumNova;case _commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET:return _chunkGEY574THcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.STORY:return _chunkIR5WN6FQcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA:return _chains.modeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.MODE:return _chains.mode;case _commonsdkbase.BlockchainIncludingTestnet.BSC:return _chains.bsc;case _commonsdkbase.BlockchainIncludingTestnet.SHAPE:return _chains.shape;case _commonsdkbase.BlockchainIncludingTestnet.ZORA:return _chains.zora;case _commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA:return _chains.zoraSepolia;case _commonsdkbase.BlockchainIncludingTestnet.ETHEREUM_SEPOLIA:return _chains.sepolia;case _commonsdkbase.BlockchainIncludingTestnet.FLOW:return _chains.flowMainnet;case _commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET:return _chains.flowTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET:return _chains.plumeTestnet;case _commonsdkbase.BlockchainIncludingTestnet.PLUME:return _chains.plume;case _commonsdkbase.BlockchainIncludingTestnet.ARC_TESTNET:return _chunkHRUMWG2Fcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO:return _chunkUE3WVHTMcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET:return _chunk5X4EOJFGcjs.a;case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT:case _commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.APECHAIN:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE:case _commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL:case _commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA:case _commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1:case _commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET:case _commonsdkbase.BlockchainIncludingTestnet.CURTIS:case _commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN:case _commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA:throw new Error(`Chain ${t} is not yet supported in toViemChain function. Please add the appropriate viem chain definition.`);default:throw new Error(`Unknown chain: ${t}`)}}function I(t){return b.includes(t)}function C(t){return w.includes(t)}var D={[_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT]:_commonsdkbase.BlockchainIncludingTestnet.ABSTRACT_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.APECHAIN]:_commonsdkbase.BlockchainIncludingTestnet.CURTIS,[_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM]:_commonsdkbase.BlockchainIncludingTestnet.ARBITRUM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.BASE]:_commonsdkbase.BlockchainIncludingTestnet.BASE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.FLOW]:_commonsdkbase.BlockchainIncludingTestnet.FLOW_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.MANTLE]:_commonsdkbase.BlockchainIncludingTestnet.MANTLE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.MODE]:_commonsdkbase.BlockchainIncludingTestnet.MODE_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM]:_commonsdkbase.BlockchainIncludingTestnet.OPTIMISM_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.PLUME]:_commonsdkbase.BlockchainIncludingTestnet.PLUME_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.POLYGON]:_commonsdkbase.BlockchainIncludingTestnet.POLYGON_AMOY,[_commonsdkbase.BlockchainIncludingTestnet.SCROLL]:_commonsdkbase.BlockchainIncludingTestnet.SCROLL_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.SEI_PACIFIC_1]:_commonsdkbase.BlockchainIncludingTestnet.SEI_ATLANTIC_2_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.STORY]:_commonsdkbase.BlockchainIncludingTestnet.STORY_TESTNET,[_commonsdkbase.BlockchainIncludingTestnet.WORLDCHAIN]:_commonsdkbase.BlockchainIncludingTestnet.WORLD_CHAIN_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.ZORA]:_commonsdkbase.BlockchainIncludingTestnet.ZORA_SEPOLIA,[_commonsdkbase.BlockchainIncludingTestnet.TEMPO]:_commonsdkbase.BlockchainIncludingTestnet.TEMPO_TESTNET};function Y(t){return D[t]}function g(t){return t==="solana"||t==="stellar"||I(t)||C(t)}function X(t,a){if(!g(t))throw new (0, _chunkT3U46LK3cjs.c)(`Unknown chain "${t}". Please use a supported chain name (e.g. "base-sepolia", "polygon", "solana", "stellar").`);if(t==="solana"||t==="stellar")return t;let r=t,T=a===_commonsdkbase.APIKeyEnvironmentPrefix.PRODUCTION;if(T&&I(r))throw new (0, _chunkT3U46LK3cjs.b)(`Chain "${t}" is a testnet chain and cannot be used in production. Please use a mainnet chain instead.`);if(!T&&C(r)){let n=Y(r);if(n!=null)return _chunkCCAPUWFBcjs.a.debug("validateChainForEnvironment.autoConverted",{chain:t,convertedTo:n,environment:a,message:`Chain "${t}" is a mainnet chain and cannot be used in ${a} environment. Automatically converted to "${n}".`}),n;_chunkCCAPUWFBcjs.a.debug("validateChainForEnvironment.mismatch",{chain:t,environment:a,message:`Chain "${t}" is a mainnet chain and should not be used in ${a} environment. No testnet equivalent is available. Please use a testnet chain instead.`})}return t}exports.a = Q; exports.b = I; exports.c = C; exports.d = Y; exports.e = g; exports.f = X;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b as g}from"./chunk-
|
|
1
|
+
import{a,b as g}from"./chunk-TYVOOI35.js";import{a as s}from"./chunk-TTT6T3VE.js";import{g as t}from"./chunk-J3R36SGJ.js";import{PersonalMessage as u}from"ox";import{isHex as h,toHex as l}from"viem";var c=class p extends a{constructor(e){super(e)}signMessage(e){return t(this,null,function*(){let i=h(e)?e:l(e),r=u.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return t(this,null,function*(){return yield this.sign(e)})}sign(e){return t(this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");s.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:g});if(s.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};export{c as a};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk2B2VKXMRcjs = require('./chunk-2B2VKXMR.cjs');var _chunkCCAPUWFBcjs = require('./chunk-CCAPUWFB.cjs');var _chunk2GKPWQBQcjs = require('./chunk-2GKPWQBQ.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunk2B2VKXMRcjs.a{constructor(e){super(e)}signMessage(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){let i=_viem.isHex.call(void 0, e)?e:_viem.toHex.call(void 0, e),r=_ox.PersonalMessage.getSignPayload(i);return yield this.sign(r)})}signTransaction(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunk2GKPWQBQcjs.g.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkCCAPUWFBcjs.a.info("sign: sending request",{keyType:"secp256k1"});let y=Date.now(),n=yield(o=this.config.clientTEEConnection)==null?void 0:o.sendAction({event:"request:sign",responseEvent:"response:sign",data:{authData:{jwt:i,apiKey:this.config.crossmint.apiKey},data:{keyType:"secp256k1",bytes:r,encoding:"hex"}},options:_chunk2B2VKXMRcjs.b});if(_chunkCCAPUWFBcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};exports.a = c;
|