@swapkit/wallet-keystore 6.0.2 → 6.0.4

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/CHANGELOG.md CHANGED
@@ -1,5 +1,28 @@
1
1
  # @swapkit/wallet-keystore
2
2
 
3
+ ## 6.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#443](https://github.com/swapkit/sdk/pull/443) [`81b8303`](https://github.com/swapkit/sdk/commit/81b83032429f8e2bd496335d252563dd4a69a60f) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Solana's default derivation path is now `m/44'/501'/0'/0'` (four hardened levels) instead of a five-level BIP44 shape. Keystore and passkey already derived this path by trimming the default, so their addresses do not change. `getSolanaToolbox({ phrase })` without an explicit `derivationPath` now derives the same address as the keystore, Phantom and Trezor Suite, which moves the address for anyone relying on that fallback. Hardware wallets that read `NetworkDerivationPath[Chain.Solana]` now receive a path the device firmware accepts.
8
+ - [#444](https://github.com/swapkit/sdk/pull/444) [`d9f486d`](https://github.com/swapkit/sdk/commit/d9f486d8197c13523934e6524bdcd9e3371fdebb) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Export Cardano transaction helpers from `@swapkit/toolboxes/cardano` so hardware and browser wallets can reuse them, and sign keystore transactions over the body exactly as received instead of a re-encoded copy. `decodeCardanoWitnessSet` turns the signatures a CIP-30 wallet returns into the list `addCardanoVkeyWitnesses` accepts. (via @swapkit/toolboxes@6.3.0)
9
+ - [#439](https://github.com/swapkit/sdk/pull/439) [`92e68f2`](https://github.com/swapkit/sdk/commit/92e68f28a36915bf35fa3b9ddb4d249f035a522c) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Allow the Stellar toolbox to use an external signer, so hardware wallets can sign Stellar transactions without exposing a seed phrase. (via @swapkit/toolboxes@6.3.0)
10
+ - [#440](https://github.com/swapkit/sdk/pull/440) [`ab0cc3d`](https://github.com/swapkit/sdk/commit/ab0cc3d80439fd1541616bfc0cdf8e8798c06590) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Keep THORChain and Maya balances loading when the account holds a denom `AssetValue` cannot parse. Secured assets such as `btc-btc` threw inside `getBalance`, which rejected the whole call and left RUNE and every other balance of the chain empty. Those denoms are now skipped and the rest are returned. (via @swapkit/toolboxes@6.3.0)
11
+ - [#445](https://github.com/swapkit/sdk/pull/445) [`0e9f9ee`](https://github.com/swapkit/sdk/commit/0e9f9ee3e9c6769ded65394d5aef2e3704c7e7a7) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - TON now uses Toncenter (`https://toncenter.com/api/v2/jsonRPC`) as its default RPC and goes through the same health-checked `rpcUrls` fallback as other chains. Orbs node discovery is only used when every configured TON RPC fails, so an Orbs outage no longer breaks TON addresses, fees or transfers. The TON RPC health check now calls `getMasterchainInfo`; the previous `getAddressInformation` call with an empty address was rejected by every node. (via @swapkit/toolboxes@6.3.0)
12
+ - [#447](https://github.com/swapkit/sdk/pull/447) [`b827853`](https://github.com/swapkit/sdk/commit/b827853cd1bfa68a9bd733843b3740f10ecab359) Thanks [@github-actions](https://github.com/apps/github-actions)! - Update generated token lists. (via @swapkit/toolboxes@6.3.0)
13
+
14
+ ## 6.0.3
15
+
16
+ ### Patch Changes
17
+
18
+ - [#437](https://github.com/swapkit/sdk/pull/437) [`5baea45`](https://github.com/swapkit/sdk/commit/5baea45e1595c1582e1d1911fa99177f5e8150f0) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Export `tronAddressToHex` from `@swapkit/toolboxes/tron` so hardware wallets can reuse the checksum-validated address conversion. (via @swapkit/toolboxes@6.2.0)
19
+ - [#436](https://github.com/swapkit/sdk/pull/436) [`b7890a5`](https://github.com/swapkit/sdk/commit/b7890a5413c888b7114c512f197bd944672c5256) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Fee-bump replacements from nested segwit and taproot addresses can now be signed by external wallets (via @swapkit/toolboxes@6.2.0)
20
+ - [#419](https://github.com/swapkit/sdk/pull/419) [`b1b908b`](https://github.com/swapkit/sdk/commit/b1b908b64f5078d7bead574c5ff45f9ce4995ee8) Thanks [@ice-chillios](https://github.com/ice-chillios)! - Remove the CTRL (formerly XDEFI) and Leap wallet options, along with CTRL provider detection, its account-change listener and wallet-specific error codes. Update Cosmos signer documentation to refer to supported wallets. Integrations must remove CTRL and Leap from wallet configuration and use a supported wallet instead. (via @swapkit/toolboxes@6.2.0)
21
+ - [#433](https://github.com/swapkit/sdk/pull/433) [`c52f562`](https://github.com/swapkit/sdk/commit/c52f56237e2a9149ba12a89e0c8a47fb6138c66c) Thanks [@mfaizan1](https://github.com/mfaizan1)! - Accept PSBT inputs a wallet has already finalized. OKX Wallet finalizes inside `signPsbt` and drops `tapKeySig`, so `finalize()` threw `finalize/taproot: unknown input` and every OKX taproot send failed before broadcast. (via @swapkit/toolboxes@6.2.0)
22
+ - [#434](https://github.com/swapkit/sdk/pull/434) [`151c624`](https://github.com/swapkit/sdk/commit/151c6247a0c84e75d365853a48630d20d746477e) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Support Zcash swaps through THORChain: only transparent addresses are accepted and the ZEC minimum amount matches the THORChain dust threshold. (via @swapkit/toolboxes@6.2.0)
23
+ - [#435](https://github.com/swapkit/sdk/pull/435) [`94a2a79`](https://github.com/swapkit/sdk/commit/94a2a79867f89b5a12f34169a20e904469a010dc) Thanks [@hippocampusSK](https://github.com/hippocampusSK)! - Add `tonConnect` to the SKConfig integrations type so wallets can read the TON Connect manifest URL from `SKConfig.get("integrations").tonConnect?.manifestUrl`. (via @swapkit/toolboxes@6.2.0)
24
+ - [#430](https://github.com/swapkit/sdk/pull/430) [`9d44f87`](https://github.com/swapkit/sdk/commit/9d44f87ec8cd6ebef168a8ea64ec492f25d3d305) Thanks [@github-actions](https://github.com/apps/github-actions)! - Update generated token lists. (via @swapkit/toolboxes@6.2.0)
25
+
3
26
  ## 6.0.2
4
27
 
5
28
  ### Patch Changes
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- var v=((e)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(a,n)=>(typeof require<"u"?require:a)[n]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{ACCOUNT_INDEXED_CHAINS as F,Chain as r,CosmosChains as O,EVMChains as U,filterSupportedChains as M,getUTXOScriptTypeForPath as j,NetworkDerivationPath as N,SwapKitError as V,UTXOChains as y,updateDerivationPath as Y,WalletOption as T}from"@swapkit/helpers";import{createWallet as L,getWalletSupportedChains as q}from"@swapkit/wallet-core";import{createCipheriv as X,createDecipheriv as k,pbkdf2Sync as A,randomBytes as w}from"node:crypto";import{generateMnemonic as _,validateMnemonic as H}from"@scure/bip39";import{wordlist as D}from"@scure/bip39/wordlists/english.js";import{SwapKitError as x}from"@swapkit/helpers";async function K(e){let{blake2b:a}=await import("@noble/hashes/blake2.js"),n=e instanceof Buffer?e:Buffer.from(e,"hex"),i=a(n,{dkLen:32});return Array.from(i).map((o)=>o<16?`0${o.toString(16)}`:o.toString(16)).join("")}async function C(e,a){let i=w(16),o=w(32),s={c:262144,dklen:32,prf:"hmac-sha256",salt:o.toString("hex")},d=A(a,o,s.c,s.dklen,"sha256"),u=X("aes-128-ctr",d.subarray(0,16),i),t=Buffer.concat([u.update(Buffer.from(e,"utf8")),u.final()]),c=Buffer.concat([d.subarray(16,32),Buffer.from(t)]),p=await K(c);return{crypto:{cipher:"aes-128-ctr",cipherparams:{iv:i.toString("hex")},ciphertext:t.toString("hex"),kdf:"pbkdf2",kdfparams:s,mac:p},meta:"xchain-keystore",version:1}}function S(e=24){if(![12,15,18,21,24].includes(e))throw new x("wallet_keystore_invalid_word_count",{wordCount:e});return _(D,e/3*32)}async function B({password:e,wordCount:a=24}){let n=S(a);return{keystore:await C(n,e),phrase:n}}function I(e){return H(e,D)}async function R(e,a){switch(e.version){case 1:{let n=e.crypto.kdfparams,i=Buffer.from(n.salt,"hex"),o=A(a,i,n.c,n.dklen,"sha256"),s=Buffer.from(e.crypto.ciphertext,"hex"),d=Buffer.concat([o.subarray(16,32),s]);if(await K(d)!==e.crypto.mac)throw new x("wallet_keystore_invalid_password");let t=k(e.crypto.cipher,o.subarray(0,16),Buffer.from(e.crypto.cipherparams.iv,"hex"));return Buffer.concat([t.update(s),t.final()]).toString("utf8")}default:throw new x("wallet_keystore_unsupported_version")}}function z(e,a){if(!a)return{derivationPath:void 0,scriptType:void 0};let n=y.includes(e),i="derivationPath"in a?a.derivationPath:a,o="scriptType"in a?a.scriptType:void 0;if(n&&!o)throw new V("toolbox_utxo_invalid_params",{chain:e,error:`${e}: a UTXO derivation entry must state its scriptType: { derivationPath, scriptType }. getUTXOScriptTypeForPath(derivationPath) gives the encoding the path implies.`});return{derivationPath:i,scriptType:n?o:void 0}}var G=new Set(["toolbox_utxo_unsupported_script_type","toolbox_utxo_invalid_params"]);function J(e){return typeof e==="object"&&e!==null&&"deriveAddressAtIndex"in e&&typeof e.deriveAddressAtIndex==="function"&&"getExtendedPublicKey"in e&&typeof e.getExtendedPublicKey==="function"&&"getBalance"in e&&typeof e.getBalance==="function"}async function Q(e,a){let{createHDWalletHelpers:n,getUtxoApi:i}=await import("@swapkit/toolboxes/utxo");function o(t){let{accountIndex:c,count:p,startIndex:l=0,change:P=!1}=t;if(p<1||p>1000)throw RangeError(`count must be between 1 and 1000, got ${p}`);if(l<0)throw RangeError(`startIndex must be non-negative, got ${l}`);let m=[];for(let f=0;f<p;f++){let h=a.deriveAddressAtIndex({accountIndex:c,change:P,index:l+f});if(h)m.push(h)}return m}let{scanForAddresses:s,getAggregatedBalance:d,getAggregatedUtxos:u}=n({chain:e,deriveAddress:(t)=>a.deriveAddressAtIndex(t),getBalance:a.getBalance,getUtxos:(t)=>i(e).getUtxos({address:t,fetchTxHex:!0})});return{deriveAddresses:o,getAggregatedBalance:d,getAggregatedUtxos:u,scanForAddresses:s}}var Z=L({connect:({addChain:e})=>async function(n,i,o){let s=await te({chains:n,derivationPathMapOrIndex:o,phrase:i});for(let d of Object.values(s))e({...d,chain:d.chain,walletType:T.KEYSTORE});return!0},directSigningSupport:{...Object.fromEntries(U.map((e)=>[e,!0])),...Object.fromEntries(y.map((e)=>[e,!0])),...Object.fromEntries(O.filter((e)=>e!==r.Harbor).map((e)=>[e,!0])),[r.Aleo]:!0,[r.Aptos]:!0,[r.Cardano]:!0,[r.Hype]:!0,[r.Near]:!0,[r.Ripple]:!0,[r.Solana]:!0,[r.Stellar]:!0,[r.Sui]:!0,[r.Ton]:!0,[r.Tron]:!0},name:"connectKeystore",supportedChains:[...U,...y,...O.filter((e)=>e!==r.Harbor),r.Aleo,r.Aptos,r.Cardano,r.Ripple,r.Solana,r.Stellar,r.Sui,r.Ton,r.Tron,r.Near,r.Hype],walletType:T.KEYSTORE}),ee=q(Z);async function te({chains:e,phrase:a,derivationPathMapOrIndex:n}){let i=M({chains:e,supportedChains:ee,walletType:T.KEYSTORE}),o=typeof n==="number"?n:0,s=await Promise.allSettled(i.map(async(t)=>{let{getToolbox:c}=await import("@swapkit/toolboxes"),{derivationPath:p,scriptType:l}=z(t,n&&typeof n==="object"?n[t]:void 0),m=N[t].slice(0,t===r.Solana||t===r.Aleo?4:5),f=F.includes(t)?{account:o}:{index:o},h=p||Y(m,f),b=y.includes(t)?l??j(h):void 0,g=await c(t,{derivationPath:h,phrase:a,...b?{scriptType:b}:{}}),E=await g.getAddress()||"",W=y.includes(t)&&J(g)?await Q(t,g):{};return{...g,...W,address:E,chain:t}})),d=s.flatMap((t)=>t.status==="fulfilled"?[t.value]:[]),u=s[0];if(d.length===0&&u?.status==="rejected")throw u.reason;for(let[t,c]of s.entries()){if(c.status!=="rejected")continue;let p=c.reason?.errorKey;if(p&&G.has(p))throw c.reason;console.error(`connectKeystore: skipping ${i[t]} — failed to connect`,c.reason)}return d.reduce((t,c)=>(t[c.chain]=c,t),{})}export{ee as KEYSTORE_SUPPORTED_CHAINS,te as createKeystoreWallet,R as decryptFromKeystore,C as encryptToKeyStore,B as generateKeystore,S as generatePhrase,Z as keystoreWallet,I as validatePhrase};
1
+ var x=((e)=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(e,{get:(a,r)=>(typeof require<"u"?require:a)[r]}):e)(function(e){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+e+'" is not supported')});import{ACCOUNT_INDEXED_CHAINS as I,Chain as n,CosmosChains as C,EVMChains as S,filterSupportedChains as R,getUTXOScriptTypeForPath as F,NetworkDerivationPath as M,SwapKitError as j,UTXOChains as m,updateDerivationPath as N,WalletOption as T}from"@swapkit/helpers";import{createWallet as V,getWalletSupportedChains as Y}from"@swapkit/wallet-core";import{createCipheriv as E,createDecipheriv as W,pbkdf2Sync as b,randomBytes as P}from"node:crypto";import{generateMnemonic as X,validateMnemonic as k}from"@scure/bip39";import{wordlist as w}from"@scure/bip39/wordlists/english.js";import{SwapKitError as v}from"@swapkit/helpers";async function A(e){let{blake2b:a}=await import("@noble/hashes/blake2.js"),r=e instanceof Buffer?e:Buffer.from(e,"hex"),i=a(r,{dkLen:32});return Array.from(i).map((o)=>o<16?`0${o.toString(16)}`:o.toString(16)).join("")}async function D(e,a){let i=P(16),o=P(32),s={c:262144,dklen:32,prf:"hmac-sha256",salt:o.toString("hex")},d=b(a,o,s.c,s.dklen,"sha256"),u=E("aes-128-ctr",d.subarray(0,16),i),t=Buffer.concat([u.update(Buffer.from(e,"utf8")),u.final()]),c=Buffer.concat([d.subarray(16,32),Buffer.from(t)]),p=await A(c);return{crypto:{cipher:"aes-128-ctr",cipherparams:{iv:i.toString("hex")},ciphertext:t.toString("hex"),kdf:"pbkdf2",kdfparams:s,mac:p},meta:"xchain-keystore",version:1}}function K(e=24){if(![12,15,18,21,24].includes(e))throw new v("wallet_keystore_invalid_word_count",{wordCount:e});return X(w,e/3*32)}async function _({password:e,wordCount:a=24}){let r=K(a);return{keystore:await D(r,e),phrase:r}}function H(e){return k(e,w)}async function B(e,a){switch(e.version){case 1:{let r=e.crypto.kdfparams,i=Buffer.from(r.salt,"hex"),o=b(a,i,r.c,r.dklen,"sha256"),s=Buffer.from(e.crypto.ciphertext,"hex"),d=Buffer.concat([o.subarray(16,32),s]);if(await A(d)!==e.crypto.mac)throw new v("wallet_keystore_invalid_password");let t=W(e.crypto.cipher,o.subarray(0,16),Buffer.from(e.crypto.cipherparams.iv,"hex"));return Buffer.concat([t.update(s),t.final()]).toString("utf8")}default:throw new v("wallet_keystore_unsupported_version")}}function L(e,a){if(!a)return{derivationPath:void 0,scriptType:void 0};let r=m.includes(e),i="derivationPath"in a?a.derivationPath:a,o="scriptType"in a?a.scriptType:void 0;if(r&&!o)throw new j("toolbox_utxo_invalid_params",{chain:e,error:`${e}: a UTXO derivation entry must state its scriptType: { derivationPath, scriptType }. getUTXOScriptTypeForPath(derivationPath) gives the encoding the path implies.`});return{derivationPath:i,scriptType:r?o:void 0}}var q=new Set(["toolbox_utxo_unsupported_script_type","toolbox_utxo_invalid_params"]);function z(e){return typeof e==="object"&&e!==null&&"deriveAddressAtIndex"in e&&typeof e.deriveAddressAtIndex==="function"&&"getExtendedPublicKey"in e&&typeof e.getExtendedPublicKey==="function"&&"getBalance"in e&&typeof e.getBalance==="function"}async function G(e,a){let{createHDWalletHelpers:r,getUtxoApi:i}=await import("@swapkit/toolboxes/utxo");function o(t){let{accountIndex:c,count:p,startIndex:h=0,change:g=!1}=t;if(p<1||p>1000)throw RangeError(`count must be between 1 and 1000, got ${p}`);if(h<0)throw RangeError(`startIndex must be non-negative, got ${h}`);let y=[];for(let f=0;f<p;f++){let l=a.deriveAddressAtIndex({accountIndex:c,change:g,index:h+f});if(l)y.push(l)}return y}let{scanForAddresses:s,getAggregatedBalance:d,getAggregatedUtxos:u}=r({chain:e,deriveAddress:(t)=>a.deriveAddressAtIndex(t),getBalance:a.getBalance,getUtxos:(t)=>i(e).getUtxos({address:t,fetchTxHex:!0})});return{deriveAddresses:o,getAggregatedBalance:d,getAggregatedUtxos:u,scanForAddresses:s}}var J=V({connect:({addChain:e})=>async function(r,i,o){let s=await Z({chains:r,derivationPathMapOrIndex:o,phrase:i});for(let d of Object.values(s))e({...d,chain:d.chain,walletType:T.KEYSTORE});return!0},directSigningSupport:{...Object.fromEntries(S.map((e)=>[e,!0])),...Object.fromEntries(m.map((e)=>[e,!0])),...Object.fromEntries(C.filter((e)=>e!==n.Harbor).map((e)=>[e,!0])),[n.Aleo]:!0,[n.Aptos]:!0,[n.Cardano]:!0,[n.Hype]:!0,[n.Near]:!0,[n.Ripple]:!0,[n.Solana]:!0,[n.Stellar]:!0,[n.Sui]:!0,[n.Ton]:!0,[n.Tron]:!0},name:"connectKeystore",supportedChains:[...S,...m,...C.filter((e)=>e!==n.Harbor),n.Aleo,n.Aptos,n.Cardano,n.Ripple,n.Solana,n.Stellar,n.Sui,n.Ton,n.Tron,n.Near,n.Hype],walletType:T.KEYSTORE}),Q=Y(J);async function Z({chains:e,phrase:a,derivationPathMapOrIndex:r}){let i=R({chains:e,supportedChains:Q,walletType:T.KEYSTORE}),o=typeof r==="number"?r:0,s=await Promise.allSettled(i.map(async(t)=>{let{getToolbox:c}=await import("@swapkit/toolboxes"),{derivationPath:p,scriptType:h}=L(t,r&&typeof r==="object"?r[t]:void 0),g=I.includes(t)?{account:o}:{index:o},y=p||N(M[t],g),f=m.includes(t)?h??F(y):void 0,l=await c(t,{derivationPath:y,phrase:a,...f?{scriptType:f}:{}}),O=await l.getAddress()||"",U=m.includes(t)&&z(l)?await G(t,l):{};return{...l,...U,address:O,chain:t}})),d=s.flatMap((t)=>t.status==="fulfilled"?[t.value]:[]),u=s[0];if(d.length===0&&u?.status==="rejected")throw u.reason;for(let[t,c]of s.entries()){if(c.status!=="rejected")continue;let p=c.reason?.errorKey;if(p&&q.has(p))throw c.reason;console.error(`connectKeystore: skipping ${i[t]} — failed to connect`,c.reason)}return d.reduce((t,c)=>(t[c.chain]=c,t),{})}export{Q as KEYSTORE_SUPPORTED_CHAINS,Z as createKeystoreWallet,B as decryptFromKeystore,D as encryptToKeyStore,_ as generateKeystore,K as generatePhrase,J as keystoreWallet,H as validatePhrase};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "author": "swapkit-dev",
3
- "dependencies": { "@swapkit/helpers": "6.1.0", "@swapkit/toolboxes": "6.1.0", "@swapkit/wallet-core": "5.0.12" },
3
+ "dependencies": { "@swapkit/helpers": "6.1.2", "@swapkit/toolboxes": "6.3.0", "@swapkit/wallet-core": "5.0.14" },
4
4
  "description": "SwapKit - Wallet Keystore",
5
5
  "exports": { ".": { "default": "./dist/index.js", "types": "./dist/types/index.d.ts" } },
6
6
  "files": ["dist/", "CHANGELOG.md"],
@@ -22,5 +22,5 @@
22
22
  "type-check:go": "tsgo"
23
23
  },
24
24
  "type": "module",
25
- "version": "6.0.2"
25
+ "version": "6.0.4"
26
26
  }