@leofcoin/peernet 1.1.95 → 1.1.97

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-BWKdRXeW.js';
1
+ import { L as LittlePubSub } from './peernet-O_tySEFY.js';
2
2
  import './identity-Cn0iQbY3.js';
3
3
  import './value-C3vAp-wb.js';
4
4
 
@@ -16,12 +16,9 @@ declare type Coordinates = {
16
16
  longitude: number;
17
17
  latitude: number;
18
18
  };
19
+ export declare const getAddress: () => Promise<any>;
19
20
  export default class DhtEarth {
20
21
  providerMap: Map<string, DHTProviderMapValue>;
21
- /**
22
- *
23
- */
24
- constructor();
25
22
  getCoordinates(address: string): Promise<Coordinates>;
26
23
  /**
27
24
  * @param {Object} peer
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './peernet-BWKdRXeW.js';
1
+ import { F as FormatInterface } from './peernet-O_tySEFY.js';
2
2
  import './identity-Cn0iQbY3.js';
3
3
  import './value-C3vAp-wb.js';
4
4
 
@@ -50,9 +50,6 @@ var proto$9 = {
50
50
  has: Boolean()
51
51
  };
52
52
 
53
- /**
54
- * @extends typeof {FormatInterface}
55
- */
56
53
  class DHTMessageResponse extends FormatInterface {
57
54
  get messageName() {
58
55
  return 'PeernetDHTMessageResponse'
@@ -7968,9 +7968,9 @@ const lastFetched = {
7968
7968
  const fetchedCoordinates = {};
7969
7969
  const getAddress = async () => {
7970
7970
  const { address } = lastFetched;
7971
- if (address) {
7972
- address.value = await fetch('https://icanhazip.com/');
7973
- address.value = await address.value.text();
7971
+ if (!address) {
7972
+ const value = await fetch('https://icanhazip.com/');
7973
+ address.value = await value.text();
7974
7974
  address.timestamp = Math.round(new Date().getTime() / 1000);
7975
7975
  lastFetched.address = address;
7976
7976
  }
@@ -7991,12 +7991,6 @@ const distanceInKmBetweenEarthCoordinates = (lat1, lon1, lat2, lon2) => {
7991
7991
  };
7992
7992
  class DhtEarth {
7993
7993
  providerMap = new Map();
7994
- /**
7995
- *
7996
- */
7997
- constructor() {
7998
- this.providerMap = new Map();
7999
- }
8000
7994
  async getCoordinates(address) {
8001
7995
  if (!fetchedCoordinates[address]) {
8002
7996
  const request = `https://whereis.leofcoin.org/?ip=${address}`;
@@ -8368,11 +8362,12 @@ class Peernet {
8368
8362
  * @return {Promise} instance of Peernet
8369
8363
  */
8370
8364
  async _init(options, password) {
8365
+ await getAddress();
8371
8366
  this.storePrefix = options.storePrefix;
8372
8367
  this.root = options.root;
8373
8368
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
8374
8369
  // FolderMessageResponse
8375
- } = await import(/* webpackChunkName: "messages" */ './messages-BqTna7yM.js');
8370
+ } = await import(/* webpackChunkName: "messages" */ './messages-DDEOxfJp.js');
8376
8371
  /**
8377
8372
  * proto Object containing protos
8378
8373
  * @type {Object}
@@ -8466,7 +8461,7 @@ class Peernet {
8466
8461
  if (this.#starting || this.#started)
8467
8462
  return;
8468
8463
  this.#starting = true;
8469
- const importee = await import('./client-BGaLaHk2.js');
8464
+ const importee = await import('./client-BDXkFVRR.js');
8470
8465
  /**
8471
8466
  * @access public
8472
8467
  * @type {PeernetClient}
@@ -1,3 +1,3 @@
1
- export { P as default } from './peernet-BWKdRXeW.js';
1
+ export { P as default } from './peernet-O_tySEFY.js';
2
2
  import './identity-Cn0iQbY3.js';
3
3
  import './value-C3vAp-wb.js';
@@ -48,9 +48,6 @@ var proto$9 = {
48
48
  has: Boolean()
49
49
  };
50
50
 
51
- /**
52
- * @extends typeof {FormatInterface}
53
- */
54
51
  class DHTMessageResponse extends FormatInterface {
55
52
  get messageName() {
56
53
  return 'PeernetDHTMessageResponse'
@@ -159,9 +159,9 @@ const lastFetched = {
159
159
  const fetchedCoordinates = {};
160
160
  const getAddress = async () => {
161
161
  const { address } = lastFetched;
162
- if (address) {
163
- address.value = await fetch('https://icanhazip.com/');
164
- address.value = await address.value.text();
162
+ if (!address) {
163
+ const value = await fetch('https://icanhazip.com/');
164
+ address.value = await value.text();
165
165
  address.timestamp = Math.round(new Date().getTime() / 1000);
166
166
  lastFetched.address = address;
167
167
  }
@@ -182,12 +182,6 @@ const distanceInKmBetweenEarthCoordinates = (lat1, lon1, lat2, lon2) => {
182
182
  };
183
183
  class DhtEarth {
184
184
  providerMap = new Map();
185
- /**
186
- *
187
- */
188
- constructor() {
189
- this.providerMap = new Map();
190
- }
191
185
  async getCoordinates(address) {
192
186
  if (!fetchedCoordinates[address]) {
193
187
  const request = `https://whereis.leofcoin.org/?ip=${address}`;
@@ -449,11 +443,12 @@ class Peernet {
449
443
  * @return {Promise} instance of Peernet
450
444
  */
451
445
  async _init(options, password) {
446
+ await getAddress();
452
447
  this.storePrefix = options.storePrefix;
453
448
  this.root = options.root;
454
449
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
455
450
  // FolderMessageResponse
456
- } = await import(/* webpackChunkName: "messages" */ './messages-DFPp9HMC.js');
451
+ } = await import(/* webpackChunkName: "messages" */ './messages-BmpgEM4y.js');
457
452
  /**
458
453
  * proto Object containing protos
459
454
  * @type {Object}
@@ -16,12 +16,9 @@ declare type Coordinates = {
16
16
  longitude: number;
17
17
  latitude: number;
18
18
  };
19
+ export declare const getAddress: () => Promise<any>;
19
20
  export default class DhtEarth {
20
21
  providerMap: Map<string, DHTProviderMapValue>;
21
- /**
22
- *
23
- */
24
- constructor();
25
22
  getCoordinates(address: string): Promise<Coordinates>;
26
23
  /**
27
24
  * @param {Object} peer
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "1.1.95",
3
+ "version": "1.1.97",
4
4
  "description": "",
5
5
  "browser": "./exports/browser/peernet.js",
6
6
  "exports": {
package/src/dht/dht.ts CHANGED
@@ -36,11 +36,11 @@ const lastFetched = {
36
36
 
37
37
  const fetchedCoordinates = {}
38
38
 
39
- const getAddress = async () => {
39
+ export const getAddress = async () => {
40
40
  const { address } = lastFetched
41
- if (address) {
42
- address.value = await fetch('https://icanhazip.com/')
43
- address.value = await address.value.text()
41
+ if (!address) {
42
+ const value = await fetch('https://icanhazip.com/')
43
+ address.value = await value.text()
44
44
  address.timestamp = Math.round(new Date().getTime() / 1000)
45
45
  lastFetched.address = address
46
46
  }
@@ -67,14 +67,7 @@ const distanceInKmBetweenEarthCoordinates = (lat1, lon1, lat2, lon2) => {
67
67
  }
68
68
 
69
69
  export default class DhtEarth {
70
- providerMap = new Map<string, DHTProviderMapValue>()
71
-
72
- /**
73
- *
74
- */
75
- constructor() {
76
- this.providerMap = new Map()
77
- }
70
+ providerMap: Map<string, DHTProviderMapValue> = new Map()
78
71
 
79
72
  async getCoordinates(address: string): Promise<Coordinates> {
80
73
  if (!fetchedCoordinates[address]) {
package/src/peernet.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import '@vandeurenglenn/debug'
2
2
  import PubSub from '@vandeurenglenn/little-pubsub'
3
3
  import PeerDiscovery from './discovery/peer-discovery.js'
4
- import DHT, { DHTProvider, DHTProviderDistanceResult } from './dht/dht.js'
4
+ import DHT, { DHTProvider, DHTProviderDistanceResult, getAddress } from './dht/dht.js'
5
5
  import { BufferToUint8Array, protoFor, target } from './utils/utils.js'
6
6
  import MessageHandler from './handlers/message.js'
7
7
  import dataHandler from './handlers/data.js'
@@ -188,6 +188,7 @@ export default class Peernet {
188
188
  * @return {Promise} instance of Peernet
189
189
  */
190
190
  async _init(options: { storePrefix?: string; root?: string }, password: string): Promise<Peernet> {
191
+ await getAddress()
191
192
  this.storePrefix = options.storePrefix
192
193
  this.root = options.root
193
194
 
@@ -1,7 +0,0 @@
1
- /**
2
- * @extends typeof {FormatInterface}
3
- */
4
- export default class DHTMessageResponse {
5
- constructor(data: any);
6
- get messageName(): string;
7
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * @extends typeof {FormatInterface}
3
- */
4
- export default class DHTMessageResponse {
5
- constructor(data: any);
6
- get messageName(): string;
7
- }