@leofcoin/peernet 1.1.24 → 1.1.26

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.
@@ -1,4 +1,4 @@
1
- import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './peernet-805b1e8e.js';
1
+ import { g as getDefaultExportFromCjs, c as commonjsGlobal } from './peernet-b4b62ddc.js';
2
2
  import './value-157ab062.js';
3
3
 
4
4
  function commonjsRequire(path) {
@@ -1,4 +1,4 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-805b1e8e.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-b4b62ddc.js';
2
2
  import './value-157ab062.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './peernet-805b1e8e.js';
1
+ import { F as FormatInterface } from './peernet-b4b62ddc.js';
2
2
  import './value-157ab062.js';
3
3
 
4
4
  var proto$b = {
@@ -6203,8 +6203,7 @@ const lastFetched = {
6203
6203
  const fetchedCoordinates = {};
6204
6204
  const getAddress = async () => {
6205
6205
  const { address } = lastFetched;
6206
- const now = Math.round(new Date().getTime() / 1000);
6207
- if (now - address.timestamp > 1200000) {
6206
+ if (address) {
6208
6207
  address.value = await fetch('https://icanhazip.com/');
6209
6208
  address.value = await address.value.text();
6210
6209
  address.timestamp = Math.round(new Date().getTime() / 1000);
@@ -20185,7 +20184,7 @@ class Identity {
20185
20184
  globalThis.peernet.selectedAccount = new TextDecoder().decode(selected);
20186
20185
  }
20187
20186
  else {
20188
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-e407f1a3.js');
20187
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-688c9980.js');
20189
20188
  const { identity, accounts } = await importee.default(password, this.network);
20190
20189
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
20191
20190
  await globalThis.walletStore.put('version', String(1));
@@ -20356,7 +20355,7 @@ class Peernet {
20356
20355
  this.root = options.root;
20357
20356
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
20358
20357
  // FolderMessageResponse
20359
- } = await import(/* webpackChunkName: "messages" */ './messages-2465e07d.js');
20358
+ } = await import(/* webpackChunkName: "messages" */ './messages-6c66a924.js');
20360
20359
  /**
20361
20360
  * proto Object containing protos
20362
20361
  * @type {Object}
@@ -20428,7 +20427,7 @@ class Peernet {
20428
20427
  if (this.#starting || this.#started)
20429
20428
  return;
20430
20429
  this.#starting = true;
20431
- const importee = await import('./client-31b62450.js');
20430
+ const importee = await import('./client-4112eed9.js');
20432
20431
  /**
20433
20432
  * @access public
20434
20433
  * @type {PeernetClient}
@@ -20613,7 +20612,7 @@ class Peernet {
20613
20612
  throw nothingFoundError(hash);
20614
20613
  debug(`found ${providers.size} provider(s) for ${hash}`);
20615
20614
  // get closest peer on earth
20616
- const closestPeer = await this.dht.closestPeer(providers);
20615
+ const closestPeer = providers[0];
20617
20616
  // get peer instance by id
20618
20617
  if (!closestPeer || !closestPeer.id)
20619
20618
  return this.requestData(hash, store?.name || store);
@@ -1,2 +1,2 @@
1
- export { P as default } from './peernet-805b1e8e.js';
1
+ export { P as default } from './peernet-b4b62ddc.js';
2
2
  import './value-157ab062.js';
@@ -164,8 +164,7 @@ const lastFetched = {
164
164
  const fetchedCoordinates = {};
165
165
  const getAddress = async () => {
166
166
  const { address } = lastFetched;
167
- const now = Math.round(new Date().getTime() / 1000);
168
- if (now - address.timestamp > 1200000) {
167
+ if (address) {
169
168
  address.value = await fetch('https://icanhazip.com/');
170
169
  address.value = await address.value.text();
171
170
  address.timestamp = Math.round(new Date().getTime() / 1000);
@@ -771,7 +770,7 @@ class Peernet {
771
770
  throw nothingFoundError(hash);
772
771
  debug(`found ${providers.size} provider(s) for ${hash}`);
773
772
  // get closest peer on earth
774
- const closestPeer = await this.dht.closestPeer(providers);
773
+ const closestPeer = providers[0];
775
774
  // get peer instance by id
776
775
  if (!closestPeer || !closestPeer.id)
777
776
  return this.requestData(hash, store?.name || store);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "1.1.24",
3
+ "version": "1.1.26",
4
4
  "description": "",
5
5
  "main": "src/peernet.js",
6
6
  "exports": {
package/src/dht/dht.js CHANGED
@@ -18,8 +18,7 @@ const fetchedCoordinates = {}
18
18
 
19
19
  const getAddress = async () => {
20
20
  const {address} = lastFetched
21
- const now = Math.round(new Date().getTime() / 1000);
22
- if (now - address.timestamp > 1200000) {
21
+ if (address) {
23
22
  address.value = await fetch('https://icanhazip.com/')
24
23
  address.value = await address.value.text()
25
24
  address.timestamp = Math.round(new Date().getTime() / 1000);
package/src/peernet.ts CHANGED
@@ -465,7 +465,7 @@ export default class Peernet {
465
465
  if (!providers || providers.size === 0) throw nothingFoundError(hash)
466
466
  debug(`found ${providers.size} provider(s) for ${hash}`)
467
467
  // get closest peer on earth
468
- const closestPeer = await this.dht.closestPeer(providers)
468
+ const closestPeer = providers[0]
469
469
  // get peer instance by id
470
470
  if (!closestPeer || !closestPeer.id) return this.requestData(hash, store?.name || store)
471
471