@bitsocial/bitsocial-react-hooks 0.1.21 → 0.1.22

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,3 +1,7 @@
1
+ ## [0.1.22](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.21...v0.1.22) (2026-06-25)
2
+
3
+
4
+
1
5
  ## [0.1.21](https://github.com/bitsocialnet/bitsocial-react-hooks/compare/v0.1.20...v0.1.21) (2026-06-24)
2
6
 
3
7
 
package/README.md CHANGED
@@ -893,6 +893,7 @@ const account = useAccount() // or useAccount('Account 2') to use an account oth
893
893
  // `account.author.wallets` only auto-generates an `eth` wallet by default.
894
894
  // `account.chainProviders` is the canonical chain config for wallets, NFT lookups, and other chain reads.
895
895
  // Defaults use multiple explicit Ethereum RPCs for `.eth` / `.bso` author-name resolution.
896
+ // Defaults use multiple HTTP routers for IPFS/IPNS delegated routing.
896
897
  // `account.nameResolversChainProviders` optionally overrides only the RPCs used for that resolution.
897
898
  console.log(account.author.wallets.eth)
898
899
 
@@ -905,6 +906,15 @@ const ethResolverRpcUrls = [
905
906
  'https://eth-pokt.nodies.app',
906
907
  ]
907
908
 
909
+ const httpRoutersOptions = [
910
+ 'https://peers.pleb.bot',
911
+ 'https://routing.lol',
912
+ 'https://peers.forumindex.com',
913
+ 'https://peers.plebpubsub.xyz',
914
+ 'https://routerofbitsocial.xyz',
915
+ 'https://bsotracker.online',
916
+ ]
917
+
908
918
  const author: {...account.author, displayName: 'John'}
909
919
  const editedAccount = {
910
920
  ...account,
@@ -913,6 +923,10 @@ const editedAccount = {
913
923
  ...account.chainProviders,
914
924
  eth: { urls: [...ethResolverRpcUrls, 'ethers.js'], chainId: 1 },
915
925
  },
926
+ pkcOptions: {
927
+ ...account.pkcOptions,
928
+ httpRoutersOptions,
929
+ },
916
930
  nameResolversChainProviders: {
917
931
  eth: { urls: ethResolverRpcUrls, chainId: 1 },
918
932
  },
@@ -1,6 +1,7 @@
1
1
  import { AccountCommunity, ChainProviders } from "../../types.js";
2
2
  export declare const DEFAULT_ETH_RPC_URL = "https://ethereum-rpc.publicnode.com";
3
3
  export declare const DEFAULT_ETH_RPC_URLS: string[];
4
+ export declare const DEFAULT_HTTP_ROUTER_URLS: string[];
4
5
  export declare const overwritePkcOptions: {
5
6
  resolveAuthorNames: boolean;
6
7
  resolveAuthorAddresses: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"account-generator.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAY,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASzE,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AACzE,eAAO,MAAM,oBAAoB,UAOhC,CAAC;AAgBF,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAqBF,eAAO,MAAM,wBAAwB,QAQd,cACtB,CAAC;AAGF,eAAO,MAAM,oBAAoB;;;CAoChC,CAAC;AAuFF,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"account-generator.d.ts","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":"AAKA,OAAO,EAAY,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AASzE,eAAO,MAAM,mBAAmB,wCAAwC,CAAC;AACzE,eAAO,MAAM,oBAAoB,UAOhC,CAAC;AACF,eAAO,MAAM,wBAAwB,UAOpC,CAAC;AAgBF,eAAO,MAAM,mBAAmB;;;;CAI/B,CAAC;AAqBF,eAAO,MAAM,wBAAwB,QAQd,cACtB,CAAC;AAGF,eAAO,MAAM,oBAAoB;;;CA+BhC,CAAC;AAuFF,QAAA,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAGrB,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -24,6 +24,14 @@ export const DEFAULT_ETH_RPC_URLS = [
24
24
  "https://1rpc.io/eth",
25
25
  "https://eth-pokt.nodies.app",
26
26
  ];
27
+ export const DEFAULT_HTTP_ROUTER_URLS = [
28
+ "https://peers.pleb.bot",
29
+ "https://routing.lol",
30
+ "https://peers.forumindex.com",
31
+ "https://peers.plebpubsub.xyz",
32
+ "https://routerofbitsocial.xyz",
33
+ "https://bsotracker.online",
34
+ ];
27
35
  // default chain providers
28
36
  const chainProviders = {
29
37
  eth: {
@@ -91,12 +99,7 @@ export const getDefaultPkcOptions = () => {
91
99
  "https://pubsubprovider.xyz/api/v0",
92
100
  "https://plebpubsub.xyz/api/v0",
93
101
  "https://rannithepleb.com/api/v0",
94
- ], httpRoutersOptions: [
95
- "https://routing.lol",
96
- "https://peers.pleb.bot",
97
- "https://peers.plebpubsub.xyz",
98
- "https://peers.forumindex.com",
99
- ] }, overwritePkcOptions));
102
+ ], httpRoutersOptions: [...DEFAULT_HTTP_ROUTER_URLS] }, overwritePkcOptions));
100
103
  };
101
104
  // the gateway to use in <img src> for nft avatars
102
105
  // @ts-ignore
@@ -1 +1 @@
1
- {"version":3,"file":"account-generator.js","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,KAAK,MAAM,kBAAkB,CAAC;AACrC,OAAO,SAAS,MAAM,qBAAqB,CAAC;AAC5C,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,EAAE,EAAE,IAAI,IAAI,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,gBAAgB,MAAM,qBAAqB,CAAC;AAEnD,OAAO,EACL,mBAAmB,EACnB,8BAA8B,EAC9B,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,MAAM,MAAM,yBAAyB,CAAC;AAC7C,MAAM,GAAG,GAAG,MAAM,CAAC,uCAAuC,CAAC,CAAC;A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;AAEF,MAAM,gBAAgB,GAAG;IACvB,sBAAsB;IACtB,oBAAoB;CACrB,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import PkcJs from \"../../lib/pkc-js\";\nimport validator from \"../../lib/validator\";\nimport chain from \"../../lib/chain\";\nimport { v4 as uuid } from \"uuid\";\nimport accountsDatabase from \"./accounts-database\";\nimport { Accounts, AccountCommunity, ChainProviders } from \"../../types\";\nimport {\n getPkcClientOptions,\n normalizeAccountProtocolConfig,\n withProtocolAliases,\n} from \"../../lib/pkc-compat\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\n\nexport const DEFAULT_ETH_RPC_URL = \"https://ethereum-rpc.publicnode.com\";\nexport const DEFAULT_ETH_RPC_URLS = [\n DEFAULT_ETH_RPC_URL,\n \"https://eth.drpc.org\",\n \"https://ethereum.publicnode.com\",\n \"https://rpc.mevblocker.io\",\n \"https://1rpc.io/eth\",\n \"https://eth-pokt.nodies.app\",\n];\n\n// default chain providers\nconst chainProviders: ChainProviders = {\n eth: {\n // Use explicit RPCs for default name resolution; viem's default transport is opt-in.\n urls: [...DEFAULT_ETH_RPC_URLS, \"ethers.js\"],\n chainId: 1,\n },\n matic: {\n urls: [\"https://polygon-rpc.com\"],\n chainId: 137,\n },\n};\n\n// force using these options or can cause bugs\nexport const overwritePkcOptions = {\n resolveAuthorNames: false,\n resolveAuthorAddresses: false,\n validatePages: false,\n};\n\nconst aliasProtocolOptions = (options: Record<string, any>) => ({\n ...options,\n resolveAuthorNames: options.resolveAuthorNames ?? options.resolveAuthorAddresses ?? false,\n resolveAuthorAddresses: options.resolveAuthorAddresses ?? options.resolveAuthorNames ?? false,\n});\n\nconst addMissingChainProviders = (options: Record<string, any>) => {\n const optionsWithChainProviders = { ...options };\n if (!optionsWithChainProviders.chainProviders) {\n optionsWithChainProviders.chainProviders = {};\n }\n for (const chainTicker in chainProviders) {\n if (!optionsWithChainProviders.chainProviders[chainTicker]) {\n optionsWithChainProviders.chainProviders[chainTicker] = chainProviders[chainTicker];\n }\n }\n return optionsWithChainProviders;\n};\n\nexport const getDefaultChainProviders = () => {\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n const windowChainProviders = defaultWindowOptions?.chainProviders\n ? JSON.parse(JSON.stringify(defaultWindowOptions.chainProviders))\n : undefined;\n return addMissingChainProviders({\n chainProviders: windowChainProviders,\n }).chainProviders as ChainProviders;\n};\n\n// default options aren't saved to database so they can be changed\nexport const getDefaultPkcOptions = () => {\n // default PKC options defined by the electron process\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n if (defaultWindowOptions) {\n // @ts-ignore\n const defaultPkcOptions: any = JSON.parse(\n JSON.stringify({ ...defaultWindowOptions, libp2pJsClientsOptions: undefined }),\n );\n delete defaultPkcOptions.chainProviders;\n delete defaultPkcOptions.nameResolversChainProviders;\n // @ts-ignore\n defaultPkcOptions.libp2pJsClientsOptions = defaultWindowOptions.libp2pJsClientsOptions; // libp2pJsClientsOptions is not always just json\n return aliasProtocolOptions({ ...defaultPkcOptions, ...overwritePkcOptions });\n }\n // default PKC options for web client\n return aliasProtocolOptions({\n ipfsGatewayUrls: [\n \"https://ipfsgateway.xyz\",\n \"https://gateway.plebpubsub.xyz\",\n \"https://gateway.forumindex.com\",\n ],\n kuboRpcClientsOptions: undefined,\n pubsubKuboRpcClientsOptions: [\n \"https://pubsubprovider.xyz/api/v0\",\n \"https://plebpubsub.xyz/api/v0\",\n \"https://rannithepleb.com/api/v0\",\n ],\n httpRoutersOptions: [\n \"https://routing.lol\",\n \"https://peers.pleb.bot\",\n \"https://peers.plebpubsub.xyz\",\n \"https://peers.forumindex.com\",\n ],\n ...overwritePkcOptions,\n });\n};\n\n// the gateway to use in <img src> for nft avatars\n// @ts-ignore\nconst defaultMediaIpfsGatewayUrl = window.defaultMediaIpfsGatewayUrl || \"https://ipfs.io\";\n\nconst generateDefaultAccount = async () => {\n const pkcOptions = getDefaultPkcOptions();\n const chainProviders = getDefaultChainProviders();\n const pkc = await PkcJs.PKC(\n getPkcClientOptions(\n {\n chainProviders,\n pkcOptions,\n },\n pkcOptions,\n ),\n );\n // handle errors or error events are uncaught\n // no need to log them because pkc-js already logs them\n pkc.on(\"error\", (error: any) =>\n log.error(\"uncaught pkc instance error, should never happen\", { error }),\n );\n\n const signer = await pkc.createSigner();\n const author = {\n address: signer.address,\n wallets: {\n eth: await chain.getEthWalletFromPkcPrivateKey(signer.privateKey, signer.address),\n },\n };\n\n const accountName = await getNextAvailableDefaultAccountName();\n\n // communities where the account has a role, like moderator, admin, owner, etc.\n const communities: { [communityAddress: string]: AccountCommunity } = {};\n\n const account = normalizeAccountProtocolConfig(\n withProtocolAliases(\n {\n id: uuid(),\n version: accountsDatabase.accountVersion,\n name: accountName,\n author,\n signer,\n chainProviders,\n pkcOptions,\n subscriptions: [],\n blockedAddresses: {},\n blockedCids: {},\n communities,\n mediaIpfsGatewayUrl: defaultMediaIpfsGatewayUrl,\n },\n pkc,\n pkcOptions,\n ),\n chainProviders,\n );\n return account;\n};\n\nconst getNextAvailableDefaultAccountName = async () => {\n const accountIds: string[] | null =\n await accountsDatabase.accountsMetadataDatabase.getItem(\"accountIds\");\n const accountNames = [];\n if (accountIds?.length) {\n const accounts: Accounts | null = await accountsDatabase.getAccounts(accountIds);\n for (const accountId of accountIds) {\n accountNames.push(accounts[accountId].name);\n }\n }\n let accountNumber = 1;\n if (!accountNames?.length) {\n return `Account ${accountNumber}`;\n }\n validator.validateAccountsDatabaseAccountNames(accountNames);\n\n const accountNamesSet = new Set(accountNames);\n while (true) {\n const accountName = `Account ${accountNumber}`;\n if (!accountNamesSet.has(accountName)) {\n return accountName;\n }\n accountNumber++;\n }\n};\n\nconst accountGenerator = {\n generateDefaultAccount,\n getDefaultPkcOptions,\n};\n\nexport default accountGenerator;\n"]}
1
+ {"version":3,"file":"account-generator.js","sourceRoot":"","sources":["../../../src/stores/accounts/account-generator.ts"],"names":[],"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,IAAI,aAAa,GAAG,CAAC,CAAC;IACtB,IAAI,CAAC,CAAA,YAAY,aAAZ,YAAY,uBAAZ,YAAY,CAAE,MAAM,CAAA,EAAE,CAAC;QAC1B,OAAO,WAAW,aAAa,EAAE,CAAC;IACpC,CAAC;IACD,SAAS,CAAC,oCAAoC,CAAC,YAAY,CAAC,CAAC;IAE7D,MAAM,eAAe,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IAC9C,OAAO,IAAI,EAAE,CAAC;QACZ,MAAM,WAAW,GAAG,WAAW,aAAa,EAAE,CAAC;QAC/C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;YACtC,OAAO,WAAW,CAAC;QACrB,CAAC;QACD,aAAa,EAAE,CAAC;IAClB,CAAC;AACH,CAAC,CAAA,CAAC;AAEF,MAAM,gBAAgB,GAAG;IACvB,sBAAsB;IACtB,oBAAoB;CACrB,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import PkcJs from \"../../lib/pkc-js\";\nimport validator from \"../../lib/validator\";\nimport chain from \"../../lib/chain\";\nimport { v4 as uuid } from \"uuid\";\nimport accountsDatabase from \"./accounts-database\";\nimport { Accounts, AccountCommunity, ChainProviders } from \"../../types\";\nimport {\n getPkcClientOptions,\n normalizeAccountProtocolConfig,\n withProtocolAliases,\n} from \"../../lib/pkc-compat\";\nimport Logger from \"@pkcprotocol/pkc-logger\";\nconst log = Logger(\"bitsocial-react-hooks:accounts:stores\");\n\nexport const DEFAULT_ETH_RPC_URL = \"https://ethereum-rpc.publicnode.com\";\nexport const DEFAULT_ETH_RPC_URLS = [\n DEFAULT_ETH_RPC_URL,\n \"https://eth.drpc.org\",\n \"https://ethereum.publicnode.com\",\n \"https://rpc.mevblocker.io\",\n \"https://1rpc.io/eth\",\n \"https://eth-pokt.nodies.app\",\n];\nexport const DEFAULT_HTTP_ROUTER_URLS = [\n \"https://peers.pleb.bot\",\n \"https://routing.lol\",\n \"https://peers.forumindex.com\",\n \"https://peers.plebpubsub.xyz\",\n \"https://routerofbitsocial.xyz\",\n \"https://bsotracker.online\",\n];\n\n// default chain providers\nconst chainProviders: ChainProviders = {\n eth: {\n // Use explicit RPCs for default name resolution; viem's default transport is opt-in.\n urls: [...DEFAULT_ETH_RPC_URLS, \"ethers.js\"],\n chainId: 1,\n },\n matic: {\n urls: [\"https://polygon-rpc.com\"],\n chainId: 137,\n },\n};\n\n// force using these options or can cause bugs\nexport const overwritePkcOptions = {\n resolveAuthorNames: false,\n resolveAuthorAddresses: false,\n validatePages: false,\n};\n\nconst aliasProtocolOptions = (options: Record<string, any>) => ({\n ...options,\n resolveAuthorNames: options.resolveAuthorNames ?? options.resolveAuthorAddresses ?? false,\n resolveAuthorAddresses: options.resolveAuthorAddresses ?? options.resolveAuthorNames ?? false,\n});\n\nconst addMissingChainProviders = (options: Record<string, any>) => {\n const optionsWithChainProviders = { ...options };\n if (!optionsWithChainProviders.chainProviders) {\n optionsWithChainProviders.chainProviders = {};\n }\n for (const chainTicker in chainProviders) {\n if (!optionsWithChainProviders.chainProviders[chainTicker]) {\n optionsWithChainProviders.chainProviders[chainTicker] = chainProviders[chainTicker];\n }\n }\n return optionsWithChainProviders;\n};\n\nexport const getDefaultChainProviders = () => {\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n const windowChainProviders = defaultWindowOptions?.chainProviders\n ? JSON.parse(JSON.stringify(defaultWindowOptions.chainProviders))\n : undefined;\n return addMissingChainProviders({\n chainProviders: windowChainProviders,\n }).chainProviders as ChainProviders;\n};\n\n// default options aren't saved to database so they can be changed\nexport const getDefaultPkcOptions = () => {\n // default PKC options defined by the electron process\n // @ts-ignore\n const defaultWindowOptions = window.defaultPkcOptions;\n if (defaultWindowOptions) {\n // @ts-ignore\n const defaultPkcOptions: any = JSON.parse(\n JSON.stringify({ ...defaultWindowOptions, libp2pJsClientsOptions: undefined }),\n );\n delete defaultPkcOptions.chainProviders;\n delete defaultPkcOptions.nameResolversChainProviders;\n // @ts-ignore\n defaultPkcOptions.libp2pJsClientsOptions = defaultWindowOptions.libp2pJsClientsOptions; // libp2pJsClientsOptions is not always just json\n return aliasProtocolOptions({ ...defaultPkcOptions, ...overwritePkcOptions });\n }\n // default PKC options for web client\n return aliasProtocolOptions({\n ipfsGatewayUrls: [\n \"https://ipfsgateway.xyz\",\n \"https://gateway.plebpubsub.xyz\",\n \"https://gateway.forumindex.com\",\n ],\n kuboRpcClientsOptions: undefined,\n pubsubKuboRpcClientsOptions: [\n \"https://pubsubprovider.xyz/api/v0\",\n \"https://plebpubsub.xyz/api/v0\",\n \"https://rannithepleb.com/api/v0\",\n ],\n httpRoutersOptions: [...DEFAULT_HTTP_ROUTER_URLS],\n ...overwritePkcOptions,\n });\n};\n\n// the gateway to use in <img src> for nft avatars\n// @ts-ignore\nconst defaultMediaIpfsGatewayUrl = window.defaultMediaIpfsGatewayUrl || \"https://ipfs.io\";\n\nconst generateDefaultAccount = async () => {\n const pkcOptions = getDefaultPkcOptions();\n const chainProviders = getDefaultChainProviders();\n const pkc = await PkcJs.PKC(\n getPkcClientOptions(\n {\n chainProviders,\n pkcOptions,\n },\n pkcOptions,\n ),\n );\n // handle errors or error events are uncaught\n // no need to log them because pkc-js already logs them\n pkc.on(\"error\", (error: any) =>\n log.error(\"uncaught pkc instance error, should never happen\", { error }),\n );\n\n const signer = await pkc.createSigner();\n const author = {\n address: signer.address,\n wallets: {\n eth: await chain.getEthWalletFromPkcPrivateKey(signer.privateKey, signer.address),\n },\n };\n\n const accountName = await getNextAvailableDefaultAccountName();\n\n // communities where the account has a role, like moderator, admin, owner, etc.\n const communities: { [communityAddress: string]: AccountCommunity } = {};\n\n const account = normalizeAccountProtocolConfig(\n withProtocolAliases(\n {\n id: uuid(),\n version: accountsDatabase.accountVersion,\n name: accountName,\n author,\n signer,\n chainProviders,\n pkcOptions,\n subscriptions: [],\n blockedAddresses: {},\n blockedCids: {},\n communities,\n mediaIpfsGatewayUrl: defaultMediaIpfsGatewayUrl,\n },\n pkc,\n pkcOptions,\n ),\n chainProviders,\n );\n return account;\n};\n\nconst getNextAvailableDefaultAccountName = async () => {\n const accountIds: string[] | null =\n await accountsDatabase.accountsMetadataDatabase.getItem(\"accountIds\");\n const accountNames = [];\n if (accountIds?.length) {\n const accounts: Accounts | null = await accountsDatabase.getAccounts(accountIds);\n for (const accountId of accountIds) {\n accountNames.push(accounts[accountId].name);\n }\n }\n let accountNumber = 1;\n if (!accountNames?.length) {\n return `Account ${accountNumber}`;\n }\n validator.validateAccountsDatabaseAccountNames(accountNames);\n\n const accountNamesSet = new Set(accountNames);\n while (true) {\n const accountName = `Account ${accountNumber}`;\n if (!accountNamesSet.has(accountName)) {\n return accountName;\n }\n accountNumber++;\n }\n};\n\nconst accountGenerator = {\n generateDefaultAccount,\n getDefaultPkcOptions,\n};\n\nexport default accountGenerator;\n"]}
package/package.json CHANGED
@@ -13,7 +13,7 @@
13
13
  "publishConfig": {
14
14
  "access": "public"
15
15
  },
16
- "version": "0.1.21",
16
+ "version": "0.1.22",
17
17
  "packageManager": "yarn@4.13.0",
18
18
  "files": [
19
19
  "CHANGELOG.md",
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "dependencies": {
50
50
  "@bitsocial/bso-resolver": "0.0.8",
51
- "@pkcprotocol/pkc-js": "0.0.48",
51
+ "@pkcprotocol/pkc-js": "0.0.53",
52
52
  "@pkcprotocol/pkc-logger": "0.1.0",
53
53
  "assert": "2.0.0",
54
54
  "ethers": "5.8.0",
@@ -69,12 +69,12 @@
69
69
  "resolutions": {
70
70
  "follow-redirects": "1.16.0",
71
71
  "postcss": "8.5.10",
72
- "protobufjs": "7.5.8",
72
+ "protobufjs": "7.6.3",
73
73
  "uuid": "14.0.0",
74
74
  "axios": "1.16.0",
75
75
  "vite": "8.0.16",
76
- "tar": "7.5.11",
77
- "undici": "7.24.0",
76
+ "tar": "7.5.16",
77
+ "undici": "7.28.0",
78
78
  "minimatch": "3.1.4",
79
79
  "brace-expansion@npm:^1.1.7": "1.1.13",
80
80
  "elliptic": "6.6.1",
@@ -88,14 +88,16 @@
88
88
  "picomatch@npm:^2.3.1": "2.3.2",
89
89
  "picomatch@npm:^4.0.1": "4.0.4",
90
90
  "picomatch@npm:^4.0.3": "4.0.4",
91
- "tmp": "0.2.6",
91
+ "tmp": "0.2.7",
92
92
  "@tootallnate/once": "3.0.1",
93
93
  "@protobufjs/utf8": "1.1.1",
94
94
  "@libp2p/gossipsub": "15.0.23",
95
95
  "@libp2p/kad-dht": "16.2.6",
96
96
  "fast-uri": "3.1.2",
97
97
  "ip-address": "10.1.1",
98
- "ws": "8.20.1"
98
+ "ws": "8.21.0",
99
+ "form-data": "4.0.6",
100
+ "js-yaml": "4.2.0"
99
101
  },
100
102
  "devDependencies": {
101
103
  "@testing-library/dom": "10.4.1",