@swapkit/wallet-keystore 1.2.11 → 1.2.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -10,4 +10,4 @@ use chrome, FireFox or Internet Explorer 11`)}var E=d0(),A=y5(),C=E.Buffer,S=E.k
|
|
|
10
10
|
* @license MIT
|
|
11
11
|
*//*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> *//*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */import{generateMnemonic as _8,validateMnemonic as w8}from"@scure/bip39";import{wordlist as f6}from"@scure/bip39/wordlists/english";import{blake2bFinal as y8,blake2bInit as g8,blake2bUpdate as m8}from"blakejs";var n6=(l)=>{let g=l;if(!(g instanceof Buffer))g=Buffer.from(g,"hex");const E=g8(32);return m8(E,g),Array.from(y8(E)).map((A)=>A<16?`0${A.toString(16)}`:A.toString(16)).join("")},r6=(l,g,E,A,C)=>new Promise((S,$)=>{M5.pbkdf2(l,g,E,A,C,(V,k)=>{if(V)$(V);else S(k)})}),Q4=async(l,g)=>{const E=M5.randomBytes(32),A=M5.randomBytes(16),C={c:262144,prf:"hmac-sha256",dklen:32,salt:E.toString("hex")},$=await r6(Buffer.from(g),E,C.c,C.dklen,"sha256"),V=M5.createCipheriv("aes-128-ctr",$.subarray(0,16),A),k=Buffer.concat([V.update(Buffer.from(l,"utf8")),V.final()]);return{meta:"xchain-keystore",version:1,crypto:{cipher:"aes-128-ctr",cipherparams:{iv:A.toString("hex")},ciphertext:k.toString("hex"),kdf:"pbkdf2",kdfparams:C,mac:n6(Buffer.concat([$.subarray(16,32),Buffer.from(k)]))}}},H4=(l=12)=>{return _8(f6,l===12?128:256)},$4=(l)=>{return w8(l,f6)},F4=async(l,g)=>{switch(l.version){case 1:{const E=l.crypto.kdfparams,A=await r6(Buffer.from(g),Buffer.from(E.salt,"hex"),E.c,E.dklen,"sha256"),C=Buffer.from(l.crypto.ciphertext,"hex");if(n6(Buffer.concat([A.subarray(16,32),C]))!==l.crypto.mac)throw new Error("Invalid password");const $=M5.createDecipheriv(l.crypto.cipher,A.subarray(0,16),Buffer.from(l.crypto.cipherparams.iv,"hex"));return Buffer.concat([$.update(C),$.final()]).toString("utf8")}default:throw new Error("Unsupported keystore version")}};import{Chain as V5,DerivationPath as p8,WalletOption as b8,derivationPathToString as c8,ensureEVMApiKeys as d8,setRequestClientConfig as l8}from"@swapkit/helpers";function u8({addChain:l,apis:g,rpcUrls:E,config:{thorswapApiKey:A,covalentApiKey:C,ethplorerApiKey:S,blockchairApiKey:$,stagenet:V}}){return async function k(z,P,j){l8({apiKey:A});const T=z.map(async(D)=>{const U=typeof j==="number"?j:0,N=j&&typeof j==="object"?j[D]:void 0,I=N?c8(N):`${p8[D]}/${U}`,{address:v,walletMethods:x}=await h8({derivationPath:I,chain:D,api:g[D],rpcUrl:E[D],covalentApiKey:C,ethplorerApiKey:S,phrase:P,blockchairApiKey:$,stagenet:V});l({...x,chain:D,address:v,balance:[],walletType:b8.KEYSTORE})});return await Promise.all(T),!0}}var h8=async({api:l,rpcUrl:g,chain:E,phrase:A,ethplorerApiKey:C,covalentApiKey:S,blockchairApiKey:$,derivationPath:V,stagenet:k})=>{switch(E){case V5.Arbitrum:case V5.Avalanche:case V5.Base:case V5.BinanceSmartChain:case V5.Ethereum:case V5.Optimism:case V5.Polygon:{const{HDNodeWallet:z,getProvider:P,getToolboxByChain:j}=await import("@swapkit/toolbox-evm"),T=d8({chain:E,covalentApiKey:S,ethplorerApiKey:C}),D=P(E,g),U=z.fromPhrase(A).connect(D),N={...T,api:l,provider:D,signer:U};return{address:U.address,walletMethods:j(E)(N)}}case V5.BitcoinCash:{let D=function({builder:N,utxos:I}){return I.forEach((v,x)=>{N.sign(x,j,void 0,65,v.witnessUtxo.value)}),N.build()};const{BCHToolbox:z}=await import("@swapkit/toolbox-utxo"),P=z({rpcUrl:g,apiKey:$,apiClient:l}),j=await P.createKeysForPath({phrase:A,derivationPath:V}),T=P.getAddressFromKeys(j),U={...P,transfer:(N)=>P.transfer({...N,from:T,signTransaction:D})};return{address:T,walletMethods:U}}case V5.Bitcoin:case V5.Dash:case V5.Dogecoin:case V5.Litecoin:{const{getToolboxByChain:z}=await import("@swapkit/toolbox-utxo"),P=z(E)({rpcUrl:g,apiKey:$,apiClient:l}),j=P.createKeysForPath({phrase:A,derivationPath:V}),T=P.getAddressFromKeys(j);return{address:T,walletMethods:{...P,transfer:(D)=>P.transfer({...D,from:T,signTransaction:(U)=>U.signAllInputs(j)})}}}case V5.Cosmos:case V5.Kujira:{const{getToolboxByChain:z}=await import("@swapkit/toolbox-cosmos"),P=z(E)({server:l,stagenet:k}),j=await P.getAddressFromMnemonic(A),T=await P.getSigner(A);return{address:j,walletMethods:{...P,transfer:(U)=>P.transfer({...U,signer:T})}}}case V5.Maya:case V5.THORChain:{const{getToolboxByChain:z}=await import("@swapkit/toolbox-cosmos"),P=z(E)({server:l,stagenet:k}),j=await P.getSigner(A),T=await P.getAddressFromMnemonic(A);return{address:T,walletMethods:{...P,deposit:({assetValue:D,memo:U})=>P.deposit({assetValue:D,memo:U,from:T,signer:j}),transfer:(D)=>P.transfer({...D,from:T,signer:j}),signMessage:async(D)=>{const U=await P.createPrivateKeyFromPhrase(A);return P.signWithPrivateKey({privateKey:U,message:D})}}}}case V5.Polkadot:case V5.Chainflip:{const{Network:z,getToolboxByChain:P,createKeyring:j}=await import("@swapkit/toolbox-substrate"),T=await j(A,z[E].prefix),D=await P(E,{signer:T});return{address:T.address,walletMethods:D}}case V5.Solana:{const{SOLToolbox:z}=await import("@swapkit/toolbox-solana"),P=z({rpcUrl:g}),j=P.createKeysForPath({phrase:A,derivationPath:V});return{address:P.getAddressFromKeys(j),walletMethods:{...P,transfer:(T)=>P.transfer({...T,fromKeypair:j})}}}default:throw new Error(`Unsupported chain ${E}`)}},o8={connectKeystore:u8};export{$4 as validatePhrase,o8 as keystoreWallet,H4 as generatePhrase,Q4 as encryptToKeyStore,F4 as decryptFromKeystore};
|
|
12
12
|
|
|
13
|
-
//# debugId=
|
|
13
|
+
//# debugId=0C303C249CBADB8864756E2164756E21
|