@leofcoin/peernet 1.1.91 → 1.1.93

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 { L as LittlePubSub } from './peernet-DwOQKkjc.js';
1
+ import { L as LittlePubSub } from './peernet-EWyOZqOu.js';
2
2
  import './identity-Cn0iQbY3.js';
3
3
  import './value-C3vAp-wb.js';
4
4
 
@@ -42,7 +42,7 @@ class Api {
42
42
  if (state !== 'open')
43
43
  return reject(`coudn't send request to ${client.id}, no open connection found.`);
44
44
  request.id = Math.random().toString(36).slice(-12);
45
- const handler = result => {
45
+ const handler = (result) => {
46
46
  if (result && result.error)
47
47
  return reject(result.error);
48
48
  resolve({ result, id: request.id, handler });
@@ -62,11 +62,17 @@ class Api {
62
62
  },
63
63
  subscribe: (topic = 'pubsub', cb) => {
64
64
  this.subscribe(topic, cb);
65
- return this.send(client, { url: 'pubsub', params: { topic, subscribe: true } });
65
+ return this.send(client, {
66
+ url: 'pubsub',
67
+ params: { topic, subscribe: true }
68
+ });
66
69
  },
67
70
  unsubscribe: (topic = 'pubsub', cb) => {
68
71
  this.unsubscribe(topic, cb);
69
- return this.send(client, { url: 'pubsub', params: { topic, unsubscribe: true } });
72
+ return this.send(client, {
73
+ url: 'pubsub',
74
+ params: { topic, unsubscribe: true }
75
+ });
70
76
  },
71
77
  subscribers: this._pubsub.subscribers
72
78
  };
@@ -75,7 +81,9 @@ class Api {
75
81
  return {
76
82
  uptime: async () => {
77
83
  try {
78
- const { result, id, handler } = await this.request(client, { url: 'uptime' });
84
+ const { result, id, handler } = await this.request(client, {
85
+ url: 'uptime'
86
+ });
79
87
  this.unsubscribe(id, handler);
80
88
  return result;
81
89
  }
@@ -86,9 +94,11 @@ class Api {
86
94
  ping: async () => {
87
95
  try {
88
96
  const now = new Date().getTime();
89
- const { result, id, handler } = await this.request(client, { url: 'ping' });
97
+ const { result, id, handler } = await this.request(client, {
98
+ url: 'ping'
99
+ });
90
100
  this.unsubscribe(id, handler);
91
- return (Number(result) - now);
101
+ return Number(result) - now;
92
102
  }
93
103
  catch (e) {
94
104
  throw e;
@@ -121,6 +131,18 @@ class Api {
121
131
  catch (e) {
122
132
  throw e;
123
133
  }
134
+ },
135
+ peers: async (params) => {
136
+ try {
137
+ params.peers = true;
138
+ const requested = { url: 'peernet', params };
139
+ const { result, id, handler } = await this.request(client, requested);
140
+ this.unsubscribe(id, handler);
141
+ return result;
142
+ }
143
+ catch (e) {
144
+ throw e;
145
+ }
124
146
  }
125
147
  };
126
148
  }
@@ -475,7 +497,7 @@ class Client {
475
497
  });
476
498
  }
477
499
  else {
478
- globalThis.addEventListener('beforeunload', async () => this.close());
500
+ globalThis.addEventListener('beforeunload', this.close.bind(this));
479
501
  }
480
502
  }
481
503
  setupStarListeners(star) {
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './peernet-DwOQKkjc.js';
1
+ import { F as FormatInterface } from './peernet-EWyOZqOu.js';
2
2
  import './identity-Cn0iQbY3.js';
3
3
  import './value-C3vAp-wb.js';
4
4
 
@@ -8372,7 +8372,7 @@ class Peernet {
8372
8372
  this.root = options.root;
8373
8373
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
8374
8374
  // FolderMessageResponse
8375
- } = await import(/* webpackChunkName: "messages" */ './messages-PrGKIaCz.js');
8375
+ } = await import(/* webpackChunkName: "messages" */ './messages-B9TrXtD1.js');
8376
8376
  /**
8377
8377
  * proto Object containing protos
8378
8378
  * @type {Object}
@@ -8466,7 +8466,7 @@ class Peernet {
8466
8466
  if (this.#starting || this.#started)
8467
8467
  return;
8468
8468
  this.#starting = true;
8469
- const importee = await import('./client-CWo3zJ1j.js');
8469
+ const importee = await import('./client-BScgNzXE.js');
8470
8470
  /**
8471
8471
  * @access public
8472
8472
  * @type {PeernetClient}
@@ -8725,10 +8725,11 @@ class Peernet {
8725
8725
  debug(`Error while requesting data from ${id}`, error);
8726
8726
  // if error, remove provider
8727
8727
  this.dht.removeProvider(id, hash);
8728
- if (this.#peerAttempts[id] > 3) {
8728
+ if (this.#peerAttempts[id] > 1) {
8729
8729
  this.#peerAttempts[id] = 0;
8730
8730
  debug(`Removed provider ${id} for ${hash} after 3 attempts`);
8731
- throw nothingFoundError(hash);
8731
+ console.error(nothingFoundError(hash));
8732
+ return undefined;
8732
8733
  }
8733
8734
  if (this.#peerAttempts[id] === undefined)
8734
8735
  this.#peerAttempts[id] = 0;
@@ -85,7 +85,7 @@ export default class Peernet {
85
85
  */
86
86
  get peers(): [string, import("@netpeer/swarm/peer").default][];
87
87
  get connections(): {
88
- [x: string]: import("@netpeer/swarm/peer").default;
88
+ [index: string]: import("@netpeer/swarm/peer").default;
89
89
  };
90
90
  /**
91
91
  * @return {String} id - peerId
@@ -1,3 +1,3 @@
1
- export { P as default } from './peernet-DwOQKkjc.js';
1
+ export { P as default } from './peernet-EWyOZqOu.js';
2
2
  import './identity-Cn0iQbY3.js';
3
3
  import './value-C3vAp-wb.js';
@@ -806,10 +806,11 @@ class Peernet {
806
806
  debug(`Error while requesting data from ${id}`, error);
807
807
  // if error, remove provider
808
808
  this.dht.removeProvider(id, hash);
809
- if (this.#peerAttempts[id] > 3) {
809
+ if (this.#peerAttempts[id] > 1) {
810
810
  this.#peerAttempts[id] = 0;
811
811
  debug(`Removed provider ${id} for ${hash} after 3 attempts`);
812
- throw nothingFoundError(hash);
812
+ console.error(nothingFoundError(hash));
813
+ return undefined;
813
814
  }
814
815
  if (this.#peerAttempts[id] === undefined)
815
816
  this.#peerAttempts[id] = 0;
@@ -85,7 +85,7 @@ export default class Peernet {
85
85
  */
86
86
  get peers(): [string, import("@netpeer/swarm/peer").default][];
87
87
  get connections(): {
88
- [x: string]: import("@netpeer/swarm/peer").default;
88
+ [index: string]: import("@netpeer/swarm/peer").default;
89
89
  };
90
90
  /**
91
91
  * @return {String} id - peerId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "1.1.91",
3
+ "version": "1.1.93",
4
4
  "description": "",
5
5
  "browser": "./exports/browser/peernet.js",
6
6
  "exports": {
@@ -37,34 +37,34 @@
37
37
  "@leofcoin/identity-utils": "^1.0.2",
38
38
  "@leofcoin/multi-wallet": "^3.1.8",
39
39
  "@leofcoin/storage": "^3.5.38",
40
- "@netpeer/swarm": "^0.8.20",
40
+ "@netpeer/swarm": "^0.8.21",
41
41
  "@vandeurenglenn/base32": "^1.2.4",
42
42
  "@vandeurenglenn/base58": "^1.1.9",
43
43
  "@vandeurenglenn/debug": "^1.2.6",
44
44
  "@vandeurenglenn/is-hex": "^1.1.1",
45
45
  "@vandeurenglenn/little-pubsub": "^1.5.1",
46
- "inquirer": "^12.7.0",
46
+ "inquirer": "^12.9.0",
47
47
  "multi-signature": "^1.3.1",
48
48
  "qr-scanner": "^1.4.2",
49
49
  "qrcode": "^1.5.4",
50
- "socket-request-client": "^2.0.9",
51
- "socket-request-server": "^1.6.17"
50
+ "socket-request-client": "^2.1.0",
51
+ "socket-request-server": "^1.7.1"
52
52
  },
53
53
  "devDependencies": {
54
- "@jest/globals": "^30.0.4",
54
+ "@jest/globals": "^30.0.5",
55
55
  "@rollup/plugin-commonjs": "^28.0.6",
56
56
  "@rollup/plugin-json": "^6.1.0",
57
57
  "@rollup/plugin-node-resolve": "^16.0.1",
58
58
  "@rollup/plugin-typescript": "^12.1.4",
59
59
  "@rollup/plugin-wasm": "^6.2.2",
60
60
  "@types/bs58check": "^2.1.2",
61
- "@types/node": "^24.0.14",
61
+ "@types/node": "^24.1.0",
62
62
  "@types/qrcode": "^1.5.5",
63
63
  "@types/secp256k1": "^4.0.6",
64
64
  "@types/varint": "^6.0.3",
65
65
  "chai": "^5.2.1",
66
- "cross-env": "^7.0.3",
67
- "rollup": "^4.45.1",
66
+ "cross-env": "^10.0.0",
67
+ "rollup": "^4.46.2",
68
68
  "sinon": "^21.0.0"
69
69
  }
70
70
  }
package/src/peernet.ts CHANGED
@@ -584,10 +584,11 @@ export default class Peernet {
584
584
  debug(`Error while requesting data from ${id}`, error)
585
585
  // if error, remove provider
586
586
  this.dht.removeProvider(id, hash)
587
- if (this.#peerAttempts[id] > 3) {
587
+ if (this.#peerAttempts[id] > 1) {
588
588
  this.#peerAttempts[id] = 0
589
589
  debug(`Removed provider ${id} for ${hash} after 3 attempts`)
590
- throw nothingFoundError(hash)
590
+ console.error(nothingFoundError(hash))
591
+ return undefined
591
592
  }
592
593
 
593
594
  if (this.#peerAttempts[id] === undefined) this.#peerAttempts[id] = 0