@leofcoin/peernet 1.1.22 → 1.1.24
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/exports/browser/{client-91364a04.js → client-31b62450.js} +1 -1
- package/exports/browser/{index-2c7d7136.js → index-e407f1a3.js} +1 -1
- package/exports/browser/{messages-bcb7873b.js → messages-2465e07d.js} +1 -1
- package/exports/browser/{peernet-1256dbee.js → peernet-805b1e8e.js} +23 -18
- package/exports/browser/peernet.js +1 -1
- package/exports/peernet.js +9 -6
- package/package.json +1 -1
- package/src/dht/dht.js +10 -6
|
@@ -4785,12 +4785,13 @@ const isUint8Array$1 = (type) => type === 'uint8Array';
|
|
|
4785
4785
|
const isBigNumber = (type) => type === 'bigNumber';
|
|
4786
4786
|
const tokenize = (key, value) => {
|
|
4787
4787
|
const optional = key.endsWith('?');
|
|
4788
|
-
let type = value;
|
|
4789
|
-
|
|
4790
|
-
if (value instanceof Uint8Array)
|
|
4788
|
+
let type = value === undefined ? key : value;
|
|
4789
|
+
if (type instanceof Uint8Array)
|
|
4791
4790
|
type = 'uint8Array';
|
|
4792
|
-
else if (
|
|
4791
|
+
else if (type?._isBigNumber || type.isBigNumber)
|
|
4793
4792
|
type = 'bigNumber';
|
|
4793
|
+
else
|
|
4794
|
+
type = Array.isArray(type) ? 'array' : typeof type;
|
|
4794
4795
|
const parts = key.split('?');
|
|
4795
4796
|
const minimumLength = parts[2]?.includes('min') ? parts[2].split['min:'][1] : 0;
|
|
4796
4797
|
return { type, optional, key: parts[0], minimumLength };
|
|
@@ -4802,6 +4803,7 @@ const toType = (data) => {
|
|
|
4802
4803
|
// returns the ArrayBuffer as a UintArray
|
|
4803
4804
|
if (data instanceof ArrayBuffer)
|
|
4804
4805
|
return new Uint8Array(data);
|
|
4806
|
+
// returns the bigNumbers hex as a UintArray
|
|
4805
4807
|
if (data._isBigNumber)
|
|
4806
4808
|
return new TextEncoder().encode(data._hex || data.toHexString());
|
|
4807
4809
|
// returns the string as a UintArray
|
|
@@ -4815,11 +4817,11 @@ const toType = (data) => {
|
|
|
4815
4817
|
return new TextEncoder().encode(data.toString());
|
|
4816
4818
|
throw new Error(`unsuported type ${typeof data || data}`);
|
|
4817
4819
|
};
|
|
4818
|
-
const encode$3 = (proto, input) => {
|
|
4820
|
+
const encode$3 = (proto, input, compress) => {
|
|
4819
4821
|
const keys = Object.keys(proto);
|
|
4820
4822
|
const values = Object.values(proto);
|
|
4821
4823
|
const set = [];
|
|
4822
|
-
for (let i = 0; i <
|
|
4824
|
+
for (let i = 0; i < values.length; i++) {
|
|
4823
4825
|
const token = tokenize(keys[i], values[i]);
|
|
4824
4826
|
const data = input[token.key];
|
|
4825
4827
|
if (!token.optional && data === undefined)
|
|
@@ -4832,14 +4834,14 @@ const encode$3 = (proto, input) => {
|
|
|
4832
4834
|
}
|
|
4833
4835
|
return index$6(set);
|
|
4834
4836
|
};
|
|
4835
|
-
const decode$4 = (proto, uint8Array) => {
|
|
4837
|
+
const decode$4 = (proto, uint8Array, compressed) => {
|
|
4836
4838
|
let deconcated = index$5(uint8Array);
|
|
4837
4839
|
const output = {};
|
|
4838
4840
|
const keys = Object.keys(proto);
|
|
4839
4841
|
const values = Object.values(proto);
|
|
4840
4842
|
if (keys.length !== deconcated.length)
|
|
4841
4843
|
console.warn(`length mismatch: expected ${keys.length} got ${uint8Array.length}`);
|
|
4842
|
-
for (let i = 0; i <
|
|
4844
|
+
for (let i = 0; i < values.length; i++) {
|
|
4843
4845
|
const token = tokenize(keys[i], values[i]);
|
|
4844
4846
|
if (isUint8Array$1(token.type))
|
|
4845
4847
|
output[token.key] = deconcated[i];
|
|
@@ -5926,7 +5928,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface$1 {
|
|
|
5926
5928
|
this.fromUint8Array(buffer);
|
|
5927
5929
|
else if (buffer instanceof ArrayBuffer)
|
|
5928
5930
|
this.fromArrayBuffer(buffer);
|
|
5929
|
-
else if (buffer instanceof FormatInterface
|
|
5931
|
+
else if (buffer instanceof FormatInterface && buffer?.name === this.name)
|
|
5930
5932
|
return buffer;
|
|
5931
5933
|
else if (typeof buffer === 'string') {
|
|
5932
5934
|
if (this.isHex(buffer))
|
|
@@ -6198,6 +6200,7 @@ const lastFetched = {
|
|
|
6198
6200
|
timestamp: 0,
|
|
6199
6201
|
},
|
|
6200
6202
|
};
|
|
6203
|
+
const fetchedCoordinates = {};
|
|
6201
6204
|
const getAddress = async () => {
|
|
6202
6205
|
const { address } = lastFetched;
|
|
6203
6206
|
const now = Math.round(new Date().getTime() / 1000);
|
|
@@ -6235,12 +6238,14 @@ class DhtEarth {
|
|
|
6235
6238
|
* @return {Object} {latitude: lat, longitude: lon}
|
|
6236
6239
|
*/
|
|
6237
6240
|
async getCoordinates(address) {
|
|
6238
|
-
|
|
6239
|
-
|
|
6240
|
-
|
|
6241
|
-
|
|
6242
|
-
|
|
6243
|
-
|
|
6241
|
+
if (!fetchedCoordinates[address]) {
|
|
6242
|
+
const request = `https://whereis.leofcoin.org/?ip=${address}`;
|
|
6243
|
+
let response = await fetch(request);
|
|
6244
|
+
response = await response.json();
|
|
6245
|
+
const { lat, lon } = response;
|
|
6246
|
+
fetchedCoordinates[address] = { latitude: lat, longitude: lon };
|
|
6247
|
+
}
|
|
6248
|
+
return fetchedCoordinates[address];
|
|
6244
6249
|
}
|
|
6245
6250
|
/**
|
|
6246
6251
|
* @param {Object} peer
|
|
@@ -20180,7 +20185,7 @@ class Identity {
|
|
|
20180
20185
|
globalThis.peernet.selectedAccount = new TextDecoder().decode(selected);
|
|
20181
20186
|
}
|
|
20182
20187
|
else {
|
|
20183
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
20188
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-e407f1a3.js');
|
|
20184
20189
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
20185
20190
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
20186
20191
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -20351,7 +20356,7 @@ class Peernet {
|
|
|
20351
20356
|
this.root = options.root;
|
|
20352
20357
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
20353
20358
|
// FolderMessageResponse
|
|
20354
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
20359
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-2465e07d.js');
|
|
20355
20360
|
/**
|
|
20356
20361
|
* proto Object containing protos
|
|
20357
20362
|
* @type {Object}
|
|
@@ -20423,7 +20428,7 @@ class Peernet {
|
|
|
20423
20428
|
if (this.#starting || this.#started)
|
|
20424
20429
|
return;
|
|
20425
20430
|
this.#starting = true;
|
|
20426
|
-
const importee = await import('./client-
|
|
20431
|
+
const importee = await import('./client-31b62450.js');
|
|
20427
20432
|
/**
|
|
20428
20433
|
* @access public
|
|
20429
20434
|
* @type {PeernetClient}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { P as default } from './peernet-
|
|
1
|
+
export { P as default } from './peernet-805b1e8e.js';
|
|
2
2
|
import './value-157ab062.js';
|
package/exports/peernet.js
CHANGED
|
@@ -161,6 +161,7 @@ const lastFetched = {
|
|
|
161
161
|
timestamp: 0,
|
|
162
162
|
},
|
|
163
163
|
};
|
|
164
|
+
const fetchedCoordinates = {};
|
|
164
165
|
const getAddress = async () => {
|
|
165
166
|
const { address } = lastFetched;
|
|
166
167
|
const now = Math.round(new Date().getTime() / 1000);
|
|
@@ -198,12 +199,14 @@ class DhtEarth {
|
|
|
198
199
|
* @return {Object} {latitude: lat, longitude: lon}
|
|
199
200
|
*/
|
|
200
201
|
async getCoordinates(address) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
202
|
+
if (!fetchedCoordinates[address]) {
|
|
203
|
+
const request = `https://whereis.leofcoin.org/?ip=${address}`;
|
|
204
|
+
let response = await fetch(request);
|
|
205
|
+
response = await response.json();
|
|
206
|
+
const { lat, lon } = response;
|
|
207
|
+
fetchedCoordinates[address] = { latitude: lat, longitude: lon };
|
|
208
|
+
}
|
|
209
|
+
return fetchedCoordinates[address];
|
|
207
210
|
}
|
|
208
211
|
/**
|
|
209
212
|
* @param {Object} peer
|
package/package.json
CHANGED
package/src/dht/dht.js
CHANGED
|
@@ -14,6 +14,8 @@ const lastFetched = {
|
|
|
14
14
|
},
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
const fetchedCoordinates = {}
|
|
18
|
+
|
|
17
19
|
const getAddress = async () => {
|
|
18
20
|
const {address} = lastFetched
|
|
19
21
|
const now = Math.round(new Date().getTime() / 1000);
|
|
@@ -58,12 +60,14 @@ export default class DhtEarth {
|
|
|
58
60
|
* @return {Object} {latitude: lat, longitude: lon}
|
|
59
61
|
*/
|
|
60
62
|
async getCoordinates(address) {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
if (!fetchedCoordinates[address]) {
|
|
64
|
+
const request = `https://whereis.leofcoin.org/?ip=${address}`
|
|
65
|
+
let response = await fetch(request)
|
|
66
|
+
response = await response.json()
|
|
67
|
+
const {lat, lon} = response;
|
|
68
|
+
fetchedCoordinates[address] = {latitude: lat, longitude: lon}
|
|
69
|
+
}
|
|
70
|
+
return fetchedCoordinates[address]
|
|
67
71
|
}
|
|
68
72
|
|
|
69
73
|
/**
|