@crossmint/wallets-sdk 1.9.0 → 1.10.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-BDQ6PRDN.js → chunk-375QJHH2.js} +1 -1
- package/dist/chunk-3MF3O7DM.js +1 -0
- package/dist/{chunk-5UR3TR3H.cjs → chunk-3V7BHEQD.cjs} +1 -1
- package/dist/chunk-3VKLU6RH.cjs +1 -0
- package/dist/chunk-5ARUTNXL.cjs +1 -0
- package/dist/chunk-5GYNNLVW.cjs +1 -0
- package/dist/{chunk-SSC676RL.js → chunk-5RW5KBQT.js} +1 -1
- package/dist/{chunk-CGQR7B2H.cjs → chunk-72ATJ6TI.cjs} +1 -1
- package/dist/chunk-D5MVJQXK.js +1 -0
- package/dist/{chunk-J4L3FCIC.js → chunk-DI6RHRZL.js} +1 -1
- package/dist/{chunk-5OGNXLOH.js → chunk-DPU7ZDOR.js} +1 -1
- package/dist/{chunk-J42KB6M4.cjs → chunk-F44BTXOF.cjs} +1 -1
- package/dist/{chunk-464D53RC.js → chunk-FQ72MI5X.js} +1 -1
- package/dist/chunk-GPV7CQRP.cjs +1 -0
- package/dist/{chunk-HBGLYYE4.js → chunk-HIQJJVCM.js} +1 -1
- package/dist/{chunk-IHJXAM3H.cjs → chunk-ILD5AY26.cjs} +1 -1
- package/dist/chunk-IP6YYDHR.cjs +1 -0
- package/dist/{chunk-IASKJ4WS.js → chunk-IX4WR4RQ.js} +1 -1
- package/dist/{chunk-23X5QOE6.cjs → chunk-KICS3RGF.cjs} +1 -1
- package/dist/{chunk-WLTYJRB5.js → chunk-KRBTB7ZD.js} +1 -1
- package/dist/{chunk-5KGXMZFJ.js → chunk-KRODF7KK.js} +1 -1
- package/dist/{chunk-532BF2RA.cjs → chunk-LTTMLPVE.cjs} +1 -1
- package/dist/{chunk-OHR5JRFH.cjs → chunk-MBFZQQQY.cjs} +1 -1
- package/dist/{chunk-DZAG4SRY.js → chunk-MMIBGH44.js} +1 -1
- package/dist/chunk-MSG2HGUJ.js +1 -0
- package/dist/{chunk-222WHEBO.js → chunk-PWOSYRP7.js} +1 -1
- package/dist/{chunk-LOZ4BC3H.cjs → chunk-Q542QHF4.cjs} +1 -1
- package/dist/{chunk-ILCNZB3A.cjs → chunk-QFZSILOI.cjs} +1 -1
- package/dist/{chunk-5M4L42QQ.js → chunk-QQYB76KH.js} +1 -1
- package/dist/chunk-S5VWQSTF.js +1 -0
- package/dist/{chunk-HXN3ZART.js → chunk-SI3GYRHH.js} +1 -1
- package/dist/{chunk-HRRPQMFM.cjs → chunk-T2DDN34X.cjs} +1 -1
- package/dist/{chunk-2SUPM5NU.js → chunk-THDXNOZG.js} +1 -1
- package/dist/{chunk-Z7GMI25O.cjs → chunk-TMSRJGFL.cjs} +1 -1
- package/dist/{chunk-DVTKFD3K.js → chunk-TODN3BHC.js} +1 -1
- package/dist/chunk-TZR7N7VZ.js +1 -0
- package/dist/{chunk-KZ62YXDQ.cjs → chunk-UWQ6UZGE.cjs} +1 -1
- package/dist/{chunk-4T45LK43.cjs → chunk-UZN6B2NV.cjs} +1 -1
- package/dist/{chunk-PZC2L2XZ.cjs → chunk-VGDORB2L.cjs} +1 -1
- package/dist/{chunk-CTJQUZUF.js → chunk-W7V3VEMM.js} +1 -1
- package/dist/chunk-WFWX6G26.cjs +1 -0
- package/dist/{chunk-E7Z24LRS.cjs → chunk-WKHVIEB2.cjs} +1 -1
- package/dist/{chunk-HJIKAOPC.cjs → chunk-X6FEF7IR.cjs} +1 -1
- package/dist/{chunk-AERFTEJI.cjs → chunk-XNH3I436.cjs} +1 -1
- package/dist/{chunk-YLMVZCBF.js → chunk-YAWVSDCB.js} +1 -1
- package/dist/{chunk-2UL2H43T.js → chunk-YFYV2J4S.js} +1 -1
- package/dist/{chunk-J64QG3LS.js → chunk-Z3YQFRAQ.js} +1 -1
- package/dist/{chunk-7AE4UN5A.cjs → chunk-Z7NKKPX3.cjs} +1 -1
- package/dist/index.cjs +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.js +1 -1
- package/dist/signers/index.cjs +1 -1
- package/dist/signers/index.d.cts +2 -1
- package/dist/signers/index.d.ts +2 -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/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/index.cjs +1 -1
- package/dist/utils/device-signers/index.js +1 -1
- package/dist/wallets/__tests__/test-helpers.cjs +1 -1
- package/dist/wallets/__tests__/test-helpers.js +1 -1
- package/dist/wallets/evm.cjs +1 -1
- 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.d.cts +3 -2
- package/dist/wallets/services/device-recovery-service.d.ts +3 -2
- 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.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.js +1 -1
- package/dist/wallets/stellar.cjs +1 -1
- package/dist/wallets/stellar.js +1 -1
- package/dist/wallets/wallet-factory.cjs +1 -1
- package/dist/wallets/wallet-factory.js +1 -1
- package/dist/wallets/wallet.cjs +1 -1
- package/dist/wallets/wallet.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-2F6CGFVL.cjs +0 -1
- package/dist/chunk-2TVSRZ42.js +0 -1
- package/dist/chunk-6DEQI3XT.cjs +0 -1
- package/dist/chunk-DFIZFCX4.js +0 -1
- package/dist/chunk-DX2WEUVJ.js +0 -1
- package/dist/chunk-IBQQA6L3.js +0 -1
- package/dist/chunk-J5W5S2WG.cjs +0 -1
- package/dist/chunk-K2W3NIDO.cjs +0 -1
- package/dist/chunk-LKYOZL7U.cjs +0 -1
- package/dist/chunk-N5LPV5FV.js +0 -1
- package/dist/chunk-QYNJ3CQP.cjs +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 _chunkXNH3I436cjs = require('../../chunk-XNH3I436.cjs');require('../../chunk-LHAOCUXT.cjs');require('../../chunk-QFZSILOI.cjs');require('../../chunk-5GYNNLVW.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, _chunkXNH3I436cjs.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, _chunkXNH3I436cjs.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-HIQJJVCM.js";import"../../chunk-SLPKMZNW.js";import"../../chunk-SI3GYRHH.js";import"../../chunk-TZR7N7VZ.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 _chunkXNH3I436cjs = require('../chunk-XNH3I436.cjs');require('../chunk-LHAOCUXT.cjs');require('../chunk-QFZSILOI.cjs');require('../chunk-5GYNNLVW.cjs');require('../chunk-DSIFRRBS.cjs');exports.ApiClient = _chunkXNH3I436cjs.a;
|
package/dist/api/client.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../chunk-
|
|
1
|
+
import{a}from"../chunk-HIQJJVCM.js";import"../chunk-SLPKMZNW.js";import"../chunk-SI3GYRHH.js";import"../chunk-TZR7N7VZ.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 _chunkXNH3I436cjs = require('../chunk-XNH3I436.cjs');require('../chunk-ECAM5KTH.cjs');require('../chunk-LHAOCUXT.cjs');require('../chunk-QFZSILOI.cjs');require('../chunk-5GYNNLVW.cjs');require('../chunk-DSIFRRBS.cjs');exports.ApiClient = _chunkXNH3I436cjs.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-HIQJJVCM.js";import"../chunk-KBJA7JDT.js";import"../chunk-SLPKMZNW.js";import"../chunk-SI3GYRHH.js";import"../chunk-TZR7N7VZ.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 _chunkKICS3RGFcjs = require('../../chunk-KICS3RGF.cjs');require('../../chunk-TM77X7C3.cjs');require('../../chunk-LHAOCUXT.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-QFZSILOI.cjs');require('../../chunk-5GYNNLVW.cjs');require('../../chunk-DSIFRRBS.cjs');exports.evmChainAdapter = _chunkKICS3RGFcjs.a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-KRODF7KK.js";import"../../chunk-6HB4WO5J.js";import"../../chunk-SLPKMZNW.js";import"../../chunk-455NK5LB.js";import"../../chunk-SI3GYRHH.js";import"../../chunk-TZR7N7VZ.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 _chunkUWQ6UZGEcjs = require('../../chunk-UWQ6UZGE.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-QFZSILOI.cjs');require('../../chunk-5GYNNLVW.cjs');require('../../chunk-DSIFRRBS.cjs');exports.solanaChainAdapter = _chunkUWQ6UZGEcjs.a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-MMIBGH44.js";import"../../chunk-455NK5LB.js";import"../../chunk-SI3GYRHH.js";import"../../chunk-TZR7N7VZ.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 _chunkVGDORB2Lcjs = require('../../chunk-VGDORB2L.cjs');require('../../chunk-CCIGWTAO.cjs');require('../../chunk-QFZSILOI.cjs');require('../../chunk-5GYNNLVW.cjs');require('../../chunk-DSIFRRBS.cjs');exports.stellarChainAdapter = _chunkVGDORB2Lcjs.a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"../../chunk-
|
|
1
|
+
import{a}from"../../chunk-IX4WR4RQ.js";import"../../chunk-455NK5LB.js";import"../../chunk-SI3GYRHH.js";import"../../chunk-TZR7N7VZ.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 _chunkWFWX6G26cjs = require('../chunk-WFWX6G26.cjs');require('../chunk-KICS3RGF.cjs');require('../chunk-UWQ6UZGE.cjs');require('../chunk-VGDORB2L.cjs');require('../chunk-TM77X7C3.cjs');require('../chunk-ENU3EKBG.cjs');require('../chunk-LHAOCUXT.cjs');require('../chunk-CCIGWTAO.cjs');require('../chunk-QFZSILOI.cjs');require('../chunk-5GYNNLVW.cjs');require('../chunk-DSIFRRBS.cjs');exports.getChainAdapter = _chunkWFWX6G26cjs.a; exports.isSupportedChainType = _chunkWFWX6G26cjs.b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b}from"../chunk-
|
|
1
|
+
import{a,b}from"../chunk-5RW5KBQT.js";import"../chunk-KRODF7KK.js";import"../chunk-MMIBGH44.js";import"../chunk-IX4WR4RQ.js";import"../chunk-6HB4WO5J.js";import"../chunk-OQZTL6ZG.js";import"../chunk-SLPKMZNW.js";import"../chunk-455NK5LB.js";import"../chunk-SI3GYRHH.js";import"../chunk-TZR7N7VZ.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 _chunkWKHVIEB2cjs = require('../chunk-WKHVIEB2.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-QFZSILOI.cjs');require('../chunk-5GYNNLVW.cjs');require('../chunk-DSIFRRBS.cjs');exports.isMainnetChain = _chunkWKHVIEB2cjs.c; exports.isTestnetChain = _chunkWKHVIEB2cjs.b; exports.isValidChain = _chunkWKHVIEB2cjs.e; exports.mainnetToTestnet = _chunkWKHVIEB2cjs.d; exports.toViemChain = _chunkWKHVIEB2cjs.a; exports.validateChainForEnvironment = _chunkWKHVIEB2cjs.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-KRBTB7ZD.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-SI3GYRHH.js";import"../chunk-TZR7N7VZ.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 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-
|
|
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-SI3GYRHH.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};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as le}from"./chunk-MSG2HGUJ.js";import{a as ce,b as ge}from"./chunk-THDXNOZG.js";import{a as oe}from"./chunk-S5VWQSTF.js";import{a as se}from"./chunk-QQYB76KH.js";import{a as ie}from"./chunk-OMTJMVSG.js";import{a as I}from"./chunk-E2GL7NJM.js";import{a as $}from"./chunk-PJKTUGX2.js";import{a as ne,b as ae}from"./chunk-VMXMHGSE.js";import{a as te}from"./chunk-DPU7ZDOR.js";import{f as _}from"./chunk-DCKFFFPG.js";import{a as ee,b as re}from"./chunk-5RW5KBQT.js";import{b as Z}from"./chunk-6HB4WO5J.js";import{f as Y}from"./chunk-KRBTB7ZD.js";import{E as X,H as k,d as U,e as H,j as J,l as j,m as q,u as B,v as V,x as z,y as K,z as Q}from"./chunk-SLPKMZNW.js";import{a}from"./chunk-SI3GYRHH.js";import{a as f,b as D,c as b,d as i,e as m,f as A,g as O,h as o}from"./chunk-NU7VF7MC.js";import{WithLoggerContext as W}from"@crossmint/common-sdk-base";var L,c,R,P,l,S,E,N,F,x,de,pe,G,T=class{constructor(e,r){m(this,x);m(this,L);m(this,c);m(this,R);m(this,P);m(this,l);m(this,S);m(this,E,[]);m(this,N);m(this,F,null);let{chain:t,address:n,owner:s,options:h,alias:u,recovery:d,apiRecoveryServerSignerAddress:g,apiDelegatedServerSignerAddresses:p,signers:w,signer:v}=e;A(this,c,r),this.chain=t,this.address=n,this.owner=s,A(this,L,h),this.alias=u;let C=null;g!=null?C=g:d.type==="server"&&_(d)&&(C=d.address),A(this,E,p!=null?p:[]),A(this,R,w!=null?w:[]),A(this,P,new ie({chain:t,projectId:i(this,c).projectId,environment:i(this,c).environment,apiRecoveryAddress:C,apiDelegatedAddresses:i(this,E),knownOnChainAddresses:()=>[...i(this,R).filter(y=>y.type==="server"&&_(y)).map(y=>y.address),...i(this,E)]})),A(this,l,new oe({apiClient:r,options:h,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:i(this,P),recovery:d,initialSigners:i(this,R),signers:()=>this.signers(),signer:v})),A(this,S,new le({chain:t,walletAddress:this.address,options:h,signerManager:i(this,l),serverSignerResolver:i(this,P),signers:()=>this.signers(),addSigner:y=>this.addSigner(y),approveSignature:y=>this.approveSignatureAndWait(y),approveTransaction:y=>this.approveTransactionAndWait(y)})),A(this,N,this.initDefaultSigner())}get signer(){return i(this,l).activeSigner}waitForInit(){return o(this,null,function*(){yield i(this,N)})}initDefaultSigner(){return o(this,null,function*(){if(i(this,l).activeSigner!=null||(yield i(this,S).initDeviceSigner(),i(this,l).activeSigner!=null||i(this,S).needsRecovery))return;let e=i(this,R).length===0?i(this,l).recovery:i(this,R).length===1?i(this,R)[0]:null;if(e==null)return;let r=I(e.type),t=i(this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===i(this,l).recovery;try{let s=r.buildInternalConfig(e,t);i(this,l).setActiveSigner(yield i(this,l).assemble(s,{isAdminSigner:n}))}catch(s){a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:i(this,l).recovery.type,signerCount:i(this,R).length,error:s})}})}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,R)}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,L)}get chainAdapter(){return ee(this.chain)}resolveServerSignerApiLocator(e){return i(this,P).apiLocator(e)}get recovery(){return i(this,l).recovery}balances(e){return o(this,null,function*(){a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],s=yield i(this,c).getBalance(this.address,{chains:[r],tokens:n});if("error"in s)throw a.error("wallet.balances.error",{error:s}),new Error(`Failed to get balances for wallet: ${JSON.stringify(s.message)}`);return a.info("wallet.balances.success"),se(s,this.chain,t,e)})}stagingFund(e,r){return o(this,null,function*(){a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return a.info("wallet.stagingFund.success"),t})}nfts(e){return o(this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield i(this,c).getNfts(D(f({},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw a.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 s=Number(t);if(Number.isNaN(s)||!Number.isFinite(s)||s<=0)throw new z(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let h=ne(e),u=this.resolveChainForEnvironment(),d=ae(r,u);a.info("wallet.send.start",f({recipient:h,token:d,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let g=i(this,l).require(),p;(n==null?void 0:n.signer)==null?p=g.locator():typeof n.signer=="string"?p=n.signer:p=this.resolveServerSignerApiLocator(n.signer);let w=f({recipient:h,amount:t,signer:p},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),v=yield i(this,c).send(this.walletLocator,d,w);if("message"in v)throw a.error("wallet.send.error",{error:v}),new K(`Failed to send token: ${JSON.stringify(v.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return a.info("wallet.send.prepared",{transactionId:v.id}),{hash:void 0,explorerLink:void 0,transactionId:v.id};let C=yield this.approveTransactionAndWait(v.id);return a.info("wallet.send.success",{transactionId:v.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(a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return o(this,null,function*(){a.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 v;let n=typeof t=="string"?t:$(t),s=yield i(this,l).getSignerState(n);if(s.signer!=null){if(i(this,l).isApprovedSignerStatus(s.signer.status))return(r==null?void 0:r.scopes)!=null&&a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:n}),a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(s.signer,null,r);if(s.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 a.info("wallet.addSigner.resuming",{operationType:s.pendingOperation.type,operationId:s.pendingOperation.id}),this.completeSignerRegistration(s.signer,s.pendingOperation,r)}}let h=typeof t=="string"?t:I(t.type).addSignerPayload(t,i(this,l).descriptorContext()),d=this.chain!=="solana"&&this.chain!=="stellar"?(v=r==null?void 0:r.deployImmediately)!=null?v:!0:void 0,g=yield i(this,c).registerSigner(this.walletLocator,f(f({signer:h,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),d!=null&&{deployImmediately:d}));if("error"in g)throw a.error("wallet.addSigner.error",{error:g}),g.code===j?new q(g.message):new J(`Failed to register signer: ${JSON.stringify(g.message)}`);let p=Z(g,this.chain);if(p==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let w=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:n,type:e.type});return this.completeSignerRegistration(p,w,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 a.info("wallet.addSigner.prepared",n),f(f({},e),n)}case"signature":{let n={signatureId:r.id};return a.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),a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else a.info("wallet.addSigner.success");return D(f({},e),{status:"success"})})}removeSigner(e,r){return o(this,null,function*(){let t=this.resolveSignerLocator(e);return a.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 a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let s=n.id;return r!=null&&r.prepareOnly?(a.info("wallet.removeSigner.prepared",{transactionId:s}),{transactionId:s,status:void 0}):(yield this.approveTransactionAndWait(s),a.info("wallet.removeSigner.success",{transactionId:s}),{transactionId:s,status:"success"})}))})}useSigner(e){return o(this,null,function*(){a.info("wallet.useSigner.start"),e.type==="server"&&i(this,P).resetDelegatedCache(),I(e.type).validateConfig(e);let r=!1;e.type==="device"?yield i(this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=I(e.type).buildInternalConfig(e,i(this,l).descriptorContext()),n=$(e);i(this,l).setActiveSigner(yield i(this,l).assemble(t,{isAdminSigner:r})),a.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,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return i(this,S).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,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return i(this,S).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(s=>s.locator),n=i(this,P).resolveForUseSigner(e,t,()=>this.isRecoverySigner(e));switch(n.kind){case"delegated":return i(this,S).onSignerSelected(),!1;case"recovery":return i(this,l).stripSecretFromRecovery(),i(this,S).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):$(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,S).needsRecovery}recover(){return o(this,null,function*(){yield i(this,S).recover()})}signers(){return o(this,null,function*(){var s,h;a.info("wallet.signers.start");let e=yield i(this,c).getWallet(this.walletLocator);if("error"in e)throw a.error("wallet.signers.error",{error:e}),new H(JSON.stringify(e));if(!Se(e)){let u=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw a.error("wallet.signers.error",{error:u}),new U(u)}let r=(h=(s=e==null?void 0:e.config)==null?void 0:s.delegatedSigners)!=null?h:[],n=(yield Promise.all(r.map(u=>o(this,null,function*(){try{return(yield i(this,l).getSignerState(u.locator)).signer}catch(d){return a.warn("wallet.signers.mapSigner.failed",{locator:u.locator,error:d}),null}})))).filter(u=>u!=null);return a.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,N),i(this,F)==null&&A(this,F,this.recover());try{yield i(this,F)}finally{A(this,F,null)}let e=i(this,l).require();e instanceof te&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=i(this,l).recovery;if(r==null||r.type!==e.type)return!1;let t=I(e.type);return t.matchesRecovery(e,r,i(this,l).descriptorContext())?(t.adoptsRecoveryConfigOnMatch&&i(this,l).adoptRecoveryConfig(e),!0):!1}resolveChainForEnvironment(){let e=Y(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 d,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 k(n),new B(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let p=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,p)}let s=(d=n.approvals)==null?void 0:d.pending;if(s==null||s.length===0)return n;let h=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],t],u=yield O(this,x,G).call(this,s,h,(p,w)=>p.signMessage(w.message));return yield this.executeApproveSignatureWithErrorHandling(e,u)})}approveTransactionInternal(e,r){return o(this,null,function*(){var d,g,p,w,v;let t=yield i(this,c).getTransaction(this.walletLocator,e);if("error"in t)throw k(t),new Q(JSON.stringify(t));yield(p=(g=(d=i(this,L))==null?void 0:d.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:p.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 s=(w=t.approvals)==null?void 0:w.pending;if(s==null||s.length===0)return t;let h=[...(v=r==null?void 0:r.additionalSigners)!=null?v:[],n],u=yield O(this,x,G).call(this,s,h,(C,y)=>{let he=C.type==="device",ue=t.chainType==="solana"&&"transaction"in t.onChain&&!he?t.onChain.transaction:y.message;return C.signTransaction(ue)});return yield this.executeApproveTransactionWithErrorHandling(e,u)})}executeApproveTransactionWithErrorHandling(e,r){return o(this,null,function*(){a.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 k(t),new X(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 k(t),new V(JSON.stringify(t));return t})}waitForSignature(e){return o(this,null,function*(){return yield ge(i(this,c),this.walletLocator,e)})}waitForTransaction(n){return o(this,arguments,function*(e,r=6e4,t={}){return yield ce(i(this,c),this.walletLocator,e,f({timeoutMs:r},t))})}sleep(e){return o(this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};L=new WeakMap,c=new WeakMap,R=new WeakMap,P=new WeakMap,l=new WeakMap,S=new WeakMap,E=new WeakMap,N=new WeakMap,F=new WeakMap,x=new WeakSet,de=function(e){return o(this,null,function*(){let r=yield i(this,S).tryResolveLocallyAvailableSigner(e);return r!=null&&a.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},pe=function(e,r){return o(this,null,function*(){var n;let t=e.find(s=>s.locator()===r);if(t==null&&(t=(n=yield O(this,x,de).call(this,r))!=null?n:void 0),t==null)throw new J(`Signer ${r} not found in pending approvals`);return t})},G=function(e,r,t){return o(this,null,function*(){return yield Promise.all(e.map(n=>o(this,null,function*(){let s=yield O(this,x,pe).call(this,r,n.signer.locator),h=yield t(s,n);return D(f({},h),{signer:s.locator()})})))})},b([W({logger:a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"balances",1),b([W({logger:a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"stagingFund",1),b([W({logger:a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"send",1),b([W({logger:a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"approve",1),b([W({logger:a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"addSigner",1),b([W({logger:a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"removeSigner",1),b([W({logger:a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"useSigner",1),b([W({logger:a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"recover",1),b([W({logger:a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"signers",1);function Se(M){return M.type==="smart"&&re(M.chainType)}export{T as a};
|
|
@@ -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 _chunkQFZSILOIcjs = require('./chunk-QFZSILOI.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*(){_chunkQFZSILOIcjs.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");_chunkQFZSILOIcjs.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 */ }`);_chunkQFZSILOIcjs.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 _chunkQFZSILOIcjs.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(_chunkQFZSILOIcjs.a.info("get-status: response received",{signerStatus:e.signerStatus,durationMs:n}),e.signerStatus==="ready"){this._needsAuth=!1;return}else this._needsAuth=!0;_chunkQFZSILOIcjs.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*(){_chunkQFZSILOIcjs.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){_chunkQFZSILOIcjs.a.error("handleAuthRequired error",{error:c}),a(c)}try{yield s}catch(c){throw _chunkQFZSILOIcjs.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();_chunkQFZSILOIcjs.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,_chunkQFZSILOIcjs.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 _chunkQFZSILOIcjs.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();_chunkQFZSILOIcjs.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}),_chunkQFZSILOIcjs.a.info("complete-onboarding: response received",{status:t==null?void 0:t.status,durationMs:Date.now()-d})}catch(a){return _chunkQFZSILOIcjs.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}_chunkQFZSILOIcjs.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){_chunkQFZSILOIcjs.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 _chunkQFZSILOIcjs.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:_chunkQFZSILOIcjs.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 _chunkIP6YYDHRcjs = require('./chunk-IP6YYDHR.cjs');var _chunkUZN6B2NVcjs = require('./chunk-UZN6B2NV.cjs');var _chunk5ARUTNXLcjs = require('./chunk-5ARUTNXL.cjs');var _chunkX6FEF7IRcjs = require('./chunk-X6FEF7IR.cjs');var _chunkI3H3U7XWcjs = require('./chunk-I3H3U7XW.cjs');var _chunkTVD45ZZMcjs = require('./chunk-TVD45ZZM.cjs');var _chunkEXOY4ZCVcjs = require('./chunk-EXOY4ZCV.cjs');var _chunkEOXMCIRYcjs = require('./chunk-EOXMCIRY.cjs');var _chunk3V7BHEQDcjs = require('./chunk-3V7BHEQD.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkWFWX6G26cjs = require('./chunk-WFWX6G26.cjs');var _chunkTM77X7C3cjs = require('./chunk-TM77X7C3.cjs');var _chunkWKHVIEB2cjs = require('./chunk-WKHVIEB2.cjs');var _chunkLHAOCUXTcjs = require('./chunk-LHAOCUXT.cjs');var _chunkQFZSILOIcjs = require('./chunk-QFZSILOI.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _commonsdkbase = require('@crossmint/common-sdk-base');var L,c,R,P,l,S,E,N,F,x,de,pe,G,T= exports.a =class{constructor(e,r){_chunkDSIFRRBScjs.e.call(void 0, this,x);_chunkDSIFRRBScjs.e.call(void 0, this,L);_chunkDSIFRRBScjs.e.call(void 0, this,c);_chunkDSIFRRBScjs.e.call(void 0, this,R);_chunkDSIFRRBScjs.e.call(void 0, this,P);_chunkDSIFRRBScjs.e.call(void 0, this,l);_chunkDSIFRRBScjs.e.call(void 0, this,S);_chunkDSIFRRBScjs.e.call(void 0, this,E,[]);_chunkDSIFRRBScjs.e.call(void 0, this,N);_chunkDSIFRRBScjs.e.call(void 0, this,F,null);let{chain:t,address:n,owner:s,options:h,alias:u,recovery:d,apiRecoveryServerSignerAddress:g,apiDelegatedServerSignerAddresses:p,signers:w,signer:v}=e;_chunkDSIFRRBScjs.f.call(void 0, this,c,r),this.chain=t,this.address=n,this.owner=s,_chunkDSIFRRBScjs.f.call(void 0, this,L,h),this.alias=u;let C=null;g!=null?C=g:d.type==="server"&&_chunkQPCZFIUVcjs.f.call(void 0, d)&&(C=d.address),_chunkDSIFRRBScjs.f.call(void 0, this,E,p!=null?p:[]),_chunkDSIFRRBScjs.f.call(void 0, this,R,w!=null?w:[]),_chunkDSIFRRBScjs.f.call(void 0, this,P,new (0, _chunkI3H3U7XWcjs.a)({chain:t,projectId:_chunkDSIFRRBScjs.d.call(void 0, this,c).projectId,environment:_chunkDSIFRRBScjs.d.call(void 0, this,c).environment,apiRecoveryAddress:C,apiDelegatedAddresses:_chunkDSIFRRBScjs.d.call(void 0, this,E),knownOnChainAddresses:()=>[..._chunkDSIFRRBScjs.d.call(void 0, this,R).filter(y=>y.type==="server"&&_chunkQPCZFIUVcjs.f.call(void 0, y)).map(y=>y.address),..._chunkDSIFRRBScjs.d.call(void 0, this,E)]})),_chunkDSIFRRBScjs.f.call(void 0, this,l,new (0, _chunk5ARUTNXLcjs.a)({apiClient:r,options:h,chain:t,walletAddress:this.address,walletLocator:()=>this.walletLocator,serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,P),recovery:d,initialSigners:_chunkDSIFRRBScjs.d.call(void 0, this,R),signers:()=>this.signers(),signer:v})),_chunkDSIFRRBScjs.f.call(void 0, this,S,new (0, _chunkIP6YYDHRcjs.a)({chain:t,walletAddress:this.address,options:h,signerManager:_chunkDSIFRRBScjs.d.call(void 0, this,l),serverSignerResolver:_chunkDSIFRRBScjs.d.call(void 0, this,P),signers:()=>this.signers(),addSigner:y=>this.addSigner(y),approveSignature:y=>this.approveSignatureAndWait(y),approveTransaction:y=>this.approveTransactionAndWait(y)})),_chunkDSIFRRBScjs.f.call(void 0, this,N,this.initDefaultSigner())}get signer(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner}waitForInit(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,N)})}initDefaultSigner(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner!=null||(yield _chunkDSIFRRBScjs.d.call(void 0, this,S).initDeviceSigner(),_chunkDSIFRRBScjs.d.call(void 0, this,l).activeSigner!=null||_chunkDSIFRRBScjs.d.call(void 0, this,S).needsRecovery))return;let e=_chunkDSIFRRBScjs.d.call(void 0, this,R).length===0?_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery:_chunkDSIFRRBScjs.d.call(void 0, this,R).length===1?_chunkDSIFRRBScjs.d.call(void 0, this,R)[0]:null;if(e==null)return;let r=_chunkTVD45ZZMcjs.a.call(void 0, e.type),t=_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext();if(!r.canAutoAssemble(e,t))return;let n=e===_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery;try{let s=r.buildInternalConfig(e,t);_chunkDSIFRRBScjs.d.call(void 0, this,l).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).assemble(s,{isAdminSigner:n}))}catch(s){_chunkQFZSILOIcjs.a.warn("wallet.initDefaultSigner.autoAssemblyFailed",{recoveryType:_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery.type,signerCount:_chunkDSIFRRBScjs.d.call(void 0, this,R).length,error:s})}})}static getApiClient(e){return e.apiClient}static getOptions(e){return e.options}static getRecovery(e){return _chunkDSIFRRBScjs.d.call(void 0, e,l).recovery}static getInitialSigners(e){return _chunkDSIFRRBScjs.d.call(void 0, e,R)}static getApiRecoveryServerSignerAddress(e){var r;return(r=_chunkDSIFRRBScjs.d.call(void 0, e,P).apiRecoveryAddress)!=null?r:void 0}static getApiDelegatedServerSignerAddresses(e){return _chunkDSIFRRBScjs.d.call(void 0, e,E)}get apiClient(){return _chunkDSIFRRBScjs.d.call(void 0, this,c)}get options(){return _chunkDSIFRRBScjs.d.call(void 0, this,L)}get chainAdapter(){return _chunkWFWX6G26cjs.a.call(void 0, this.chain)}resolveServerSignerApiLocator(e){return _chunkDSIFRRBScjs.d.call(void 0, this,P).apiLocator(e)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).recovery}balances(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkQFZSILOIcjs.a.info("wallet.balances.start");let r=this.resolveChainForEnvironment(),t=this.chainAdapter.nativeToken,n=[t,"usdc",...e!=null?e:[]],s=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getBalance(this.address,{chains:[r],tokens:n});if("error"in s)throw _chunkQFZSILOIcjs.a.error("wallet.balances.error",{error:s}),new Error(`Failed to get balances for wallet: ${JSON.stringify(s.message)}`);return _chunkQFZSILOIcjs.a.info("wallet.balances.success"),_chunkX6FEF7IRcjs.a.call(void 0, s,this.chain,t,e)})}stagingFund(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkQFZSILOIcjs.a.info("wallet.stagingFund.start",{amount:e,chain:r!=null?r:this.chain});let t=yield this.apiClient.fundWallet(this.address,{amount:e,token:"usdxm",chain:r!=null?r:this.chain});if("error"in t)throw _chunkQFZSILOIcjs.a.error("wallet.stagingFund.error",{error:t}),new Error(`Failed to fund wallet: ${JSON.stringify(t.message)}`);return _chunkQFZSILOIcjs.a.info("wallet.stagingFund.success"),t})}nfts(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getNfts(_chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{chain:r,address:this.address}));if(t!=null&&typeof t=="object"&&"error"in t)throw _chunkQFZSILOIcjs.a.error("wallet.nfts.error",{error:t}),new Error(`Failed to get nfts: ${JSON.stringify(t.message)}`);return t})}transactions(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let e=yield _chunkDSIFRRBScjs.d.call(void 0, 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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, 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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=this.resolveChainForEnvironment(),t=yield this.apiClient.getTransfers(this.walletLocator,{chain:r,tokens:e.tokens,status:e.status});if("error"in t)throw new Error(`Failed to get transfers: ${JSON.stringify(t.message)}`);return t})}send(e,r,t,n){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=Number(t);if(Number.isNaN(s)||!Number.isFinite(s)||s<=0)throw new (0, _chunkLHAOCUXTcjs.x)(`Invalid transfer amount: "${t}". Amount must be a positive number greater than zero.`);let h=_chunkEOXMCIRYcjs.a.call(void 0, e),u=this.resolveChainForEnvironment(),d=_chunkEOXMCIRYcjs.b.call(void 0, r,u);_chunkQFZSILOIcjs.a.info("wallet.send.start",_chunkDSIFRRBScjs.a.call(void 0, {recipient:h,token:d,amount:t},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{})),yield this.preAuthIfNeeded();let g=_chunkDSIFRRBScjs.d.call(void 0, this,l).require(),p;(n==null?void 0:n.signer)==null?p=g.locator():typeof n.signer=="string"?p=n.signer:p=this.resolveServerSignerApiLocator(n.signer);let w=_chunkDSIFRRBScjs.a.call(void 0, {recipient:h,amount:t,signer:p},(n==null?void 0:n.transactionType)!=null?{transactionType:n.transactionType}:{}),v=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).send(this.walletLocator,d,w);if("message"in v)throw _chunkQFZSILOIcjs.a.error("wallet.send.error",{error:v}),new (0, _chunkLHAOCUXTcjs.y)(`Failed to send token: ${JSON.stringify(v.message)}`);if((n==null?void 0:n.prepareOnly)===!0)return _chunkQFZSILOIcjs.a.info("wallet.send.prepared",{transactionId:v.id}),{hash:void 0,explorerLink:void 0,transactionId:v.id};let C=yield this.approveTransactionAndWait(v.id);return _chunkQFZSILOIcjs.a.info("wallet.send.success",{transactionId:v.id,hash:C.hash}),C})}approveTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return console.warn("approveTransaction is deprecated. Use approve instead. This method will be removed in the next major version."),yield this.approve(e)})}approve(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(_chunkQFZSILOIcjs.a.info("wallet.approve.start",{transactionId:e.transactionId,signatureId:e.signatureId}),yield this.preAuthIfNeeded(),e.transactionId!=null){let r=yield this.approveTransactionAndWait(e.transactionId,e.options);return _chunkQFZSILOIcjs.a.info("wallet.approve.success",{transactionId:e.transactionId}),r}if(e.signatureId!=null){let r=yield this.approveSignatureAndWait(e.signatureId,e.options);return _chunkQFZSILOIcjs.a.info("wallet.approve.success",{signatureId:e.signatureId}),r}throw _chunkQFZSILOIcjs.a.error("wallet.approve.error",{error:"Either transactionId or signatureId must be provided"}),new Error("Either transactionId or signatureId must be provided")})}addSigner(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkQFZSILOIcjs.a.info("wallet.addSigner.start");let t=typeof e=="object"&&"type"in e&&e.type==="server"?this.resolveServerSignerApiLocator(e):e;return _chunkDSIFRRBScjs.d.call(void 0, this,l).withRecoverySigner(()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var v;let n=typeof t=="string"?t:_chunkEXOY4ZCVcjs.a.call(void 0, t),s=yield _chunkDSIFRRBScjs.d.call(void 0, this,l).getSignerState(n);if(s.signer!=null){if(_chunkDSIFRRBScjs.d.call(void 0, this,l).isApprovedSignerStatus(s.signer.status))return(r==null?void 0:r.scopes)!=null&&_chunkQFZSILOIcjs.a.warn("wallet.addSigner.scopesIgnored",{reason:"signer already approved",signerLocator:n}),_chunkQFZSILOIcjs.a.info("wallet.addSigner.alreadyApproved"),this.completeSignerRegistration(s.signer,null,r);if(s.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 _chunkQFZSILOIcjs.a.info("wallet.addSigner.resuming",{operationType:s.pendingOperation.type,operationId:s.pendingOperation.id}),this.completeSignerRegistration(s.signer,s.pendingOperation,r)}}let h=typeof t=="string"?t:_chunkTVD45ZZMcjs.a.call(void 0, t.type).addSignerPayload(t,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext()),d=this.chain!=="solana"&&this.chain!=="stellar"?(v=r==null?void 0:r.deployImmediately)!=null?v:!0:void 0,g=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).registerSigner(this.walletLocator,_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {signer:h,chain:this.chainAdapter.addSignerChain(this.chain)},(r==null?void 0:r.scopes)!=null&&{scopes:r.scopes}),d!=null&&{deployImmediately:d}));if("error"in g)throw _chunkQFZSILOIcjs.a.error("wallet.addSigner.error",{error:g}),g.code===_chunkLHAOCUXTcjs.l?new (0, _chunkLHAOCUXTcjs.m)(g.message):new (0, _chunkLHAOCUXTcjs.j)(`Failed to register signer: ${JSON.stringify(g.message)}`);let p=_chunkTM77X7C3cjs.b.call(void 0, g,this.chain);if(p==null)throw new Error(`No approval found for chain ${this.chain} in register signer response`);let w=this.chainAdapter.extractAddSignerOperation(g,this.chain,{locator:n,type:e.type});return this.completeSignerRegistration(p,w,r)}))})}completeSignerRegistration(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(t!=null&&t.prepareOnly){if(r==null)return _chunkDSIFRRBScjs.a.call(void 0, {},e);switch(r.type){case"transaction":{let n={transactionId:r.id};return _chunkQFZSILOIcjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}case"signature":{let n={signatureId:r.id};return _chunkQFZSILOIcjs.a.info("wallet.addSigner.prepared",n),_chunkDSIFRRBScjs.a.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),n)}default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}}if(r!=null)switch(r.type){case"transaction":yield this.approveTransactionAndWait(r.id),_chunkQFZSILOIcjs.a.info("wallet.addSigner.success",{transactionId:r.id});break;case"signature":yield this.approveSignatureAndWait(r.id),_chunkQFZSILOIcjs.a.info("wallet.addSigner.success",{signatureId:r.id});break;default:{let n=r.type;throw new Error(`Unknown pending operation type: ${n}`)}}else _chunkQFZSILOIcjs.a.info("wallet.addSigner.success");return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},e),{status:"success"})})}removeSigner(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=this.resolveSignerLocator(e);return _chunkQFZSILOIcjs.a.info("wallet.removeSigner.start",{signerLocator:t}),_chunkDSIFRRBScjs.d.call(void 0, this,l).withRecoverySigner(()=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let n=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).removeSigner(this.walletLocator,t,{chain:this.chainAdapter.addSignerChain(this.chain)});if("error"in n)throw _chunkQFZSILOIcjs.a.error("wallet.removeSigner.error",{error:n}),new Error(`Failed to remove signer: ${JSON.stringify(n)}`);let s=n.id;return r!=null&&r.prepareOnly?(_chunkQFZSILOIcjs.a.info("wallet.removeSigner.prepared",{transactionId:s}),{transactionId:s,status:void 0}):(yield this.approveTransactionAndWait(s),_chunkQFZSILOIcjs.a.info("wallet.removeSigner.success",{transactionId:s}),{transactionId:s,status:"success"})}))})}useSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkQFZSILOIcjs.a.info("wallet.useSigner.start"),e.type==="server"&&_chunkDSIFRRBScjs.d.call(void 0, this,P).resetDelegatedCache(),_chunkTVD45ZZMcjs.a.call(void 0, e.type).validateConfig(e);let r=!1;e.type==="device"?yield _chunkDSIFRRBScjs.d.call(void 0, this,S).resolveAvailability(e):r=yield this.resolveNonDeviceSigner(e);let t=_chunkTVD45ZZMcjs.a.call(void 0, e.type).buildInternalConfig(e,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext()),n=_chunkEXOY4ZCVcjs.a.call(void 0, e);_chunkDSIFRRBScjs.d.call(void 0, this,l).setActiveSigner(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).assemble(t,{isAdminSigner:r})),_chunkQFZSILOIcjs.a.info("wallet.useSigner.success",{signerLocator:n})})}resolveNonDeviceSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(e.type!=="passkey"&&e.type!=="server"&&this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;if(e.type==="passkey"&&this.isPasskeyMissingId(e)&&!(yield this.tryAutoSelectPasskey(e))){if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).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 _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!1;if(this.isRecoverySigner(e))return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;throw new Error(`Signer "${r}" is not registered in this wallet.`)})}resolveServerSigner(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).map(s=>s.locator),n=_chunkDSIFRRBScjs.d.call(void 0, this,P).resolveForUseSigner(e,t,()=>this.isRecoverySigner(e));switch(n.kind){case"delegated":return _chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!1;case"recovery":return _chunkDSIFRRBScjs.d.call(void 0, this,l).stripSecretFromRecovery(),_chunkDSIFRRBScjs.d.call(void 0, this,S).onSignerSelected(),!0;case"unregistered":throw new Error(n.message)}})}tryAutoSelectPasskey(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=(yield this.signers()).filter(n=>n.type==="passkey");if(t.length===0)return!1;if(t.length>1)throw new Error('Multiple passkey signers are registered on this wallet. Please specify the credential id: wallet.useSigner({ type: "passkey", id: "<credential-id>" })');return e.id=t[0].locator.replace("passkey:",""),!0})}resolveSignerLocator(e){return e.type==="server"?this.resolveServerSignerApiLocator(e):_chunkEXOY4ZCVcjs.a.call(void 0, e)}isPasskeyMissingId(e){return e.id==null||e.id===""}signerIsRegistered(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).signerIsRegistered(e)})}isSignerApproved(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return _chunkDSIFRRBScjs.d.call(void 0, this,l).isSignerApproved(e)})}needsRecovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,S).needsRecovery}recover(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,S).recover()})}signers(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var s,h;_chunkQFZSILOIcjs.a.info("wallet.signers.start");let e=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getWallet(this.walletLocator);if("error"in e)throw _chunkQFZSILOIcjs.a.error("wallet.signers.error",{error:e}),new (0, _chunkLHAOCUXTcjs.e)(JSON.stringify(e));if(!Se(e)){let u=e.type!=="smart"?`Wallet type ${e.type} not supported`:`Wallet chain type ${e.chainType} not supported`;throw _chunkQFZSILOIcjs.a.error("wallet.signers.error",{error:u}),new (0, _chunkLHAOCUXTcjs.d)(u)}let r=(h=(s=e==null?void 0:e.config)==null?void 0:s.delegatedSigners)!=null?h:[],n=(yield Promise.all(r.map(u=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){try{return(yield _chunkDSIFRRBScjs.d.call(void 0, this,l).getSignerState(u.locator)).signer}catch(d){return _chunkQFZSILOIcjs.a.warn("wallet.signers.mapSigner.failed",{locator:u.locator,error:d}),null}})))).filter(u=>u!=null);return _chunkQFZSILOIcjs.a.info("wallet.signers.success",{count:n.length}),n})}get walletLocator(){if(_chunkDSIFRRBScjs.d.call(void 0, this,c).isServerSide)return this.address;{let e=this.chainAdapter.walletLocatorPrefix,r=this.alias!=null?`:alias:${this.alias}`:"";return e+r}}get signerManager(){return _chunkDSIFRRBScjs.d.call(void 0, this,l)}preAuthIfNeeded(){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){yield _chunkDSIFRRBScjs.d.call(void 0, this,N),_chunkDSIFRRBScjs.d.call(void 0, this,F)==null&&_chunkDSIFRRBScjs.f.call(void 0, this,F,this.recover());try{yield _chunkDSIFRRBScjs.d.call(void 0, this,F)}finally{_chunkDSIFRRBScjs.f.call(void 0, this,F,null)}let e=_chunkDSIFRRBScjs.d.call(void 0, this,l).require();e instanceof _chunk3V7BHEQDcjs.a&&(yield e.ensureAuthenticated())})}isRecoverySigner(e){let r=_chunkDSIFRRBScjs.d.call(void 0, this,l).recovery;if(r==null||r.type!==e.type)return!1;let t=_chunkTVD45ZZMcjs.a.call(void 0, e.type);return t.matchesRecovery(e,r,_chunkDSIFRRBScjs.d.call(void 0, this,l).descriptorContext())?(t.adoptsRecoveryConfigOnMatch&&_chunkDSIFRRBScjs.d.call(void 0, this,l).adoptRecoveryConfig(e),!0):!1}resolveChainForEnvironment(){let e=_chunkWKHVIEB2cjs.f.call(void 0, this.chain,_chunkDSIFRRBScjs.d.call(void 0, this,c).environment);return e!==this.chain&&(this.chain=e),this.chain}approveTransactionAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.approveTransactionInternal(e,r),yield this.sleep(1e3),yield this.waitForTransaction(e)})}approveSignatureAndWait(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield this.approveSignatureInternal(e,r);return!("error"in t)&&t.status==="success"&&t.outputSignature!=null?{signature:t.outputSignature,signatureId:e}:(yield this.sleep(1e3),yield this.waitForSignature(e))})}approveSignatureInternal(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d,g;if(!this.chainAdapter.supportsSignatures)throw new Error("Approving signatures is only supported for EVM smart wallets");let t=_chunkDSIFRRBScjs.d.call(void 0, this,l).require(),n=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getSignature(this.walletLocator,e);if("error"in n)throw _chunkLHAOCUXTcjs.H.call(void 0, n),new (0, _chunkLHAOCUXTcjs.u)(JSON.stringify(n));if(t.type==="api-key")return n;if((r==null?void 0:r.approval)!=null){let p=[r.approval];return yield this.executeApproveSignatureWithErrorHandling(e,p)}let s=(d=n.approvals)==null?void 0:d.pending;if(s==null||s.length===0)return n;let h=[...(g=r==null?void 0:r.additionalSigners)!=null?g:[],t],u=yield _chunkDSIFRRBScjs.g.call(void 0, this,x,G).call(this,s,h,(p,w)=>p.signMessage(w.message));return yield this.executeApproveSignatureWithErrorHandling(e,u)})}approveTransactionInternal(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var d,g,p,w,v;let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).getTransaction(this.walletLocator,e);if("error"in t)throw _chunkLHAOCUXTcjs.H.call(void 0, t),new (0, _chunkLHAOCUXTcjs.z)(JSON.stringify(t));yield(p=(g=(d=_chunkDSIFRRBScjs.d.call(void 0, this,L))==null?void 0:d.callbacks)==null?void 0:g.onTransactionStart)==null?void 0:p.call(g);let n=_chunkDSIFRRBScjs.d.call(void 0, 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 s=(w=t.approvals)==null?void 0:w.pending;if(s==null||s.length===0)return t;let h=[...(v=r==null?void 0:r.additionalSigners)!=null?v:[],n],u=yield _chunkDSIFRRBScjs.g.call(void 0, this,x,G).call(this,s,h,(C,y)=>{let he=C.type==="device",ue=t.chainType==="solana"&&"transaction"in t.onChain&&!he?t.onChain.transaction:y.message;return C.signTransaction(ue)});return yield this.executeApproveTransactionWithErrorHandling(e,u)})}executeApproveTransactionWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){_chunkQFZSILOIcjs.a.info("wallet.approve: submitting approval to API",{transactionId:e});let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).approveTransaction(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkLHAOCUXTcjs.H.call(void 0, t),new (0, _chunkLHAOCUXTcjs.E)(JSON.stringify(t));return t})}executeApproveSignatureWithErrorHandling(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let t=yield _chunkDSIFRRBScjs.d.call(void 0, this,c).approveSignature(this.walletLocator,e,{approvals:r});if(t.error)throw _chunkLHAOCUXTcjs.H.call(void 0, t),new (0, _chunkLHAOCUXTcjs.v)(JSON.stringify(t));return t})}waitForSignature(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield _chunkUZN6B2NVcjs.b.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,c),this.walletLocator,e)})}waitForTransaction(n){return _chunkDSIFRRBScjs.h.call(void 0, this,arguments,function*(e,r=6e4,t={}){return yield _chunkUZN6B2NVcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,c),this.walletLocator,e,_chunkDSIFRRBScjs.a.call(void 0, {timeoutMs:r},t))})}sleep(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return new Promise(r=>setTimeout(r,e))})}};L=new WeakMap,c=new WeakMap,R=new WeakMap,P=new WeakMap,l=new WeakMap,S=new WeakMap,E=new WeakMap,N=new WeakMap,F=new WeakMap,x=new WeakSet,de=function(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let r=yield _chunkDSIFRRBScjs.d.call(void 0, this,S).tryResolveLocallyAvailableSigner(e);return r!=null&&_chunkQFZSILOIcjs.a.info("wallet.approve.deviceSignerRecoveredViaFallback",{signerLocator:e}),r})},pe=function(e,r){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var n;let t=e.find(s=>s.locator()===r);if(t==null&&(t=(n=yield _chunkDSIFRRBScjs.g.call(void 0, this,x,de).call(this,r))!=null?n:void 0),t==null)throw new (0, _chunkLHAOCUXTcjs.j)(`Signer ${r} not found in pending approvals`);return t})},G=function(e,r,t){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield Promise.all(e.map(n=>_chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){let s=yield _chunkDSIFRRBScjs.g.call(void 0, this,x,pe).call(this,r,n.signer.locator),h=yield t(s,n);return _chunkDSIFRRBScjs.b.call(void 0, _chunkDSIFRRBScjs.a.call(void 0, {},h),{signer:s.locator()})})))})},_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkQFZSILOIcjs.a,methodName:"wallet.balances",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"balances",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkQFZSILOIcjs.a,methodName:"wallet.stagingFund",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"stagingFund",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkQFZSILOIcjs.a,methodName:"wallet.send",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"send",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkQFZSILOIcjs.a,methodName:"wallet.approve",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"approve",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkQFZSILOIcjs.a,methodName:"wallet.addSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"addSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkQFZSILOIcjs.a,methodName:"wallet.removeSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"removeSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkQFZSILOIcjs.a,methodName:"wallet.useSigner",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"useSigner",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkQFZSILOIcjs.a,methodName:"wallet.recover",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"recover",1),_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkQFZSILOIcjs.a,methodName:"wallet.signers",buildContext(e){return{chain:e.chain,address:e.address}}})],T.prototype,"signers",1);function Se(M){return M.type==="smart"&&_chunkWFWX6G26cjs.b.call(void 0, M.chainType)}exports.a = T;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunkTVD45ZZMcjs = require('./chunk-TVD45ZZM.cjs');var _chunkGPV7CQRPcjs = require('./chunk-GPV7CQRP.cjs');var _chunkQPCZFIUVcjs = require('./chunk-QPCZFIUV.cjs');var _chunkTM77X7C3cjs = require('./chunk-TM77X7C3.cjs');var _chunkQFZSILOIcjs = require('./chunk-QFZSILOI.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var a,n,d,l,S,C,u,h,v,y,F= exports.a =class{constructor(e){_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,l);_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,e.apiClient),_chunkDSIFRRBScjs.f.call(void 0, this,l,e.options),_chunkDSIFRRBScjs.f.call(void 0, this,S,e.chain),_chunkDSIFRRBScjs.f.call(void 0, this,C,e.walletAddress),_chunkDSIFRRBScjs.f.call(void 0, this,u,e.walletLocator),_chunkDSIFRRBScjs.f.call(void 0, this,h,e.serverSignerResolver),_chunkDSIFRRBScjs.f.call(void 0, this,n,e.recovery),_chunkDSIFRRBScjs.f.call(void 0, this,v,e.initialSigners),_chunkDSIFRRBScjs.f.call(void 0, this,y,e.signers),_chunkDSIFRRBScjs.f.call(void 0, this,a,e.signer)}get activeSigner(){return _chunkDSIFRRBScjs.d.call(void 0, this,a)}setActiveSigner(e){_chunkDSIFRRBScjs.f.call(void 0, this,a,e)}get recovery(){return _chunkDSIFRRBScjs.d.call(void 0, this,n)}descriptorContext(){var e,i,t,g,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:(e=_chunkDSIFRRBScjs.d.call(void 0, this,l))==null?void 0:e.clientTEEConnection,resetSignerFrame:(i=_chunkDSIFRRBScjs.d.call(void 0, this,l))==null?void 0:i.resetSignerFrame,onAuthRequired:(g=(t=_chunkDSIFRRBScjs.d.call(void 0, this,l))==null?void 0:t.callbacks)==null?void 0:g.onAuthRequired,deviceSignerKeyStorage:(c=_chunkDSIFRRBScjs.d.call(void 0, this,l))==null?void 0:c.deviceSignerKeyStorage,serverSigners:_chunkDSIFRRBScjs.d.call(void 0, this,h)}}adoptRecoveryConfig(e){_chunkDSIFRRBScjs.f.call(void 0, this,n,e)}stripSecretFromRecovery(){let e=_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))&&e!=null&&_chunkDSIFRRBScjs.f.call(void 0, this,n,{type:"server",address:e})}assemble(e,i){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var g,c;let t=_chunkGPV7CQRPcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,S),e,(g=_chunkDSIFRRBScjs.d.call(void 0, this,l))==null?void 0:g.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 e=_chunkTVD45ZZMcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,n).type),i=e.signerUnavailableReason();throw i!=null?new Error(i):e.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(e){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),g=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),g))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),g);_chunkDSIFRRBScjs.f.call(void 0, this,a,_chunkGPV7CQRPcjs.a.call(void 0, _chunkDSIFRRBScjs.d.call(void 0, this,S),c,(f=_chunkDSIFRRBScjs.d.call(void 0, this,l))==null?void 0:f.deviceSignerKeyStorage));try{return yield e()}finally{_chunkDSIFRRBScjs.f.call(void 0, this,a,i)}})}getSignerState(e){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),e)}catch(g){return _chunkQFZSILOIcjs.a.warn("wallet.signers.getSignerState.fetchFailed",{signerLocator:e,error:g}),{response:null,signer:null,pendingOperation:null}}if(i==null||typeof i!="object"||"error"in i)return _chunkQFZSILOIcjs.a.warn("wallet.signers.getSignerState.errorResponse",{signerLocator:e,response:i}),{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(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return(yield _chunkDSIFRRBScjs.d.call(void 0, this,y).call(this)).some(t=>t.locator===e)})}isSignerApproved(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var t;let i=yield this.getSignerState(e);return this.isApprovedSignerStatus((t=i.signer)==null?void 0:t.status)})}isApprovedSignerStatus(e){return e==="success"||e==="active"}};a=new WeakMap,n=new WeakMap,d=new WeakMap,l=new WeakMap,S=new WeakMap,C=new WeakMap,u=new WeakMap,h=new WeakMap,v=new WeakMap,y=new WeakMap;exports.a = F;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var s="@crossmint/wallets-sdk",t="1.10.0";var p="WALLETS_SDK",c= exports.b =t,r= exports.c =s,a= exports.d =200;exports.a = p; exports.b = c; exports.c = r; exports.d = a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-KRODF7KK.js";import{a as r}from"./chunk-MMIBGH44.js";import{a as t}from"./chunk-IX4WR4RQ.js";import{a as n}from"./chunk-OQZTL6ZG.js";var i={evm:a,solana:r,stellar:t};function g(e){return i[n(e)]}function m(e){return Object.prototype.hasOwnProperty.call(i,e)}export{g as a,m as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }var _chunk3VKLU6RHcjs = require('./chunk-3VKLU6RH.cjs');var _chunkD36TJPDFcjs = require('./chunk-D36TJPDF.cjs');var _chunkLHAOCUXTcjs = require('./chunk-LHAOCUXT.cjs');var _chunkQFZSILOIcjs = require('./chunk-QFZSILOI.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);var _commonsdkbase = require('@crossmint/common-sdk-base');var o=class o extends _chunk3VKLU6RHcjs.a{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:_chunk3VKLU6RHcjs.a.getOptions(e),alias:e.alias,recovery:_chunk3VKLU6RHcjs.a.getRecovery(e),apiRecoveryServerSignerAddress:_chunk3VKLU6RHcjs.a.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:_chunk3VKLU6RHcjs.a.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:_chunk3VKLU6RHcjs.a.getInitialSigners(e)},_chunk3VKLU6RHcjs.a.getApiClient(e))}static from(e){if(!_commonsdkbase.isValidSolanaAddress.call(void 0, e.address))throw new Error("Wallet is not a Solana wallet");return new o(e)}sendTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var l,p;_chunkQFZSILOIcjs.a.info("solanaWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let n=yield this.createTransaction(e);if((l=e.options)!=null&&l.prepareOnly)return _chunkQFZSILOIcjs.a.info("solanaWallet.sendTransaction.prepared",{transactionId:n.id}),{hash:void 0,explorerLink:void 0,transactionId:n.id};let i={additionalSigners:(p=e.additionalSigners)==null?void 0:p.map(d=>new (0, _chunkD36TJPDFcjs.a)({type:"external-wallet",address:d.publicKey.toString(),locator:`external-wallet:${d.publicKey.toString()}`,onSign:g=>(g.sign([d]),Promise.resolve(g))}))},a=yield this.approveTransactionAndWait(n.id,i);return _chunkQFZSILOIcjs.a.info("solanaWallet.sendTransaction.success",{transactionId:n.id,hash:a.hash}),a})}createTransaction(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var a;let n;((a=e.options)==null?void 0:a.signer)==null?n=this.signerManager.require().locator():typeof e.options.signer=="string"?n=e.options.signer:n=this.resolveServerSignerApiLocator(e.options.signer);let s;"serializedTransaction"in e?s=e.serializedTransaction:s=_bs582.default.encode(e.transaction.serialize());let i=yield this.apiClient.createTransaction(this.walletLocator,{params:{transaction:s,signer:n}});if("error"in i)throw new (0, _chunkLHAOCUXTcjs.y)(JSON.stringify(i));return i})}};_chunkDSIFRRBScjs.c.call(void 0, [_commonsdkbase.WithLoggerContext.call(void 0, {logger:_chunkQFZSILOIcjs.a,methodName:"solanaWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],o.prototype,"sendTransaction",1);var f=o;exports.a = f;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as S}from"./chunk-SEOBV6KR.js";import{a as s}from"./chunk-YFYV2J4S.js";import{a as l}from"./chunk-PWOSYRP7.js";import{a as o}from"./chunk-Z3YQFRAQ.js";import{a as g}from"./chunk-SRN6KQRK.js";import{a as y}from"./chunk-K7BPGUFU.js";import{a as f}from"./chunk-MN2BGRRJ.js";import{a as C}from"./chunk-FQ5F3VYJ.js";import{a as m}from"./chunk-HAQMNZO5.js";import{a as p}from"./chunk-TMOWGJ5Z.js";import{a as u}from"./chunk-MLROTECD.js";import{g as i}from"./chunk-SLPKMZNW.js";import{h as t}from"./chunk-NU7VF7MC.js";function c(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new l(e):r==="stellar"?new o(e):new s(e);case"api-key":return r==="solana"?new u(e):new C(e);case"external-wallet":return r==="solana"?new g(e):r==="stellar"?new y(e):new m(e);case"server":return S(r,e);case"passkey":return new p(e);case"device":if(n==null)throw new i("Device signer key storage is required for device signers");return new f(e,n)}}function k(r,e,n,a){return t(this,null,function*(){if(!e.startsWith("device:"))return null;let w=e.replace("device:","");return(yield a.hasKey(w))?c(r,{type:"device",locator:e,address:n},a):null})}export{c as a,k as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"./chunk-
|
|
1
|
+
import{a as o}from"./chunk-3MF3O7DM.js";import{a as W}from"./chunk-KRBTB7ZD.js";import{p as l,t as f,y as w}from"./chunk-SLPKMZNW.js";import{a as n}from"./chunk-SI3GYRHH.js";import{c as u,h as p}from"./chunk-NU7VF7MC.js";import{createPublicClient as O,encodeFunctionData as x,http as E}from"viem";import{isValidEvmAddress as A,WithLoggerContext as h}from"@crossmint/common-sdk-base";var c=class c extends o{constructor(e){super({chain:e.chain,address:e.address,owner:e.owner,options:o.getOptions(e),alias:e.alias,recovery:o.getRecovery(e),apiRecoveryServerSignerAddress:o.getApiRecoveryServerSignerAddress(e),apiDelegatedServerSignerAddresses:o.getApiDelegatedServerSignerAddresses(e),signer:e.signer,signers:o.getInitialSigners(e)},o.getApiClient(e))}static from(e){if(!A(e.address))throw new Error("Wallet is not an EVM wallet");return new c(e)}sendTransaction(e){return p(this,null,function*(){var i;n.info("evmWallet.sendTransaction.start"),yield this.preAuthIfNeeded();let t=this.buildTransaction(e),r=yield this.createTransaction(t,e.options);if((i=e.options)!=null&&i.prepareOnly)return n.info("evmWallet.sendTransaction.prepared",{transactionId:r.id}),{hash:void 0,explorerLink:void 0,transactionId:r.id};let a=yield this.approveTransactionAndWait(r.id);return n.info("evmWallet.sendTransaction.success",{transactionId:r.id,hash:a.hash}),a})}signMessage(e){return p(this,null,function*(){var i;n.info("evmWallet.signMessage.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),r=yield this.apiClient.createSignature(this.walletLocator,{type:"message",params:{message:e.message,signer:t.locator(),chain:this.chain}});if("error"in r)throw n.error("evmWallet.signMessage.error",{error:r}),new f(JSON.stringify(r));if((i=e.options)!=null&&i.prepareOnly)return n.info("evmWallet.signMessage.prepared",{signatureId:r.id}),{signature:void 0,signatureId:r.id};let a=yield this.approveSignatureAndWait(r.id);return n.info("evmWallet.signMessage.success",{signatureId:r.id}),a})}signTypedData(e){return p(this,null,function*(){var C;n.info("evmWallet.signTypedData.start"),yield this.preAuthIfNeeded();let t=this.signerManager.require(),{domain:r,message:a,primaryType:i,types:g,chain:T}=e;if(!r||!a||!g||!T)throw n.error("evmWallet.signTypedData.error",{error:"Invalid typed data"}),new l("Invalid typed data");let{name:m,version:v,chainId:S,verifyingContract:I,salt:b}=r;if(!m||!v||!S||!I)throw n.error("evmWallet.signTypedData.error",{error:"Invalid typed data domain"}),new l("Invalid typed data domain");let d=yield this.apiClient.createSignature(this.walletLocator,{type:"typed-data",params:{typedData:{domain:{name:m,version:v,chainId:Number(S),verifyingContract:I,salt:b},message:y(a),primaryType:i,types:g},signer:t.locator(),chain:T}});if("error"in d)throw n.error("evmWallet.signTypedData.error",{error:d}),new f(JSON.stringify(d));if((C=e.options)!=null&&C.prepareOnly)return n.info("evmWallet.signTypedData.prepared",{signatureId:d.id}),{signature:void 0,signatureId:d.id};let D=yield this.approveSignatureAndWait(d.id);return n.info("evmWallet.signTypedData.success",{signatureId:d.id}),D})}getViemClient(e){var t;return O({transport:(t=e==null?void 0:e.transport)!=null?t:E(),chain:W(this.chain)})}createTransaction(e,t){return p(this,null,function*(){let r;(t==null?void 0:t.signer)==null?r=this.signerManager.require().locator():typeof t.signer=="string"?r=t.signer:r=this.resolveServerSignerApiLocator(t.signer);let a=yield this.apiClient.createTransaction(this.walletLocator,{params:{signer:r,chain:this.chain,calls:[e]}});if("error"in a)throw new w(JSON.stringify(a));return a})}buildTransaction(e){var t,r,a,i,g;if("transaction"in e)return{transaction:e.transaction};if(e.abi==null)return{to:e.to,value:(r=(t=e.value)==null?void 0:t.toString())!=null?r:"0",data:(a=e.data)!=null?a:"0x"};if(!e.functionName)throw new Error("Function name is required");return{to:e.to,value:(g=(i=e.value)==null?void 0:i.toString())!=null?g:"0",data:x({abi:e.abi,functionName:e.functionName,args:e.args})}}};u([h({logger:n,methodName:"evmWallet.sendTransaction",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"sendTransaction",1),u([h({logger:n,methodName:"evmWallet.signMessage",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signMessage",1),u([h({logger:n,methodName:"evmWallet.signTypedData",buildContext(e){return{chain:e.chain,address:e.address}}})],c.prototype,"signTypedData",1);var M=c;function y(s){return typeof s=="bigint"?s.toString():Array.isArray(s)?s.map(y):s!==null&&typeof s=="object"?Object.fromEntries(Object.entries(s).map(([e,t])=>[e,y(t)])):s}export{M 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-SI3GYRHH.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
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var _chunk3V7BHEQDcjs = require('./chunk-3V7BHEQD.cjs');var _chunkQFZSILOIcjs = require('./chunk-QFZSILOI.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');var _ox = require('ox');var _viem = require('viem');var c=class p extends _chunk3V7BHEQDcjs.a{constructor(e){super(e)}signMessage(e){return _chunkDSIFRRBScjs.h.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 _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){return yield this.sign(e)})}sign(e){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){var o;yield this.handleAuthRequired();let i=this.getJwtOrThrow(),r=e.replace("0x","");_chunkQFZSILOIcjs.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:_chunk3V7BHEQDcjs.b});if(_chunkQFZSILOIcjs.a.info("sign: response received",{status:n==null?void 0:n.status,durationMs:Date.now()-y}),(n==null?void 0:n.status)==="error")throw new Error(n.error);if((n==null?void 0:n.signature)==null)throw new Error("Failed to sign transaction");return p.verifyPublicKeyFormat(n.publicKey),{signature:n.signature.bytes}})}static verifyPublicKeyFormat(e){if(e==null)throw new Error("No public key found");if(e.encoding!=="hex"||e.keyType!=="secp256k1"||e.bytes==null)throw new Error("Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: "+JSON.stringify(e))}getChainKeyParams(){return{scheme:"secp256k1",encoding:"hex"}}};exports.a = c;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as n}from"./chunk-
|
|
1
|
+
import{a as n}from"./chunk-W7V3VEMM.js";import{a as s}from"./chunk-5LNDUSMZ.js";import{a as l}from"./chunk-HIQJJVCM.js";import{a,b as i}from"./chunk-SI3GYRHH.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 _chunkKULR5B4Ocjs = require('./chunk-KULR5B4O.cjs');var _chunkF44BTXOFcjs = require('./chunk-F44BTXOF.cjs');var _chunkILD5AY26cjs = require('./chunk-ILD5AY26.cjs');var _chunkLTTMLPVEcjs = require('./chunk-LTTMLPVE.cjs');var _chunkD36TJPDFcjs = require('./chunk-D36TJPDF.cjs');var _chunk5FVDLMWWcjs = require('./chunk-5FVDLMWW.cjs');var _chunkXWQC6G7Ncjs = require('./chunk-XWQC6G7N.cjs');var _chunkR4SBFRTMcjs = require('./chunk-R4SBFRTM.cjs');var _chunkHYWIWJ6Hcjs = require('./chunk-HYWIWJ6H.cjs');var _chunkLMHH6ODXcjs = require('./chunk-LMHH6ODX.cjs');var _chunkCDHMNLZ6cjs = require('./chunk-CDHMNLZ6.cjs');var _chunkLHAOCUXTcjs = require('./chunk-LHAOCUXT.cjs');var _chunkDSIFRRBScjs = require('./chunk-DSIFRRBS.cjs');function c(r,e,n){switch(e.type){case"email":case"phone":return r==="solana"?new (0, _chunkILD5AY26cjs.a)(e):r==="stellar"?new (0, _chunkLTTMLPVEcjs.a)(e):new (0, _chunkF44BTXOFcjs.a)(e);case"api-key":return r==="solana"?new (0, _chunkCDHMNLZ6cjs.a)(e):new (0, _chunkR4SBFRTMcjs.a)(e);case"external-wallet":return r==="solana"?new (0, _chunkD36TJPDFcjs.a)(e):r==="stellar"?new (0, _chunk5FVDLMWWcjs.a)(e):new (0, _chunkHYWIWJ6Hcjs.a)(e);case"server":return _chunkKULR5B4Ocjs.a.call(void 0, r,e);case"passkey":return new (0, _chunkLMHH6ODXcjs.a)(e);case"device":if(n==null)throw new (0, _chunkLHAOCUXTcjs.g)("Device signer key storage is required for device signers");return new (0, _chunkXWQC6G7Ncjs.a)(e,n)}}function b(r,e,n,a){return _chunkDSIFRRBScjs.h.call(void 0, this,null,function*(){if(!e.startsWith("device:"))return null;let w=e.replace("device:","");return(yield a.hasKey(w))?c(r,{type:"device",locator:e,address:n},a):null})}exports.a = c; exports.b = b;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as o}from"./chunk-SLPKMZNW.js";import{a}from"./chunk-
|
|
1
|
+
import{a as o}from"./chunk-SLPKMZNW.js";import{a}from"./chunk-SI3GYRHH.js";import{b as p,c}from"./chunk-TZR7N7VZ.js";import{h as t}from"./chunk-NU7VF7MC.js";import{APIKeyEnvironmentPrefix as d,APIKeyUsageOrigin as g,CrossmintApiClient as P}from"@crossmint/common-sdk-base";var h=class extends P{constructor(e){super(e,{internalConfig:{sdkMetadata:{name:c,version:p}}});this.apiPrefix="api/2025-06-09/wallets";this.unstableApiPrefix="api/unstable/wallets"}createWallet(e){return t(this,null,function*(){let s=this.isServerSide?`${this.apiPrefix}`:`${this.apiPrefix}/me`;a.info("wallets.api.createWallet",{chainType:e.chainType,walletType:e.type});let n=yield(yield this.post(s,{body:JSON.stringify(e),headers:this.headers})).json();return"error"in n?a.error("wallets.api.createWallet.error",{error:n.error,chainType:e.chainType}):"address"in n&&a.info("wallets.api.createWallet.success",{address:n.address,chainType:e.chainType}),n})}getWallet(e){return t(this,null,function*(){a.info("wallets.api.getWallet",{locator:e});let r=yield(yield this.get(`${this.apiPrefix}/${e}`,{headers:this.headers})).json();return"error"in r?a.warn("wallets.api.getWallet.error",{locator:e,error:r.error}):"address"in r&&a.info("wallets.api.getWallet.success",{address:r.address,locator:e}),r})}createTransaction(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveTransaction(e,s,r){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/transactions/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers})).json()})}getTransaction(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions/${s}`,{headers:this.headers})).json()})}createSignature(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signatures`,{body:JSON.stringify(s),headers:this.headers})).json()})}approveSignature(e,s,r){return t(this,null,function*(){let n=yield this.post(`${this.apiPrefix}/${e}/signatures/${s}/approvals`,{body:JSON.stringify(r),headers:this.headers});return n.status===422?this.getSignature(e,s):n.json()})}getSignature(e,s){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/signatures/${s}`,{headers:this.headers})).json()})}getTransactions(e){return t(this,null,function*(){return(yield this.get(`${this.apiPrefix}/${e}/transactions`,{headers:this.headers})).json()})}getNfts(e){return t(this,null,function*(){let s=new URLSearchParams;s.append("page",e.page.toString()),s.append("perPage",e.perPage.toString());let r=`${e.chain}:${e.address}`;return(yield this.get(`${this.apiPrefix}/${r}/nfts?${s.toString()}`,{headers:this.headers})).json()})}getTransfers(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("chain",s.chain.toString()),s.tokens!=null&&r.append("tokens",s.tokens),r.append("status",s.status),(yield this.get(`${this.unstableApiPrefix}/${e}/transfers?${r.toString()}`,{headers:this.headers})).json()})}getBalance(e,s){return t(this,null,function*(){let r=new URLSearchParams;return r.append("tokens",s.tokens.join(",")),r.append("chains",s.chains.join(",")),(yield this.get(`${this.apiPrefix}/${e}/balances?${r.toString()}`,{headers:this.headers})).json()})}fundWallet(e,s){return t(this,null,function*(){if(this.environment===d.PRODUCTION)throw new Error("Funding wallets is only supported in staging environment");return(yield this.post(`api/v1-alpha2/wallets/${e}/balances`,{body:JSON.stringify(s),headers:this.headers})).json()})}registerSigner(e,s){return t(this,null,function*(){return(yield this.post(`${this.apiPrefix}/${e}/signers`,{body:JSON.stringify(s),headers:this.headers})).json()})}removeSigner(e,s,r){return t(this,null,function*(){let n=encodeURIComponent(s),i=new URLSearchParams;r.chain&&i.append("chain",r.chain);let l=`${this.apiPrefix}/${e}/signers/${n}${i.size>0?`?${i.toString()}`:""}`;return(yield this.delete(l,{headers:this.headers})).json()})}getSigner(e,s){return t(this,null,function*(){let r=encodeURIComponent(s);return(yield this.get(`${this.apiPrefix}/${e}/signers/${r}`,{headers:this.headers})).json()})}send(e,s,r){return t(this,null,function*(){a.info("wallets.api.send",{walletLocator:e,tokenLocator:s,recipient:r.recipient});let i=yield(yield this.post(`${this.apiPrefix}/${e}/tokens/${s}/transfers`,{body:JSON.stringify(r),headers:this.headers})).json();return"error"in i?a.error("wallets.api.send.error",{walletLocator:e,tokenLocator:s,error:i.error}):"id"in i&&a.info("wallets.api.send.success",{walletLocator:e,transactionId:i.id}),i})}get isServerSide(){return this.parsedAPIKey.usageOrigin===g.SERVER}get environment(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.environment}get projectId(){if(!this.parsedAPIKey.isValid)throw new o("Invalid API key");return this.parsedAPIKey.projectId}get headers(){return{"Content-Type":"application/json"}}};export{h as a};
|