@leofcoin/peernet 1.1.77 → 1.1.79
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/{browser-Ei0BXMlu.js → browser-WUe24rfW.js} +1 -1
- package/exports/browser/{client-A009z8av.js → client-I9x7CFr1.js} +3 -3
- package/exports/browser/{index-YQrIDBUQ.js → index-In1Jzp-v.js} +1 -1
- package/exports/browser/{index-G74WLzL7.js → index-sw14JvKD.js} +1 -1
- package/exports/browser/{messages-lWRTai7t.js → messages-lzTD4EMU.js} +1 -1
- package/exports/browser/{peernet-dyeDQR4X.js → peernet-DULgegxE.js} +22 -14
- package/exports/browser/peernet.d.ts +1 -1
- package/exports/browser/peernet.js +1 -1
- package/exports/peernet.js +19 -11
- package/exports/types/peernet.d.ts +1 -1
- package/package.json +1 -1
- package/src/peernet.ts +17 -13
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { L as LittlePubSub } from './peernet-
|
|
1
|
+
import { L as LittlePubSub } from './peernet-DULgegxE.js';
|
|
2
2
|
import './value-wzPYMxsX.js';
|
|
3
3
|
|
|
4
4
|
class Api {
|
|
@@ -206,7 +206,7 @@ class SocketRequestClient {
|
|
|
206
206
|
const init = async () => {
|
|
207
207
|
// @ts-ignore
|
|
208
208
|
if (!globalThis.WebSocket)
|
|
209
|
-
globalThis.WebSocket = (await import('./browser-
|
|
209
|
+
globalThis.WebSocket = (await import('./browser-WUe24rfW.js').then(function (n) { return n.b; })).default.w3cwebsocket;
|
|
210
210
|
const client = new WebSocket(this.#url, this.#protocol);
|
|
211
211
|
client.onmessage = this.onmessage;
|
|
212
212
|
client.onerror = this.onerror;
|
|
@@ -280,7 +280,7 @@ const iceServers = [
|
|
|
280
280
|
credential: 'openrelayproject'
|
|
281
281
|
}
|
|
282
282
|
];
|
|
283
|
-
const SimplePeer = (await import('./index-
|
|
283
|
+
const SimplePeer = (await import('./index-In1Jzp-v.js').then(function (n) { return n.i; })).default;
|
|
284
284
|
class Peer extends SimplePeer {
|
|
285
285
|
peerId;
|
|
286
286
|
channelName;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { c as commonjsGlobal, r as require$$3, i as inherits_browserExports, g as getDefaultExportFromCjs } from './peernet-
|
|
1
|
+
import { c as commonjsGlobal, r as require$$3, i as inherits_browserExports, g as getDefaultExportFromCjs } from './peernet-DULgegxE.js';
|
|
2
2
|
|
|
3
3
|
var browser$2 = {exports: {}};
|
|
4
4
|
|
|
@@ -27109,7 +27109,7 @@ class Identity {
|
|
|
27109
27109
|
this.selectedAccount = new TextDecoder().decode(selected);
|
|
27110
27110
|
}
|
|
27111
27111
|
else {
|
|
27112
|
-
const importee = await import(/* webpackChunkName: "generate-account" */ './index-
|
|
27112
|
+
const importee = await import(/* webpackChunkName: "generate-account" */ './index-sw14JvKD.js');
|
|
27113
27113
|
const { identity, accounts } = await importee.default(password, this.network);
|
|
27114
27114
|
await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
|
|
27115
27115
|
await globalThis.walletStore.put('version', String(1));
|
|
@@ -27301,7 +27301,7 @@ class Peernet {
|
|
|
27301
27301
|
this.root = options.root;
|
|
27302
27302
|
const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
|
|
27303
27303
|
// FolderMessageResponse
|
|
27304
|
-
} = await import(/* webpackChunkName: "messages" */ './messages-
|
|
27304
|
+
} = await import(/* webpackChunkName: "messages" */ './messages-lzTD4EMU.js');
|
|
27305
27305
|
/**
|
|
27306
27306
|
* proto Object containing protos
|
|
27307
27307
|
* @type {Object}
|
|
@@ -27395,7 +27395,7 @@ class Peernet {
|
|
|
27395
27395
|
if (this.#starting || this.#started)
|
|
27396
27396
|
return;
|
|
27397
27397
|
this.#starting = true;
|
|
27398
|
-
const importee = await import('./client-
|
|
27398
|
+
const importee = await import('./client-I9x7CFr1.js');
|
|
27399
27399
|
/**
|
|
27400
27400
|
* @access public
|
|
27401
27401
|
* @type {PeernetClient}
|
|
@@ -27464,18 +27464,26 @@ class Peernet {
|
|
|
27464
27464
|
async handleData(peer, id, proto) {
|
|
27465
27465
|
let { hash, store } = proto.decoded;
|
|
27466
27466
|
let data;
|
|
27467
|
-
|
|
27468
|
-
|
|
27469
|
-
|
|
27470
|
-
|
|
27471
|
-
data
|
|
27472
|
-
|
|
27473
|
-
|
|
27474
|
-
|
|
27475
|
-
|
|
27476
|
-
|
|
27467
|
+
try {
|
|
27468
|
+
store = globalThis[`${store}Store`] || (await this.whichStore([...this.stores], hash));
|
|
27469
|
+
if (store && !store.private) {
|
|
27470
|
+
data = await store.get(hash);
|
|
27471
|
+
if (data) {
|
|
27472
|
+
data = await new globalThis.peernet.protos['peernet-data-response']({
|
|
27473
|
+
hash,
|
|
27474
|
+
data
|
|
27475
|
+
});
|
|
27476
|
+
const node = await this.prepareMessage(data);
|
|
27477
|
+
this.sendMessage(peer, id, node.encoded);
|
|
27478
|
+
}
|
|
27479
|
+
}
|
|
27480
|
+
else {
|
|
27481
|
+
// ban (trying to access private st)
|
|
27477
27482
|
}
|
|
27478
27483
|
}
|
|
27484
|
+
catch (error) {
|
|
27485
|
+
return this.requestData(hash, store);
|
|
27486
|
+
}
|
|
27479
27487
|
}
|
|
27480
27488
|
async handleRequest(peer, id, proto) {
|
|
27481
27489
|
const method = this.requestProtos[proto.decoded.request];
|
|
@@ -27552,7 +27560,7 @@ class Peernet {
|
|
|
27552
27560
|
let providers = this.dht.providersFor(hash);
|
|
27553
27561
|
// walk the network to find a provider
|
|
27554
27562
|
let tries = 0;
|
|
27555
|
-
while ((!providers && tries < 3) || (Object.keys(providers).length === 0 && tries < 3)) {
|
|
27563
|
+
while ((!providers && tries < 3) || (providers && Object.keys(providers).length === 0 && tries < 3)) {
|
|
27556
27564
|
tries += 1;
|
|
27557
27565
|
await this.walk(hash);
|
|
27558
27566
|
providers = this.dht.providersFor(hash);
|
|
@@ -108,7 +108,7 @@ export default class Peernet {
|
|
|
108
108
|
addRequestHandler(name: any, method: any): void;
|
|
109
109
|
sendMessage(peer: any, id: any, data: any): Promise<any>;
|
|
110
110
|
handleDHT(peer: any, id: any, proto: any): Promise<void>;
|
|
111
|
-
handleData(peer: any, id: any, proto: any): Promise<
|
|
111
|
+
handleData(peer: any, id: any, proto: any): Promise<any>;
|
|
112
112
|
handleRequest(peer: any, id: any, proto: any): Promise<void>;
|
|
113
113
|
/**
|
|
114
114
|
* @private
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { P as default } from './peernet-
|
|
1
|
+
export { P as default } from './peernet-DULgegxE.js';
|
|
2
2
|
import './value-wzPYMxsX.js';
|
package/exports/peernet.js
CHANGED
|
@@ -704,18 +704,26 @@ class Peernet {
|
|
|
704
704
|
async handleData(peer, id, proto) {
|
|
705
705
|
let { hash, store } = proto.decoded;
|
|
706
706
|
let data;
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
data
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
707
|
+
try {
|
|
708
|
+
store = globalThis[`${store}Store`] || (await this.whichStore([...this.stores], hash));
|
|
709
|
+
if (store && !store.private) {
|
|
710
|
+
data = await store.get(hash);
|
|
711
|
+
if (data) {
|
|
712
|
+
data = await new globalThis.peernet.protos['peernet-data-response']({
|
|
713
|
+
hash,
|
|
714
|
+
data
|
|
715
|
+
});
|
|
716
|
+
const node = await this.prepareMessage(data);
|
|
717
|
+
this.sendMessage(peer, id, node.encoded);
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
else {
|
|
721
|
+
// ban (trying to access private st)
|
|
717
722
|
}
|
|
718
723
|
}
|
|
724
|
+
catch (error) {
|
|
725
|
+
return this.requestData(hash, store);
|
|
726
|
+
}
|
|
719
727
|
}
|
|
720
728
|
async handleRequest(peer, id, proto) {
|
|
721
729
|
const method = this.requestProtos[proto.decoded.request];
|
|
@@ -792,7 +800,7 @@ class Peernet {
|
|
|
792
800
|
let providers = this.dht.providersFor(hash);
|
|
793
801
|
// walk the network to find a provider
|
|
794
802
|
let tries = 0;
|
|
795
|
-
while ((!providers && tries < 3) || (Object.keys(providers).length === 0 && tries < 3)) {
|
|
803
|
+
while ((!providers && tries < 3) || (providers && Object.keys(providers).length === 0 && tries < 3)) {
|
|
796
804
|
tries += 1;
|
|
797
805
|
await this.walk(hash);
|
|
798
806
|
providers = this.dht.providersFor(hash);
|
|
@@ -108,7 +108,7 @@ export default class Peernet {
|
|
|
108
108
|
addRequestHandler(name: any, method: any): void;
|
|
109
109
|
sendMessage(peer: any, id: any, data: any): Promise<any>;
|
|
110
110
|
handleDHT(peer: any, id: any, proto: any): Promise<void>;
|
|
111
|
-
handleData(peer: any, id: any, proto: any): Promise<
|
|
111
|
+
handleData(peer: any, id: any, proto: any): Promise<any>;
|
|
112
112
|
handleRequest(peer: any, id: any, proto: any): Promise<void>;
|
|
113
113
|
/**
|
|
114
114
|
* @private
|
package/package.json
CHANGED
package/src/peernet.ts
CHANGED
|
@@ -390,22 +390,26 @@ export default class Peernet {
|
|
|
390
390
|
async handleData(peer, id, proto) {
|
|
391
391
|
let { hash, store } = proto.decoded
|
|
392
392
|
let data
|
|
393
|
-
|
|
393
|
+
try {
|
|
394
|
+
store = globalThis[`${store}Store`] || (await this.whichStore([...this.stores], hash))
|
|
394
395
|
|
|
395
|
-
|
|
396
|
-
|
|
396
|
+
if (store && !store.private) {
|
|
397
|
+
data = await store.get(hash)
|
|
397
398
|
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
399
|
+
if (data) {
|
|
400
|
+
data = await new globalThis.peernet.protos['peernet-data-response']({
|
|
401
|
+
hash,
|
|
402
|
+
data
|
|
403
|
+
})
|
|
403
404
|
|
|
404
|
-
|
|
405
|
-
|
|
405
|
+
const node = await this.prepareMessage(data)
|
|
406
|
+
this.sendMessage(peer, id, node.encoded)
|
|
407
|
+
}
|
|
408
|
+
} else {
|
|
409
|
+
// ban (trying to access private st)
|
|
406
410
|
}
|
|
407
|
-
}
|
|
408
|
-
|
|
411
|
+
} catch (error) {
|
|
412
|
+
return this.requestData(hash, store)
|
|
409
413
|
}
|
|
410
414
|
}
|
|
411
415
|
|
|
@@ -488,7 +492,7 @@ export default class Peernet {
|
|
|
488
492
|
let providers = this.dht.providersFor(hash)
|
|
489
493
|
// walk the network to find a provider
|
|
490
494
|
let tries = 0
|
|
491
|
-
while ((!providers && tries < 3) || (Object.keys(providers).length === 0 && tries < 3)) {
|
|
495
|
+
while ((!providers && tries < 3) || (providers && Object.keys(providers).length === 0 && tries < 3)) {
|
|
492
496
|
tries += 1
|
|
493
497
|
await this.walk(hash)
|
|
494
498
|
providers = this.dht.providersFor(hash)
|