@leofcoin/peernet 0.14.8 → 0.14.10
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/dist/browser/peernet.js +5 -7
- package/dist/commonjs/peernet.js +5 -7
- package/dist/module/peernet.js +5 -7
- package/package.json +1 -1
- package/src/peernet.js +5 -7
package/dist/browser/peernet.js
CHANGED
|
@@ -945,9 +945,9 @@ class Peernet {
|
|
|
945
945
|
const accountExists = await accountStore.has('public');
|
|
946
946
|
if (accountExists) {
|
|
947
947
|
const pub = await accountStore.get('public');
|
|
948
|
-
this.id = JSON.parse(pub).walletId;
|
|
948
|
+
this.id = JSON.parse(new TextDecoder().decode(pub)).walletId;
|
|
949
949
|
let accounts = await walletStore.get('accounts');
|
|
950
|
-
|
|
950
|
+
accounts = new TextDecoder().decode(accounts);
|
|
951
951
|
|
|
952
952
|
|
|
953
953
|
// fixing account issue (string while needs to be a JSON)
|
|
@@ -1067,7 +1067,7 @@ class Peernet {
|
|
|
1067
1067
|
this.sendMessage(peer, id, node.encoded);
|
|
1068
1068
|
}
|
|
1069
1069
|
} else if (proto.name === 'peernet-ps' && peer.peerId !== this.id) {
|
|
1070
|
-
globalSub.publish(
|
|
1070
|
+
globalSub.publish(proto.decoded.topic, proto.decoded.data);
|
|
1071
1071
|
}
|
|
1072
1072
|
// }
|
|
1073
1073
|
}
|
|
@@ -1100,7 +1100,7 @@ class Peernet {
|
|
|
1100
1100
|
family: peer.connection.remoteFamily || peer.connection.localFamily,
|
|
1101
1101
|
address: peer.connection.remoteAddress || peer.connection.localAddress,
|
|
1102
1102
|
port: peer.connection.remotePort || peer.connection.localPort,
|
|
1103
|
-
id: peerId,
|
|
1103
|
+
id: peer.peerId,
|
|
1104
1104
|
};
|
|
1105
1105
|
|
|
1106
1106
|
if (proto.decoded.has) this.dht.addProvider(peerInfo, proto.decoded.hash);
|
|
@@ -1197,7 +1197,7 @@ class Peernet {
|
|
|
1197
1197
|
}
|
|
1198
1198
|
console.log({data});
|
|
1199
1199
|
data = new Uint8Array(Object.values(data));
|
|
1200
|
-
proto = await protoFor(data);
|
|
1200
|
+
const proto = await protoFor(data);
|
|
1201
1201
|
// TODO: store data automaticly or not
|
|
1202
1202
|
return proto.decoded.data
|
|
1203
1203
|
|
|
@@ -1400,8 +1400,6 @@ class Peernet {
|
|
|
1400
1400
|
*/
|
|
1401
1401
|
async publish(topic, data) {
|
|
1402
1402
|
// globalSub.publish(topic, data)
|
|
1403
|
-
if (topic instanceof Uint8Array === false) topic = new TextEncoder().encode(topic);
|
|
1404
|
-
if (data instanceof Uint8Array === false) data = new TextEncoder().encode(JSON.stringify(data));
|
|
1405
1403
|
const id = Math.random().toString(36).slice(-12);
|
|
1406
1404
|
data = await new globalThis.peernet.protos['peernet-ps']({data, topic});
|
|
1407
1405
|
for (const peer of this.connections) {
|
package/dist/commonjs/peernet.js
CHANGED
|
@@ -616,9 +616,9 @@ class Peernet {
|
|
|
616
616
|
const accountExists = await accountStore.has('public');
|
|
617
617
|
if (accountExists) {
|
|
618
618
|
const pub = await accountStore.get('public');
|
|
619
|
-
this.id = JSON.parse(pub).walletId;
|
|
619
|
+
this.id = JSON.parse(new TextDecoder().decode(pub)).walletId;
|
|
620
620
|
let accounts = await walletStore.get('accounts');
|
|
621
|
-
|
|
621
|
+
accounts = new TextDecoder().decode(accounts);
|
|
622
622
|
|
|
623
623
|
|
|
624
624
|
// fixing account issue (string while needs to be a JSON)
|
|
@@ -738,7 +738,7 @@ class Peernet {
|
|
|
738
738
|
this.sendMessage(peer, id, node.encoded);
|
|
739
739
|
}
|
|
740
740
|
} else if (proto.name === 'peernet-ps' && peer.peerId !== this.id) {
|
|
741
|
-
globalSub.publish(
|
|
741
|
+
globalSub.publish(proto.decoded.topic, proto.decoded.data);
|
|
742
742
|
}
|
|
743
743
|
// }
|
|
744
744
|
}
|
|
@@ -771,7 +771,7 @@ class Peernet {
|
|
|
771
771
|
family: peer.connection.remoteFamily || peer.connection.localFamily,
|
|
772
772
|
address: peer.connection.remoteAddress || peer.connection.localAddress,
|
|
773
773
|
port: peer.connection.remotePort || peer.connection.localPort,
|
|
774
|
-
id: peerId,
|
|
774
|
+
id: peer.peerId,
|
|
775
775
|
};
|
|
776
776
|
|
|
777
777
|
if (proto.decoded.has) this.dht.addProvider(peerInfo, proto.decoded.hash);
|
|
@@ -868,7 +868,7 @@ class Peernet {
|
|
|
868
868
|
}
|
|
869
869
|
console.log({data});
|
|
870
870
|
data = new Uint8Array(Object.values(data));
|
|
871
|
-
proto = await protoFor(data);
|
|
871
|
+
const proto = await protoFor(data);
|
|
872
872
|
// TODO: store data automaticly or not
|
|
873
873
|
return proto.decoded.data
|
|
874
874
|
|
|
@@ -1071,8 +1071,6 @@ class Peernet {
|
|
|
1071
1071
|
*/
|
|
1072
1072
|
async publish(topic, data) {
|
|
1073
1073
|
// globalSub.publish(topic, data)
|
|
1074
|
-
if (topic instanceof Uint8Array === false) topic = new TextEncoder().encode(topic);
|
|
1075
|
-
if (data instanceof Uint8Array === false) data = new TextEncoder().encode(JSON.stringify(data));
|
|
1076
1074
|
const id = Math.random().toString(36).slice(-12);
|
|
1077
1075
|
data = await new globalThis.peernet.protos['peernet-ps']({data, topic});
|
|
1078
1076
|
for (const peer of this.connections) {
|
package/dist/module/peernet.js
CHANGED
|
@@ -614,9 +614,9 @@ class Peernet {
|
|
|
614
614
|
const accountExists = await accountStore.has('public');
|
|
615
615
|
if (accountExists) {
|
|
616
616
|
const pub = await accountStore.get('public');
|
|
617
|
-
this.id = JSON.parse(pub).walletId;
|
|
617
|
+
this.id = JSON.parse(new TextDecoder().decode(pub)).walletId;
|
|
618
618
|
let accounts = await walletStore.get('accounts');
|
|
619
|
-
|
|
619
|
+
accounts = new TextDecoder().decode(accounts);
|
|
620
620
|
|
|
621
621
|
|
|
622
622
|
// fixing account issue (string while needs to be a JSON)
|
|
@@ -736,7 +736,7 @@ class Peernet {
|
|
|
736
736
|
this.sendMessage(peer, id, node.encoded);
|
|
737
737
|
}
|
|
738
738
|
} else if (proto.name === 'peernet-ps' && peer.peerId !== this.id) {
|
|
739
|
-
globalSub.publish(
|
|
739
|
+
globalSub.publish(proto.decoded.topic, proto.decoded.data);
|
|
740
740
|
}
|
|
741
741
|
// }
|
|
742
742
|
}
|
|
@@ -769,7 +769,7 @@ class Peernet {
|
|
|
769
769
|
family: peer.connection.remoteFamily || peer.connection.localFamily,
|
|
770
770
|
address: peer.connection.remoteAddress || peer.connection.localAddress,
|
|
771
771
|
port: peer.connection.remotePort || peer.connection.localPort,
|
|
772
|
-
id: peerId,
|
|
772
|
+
id: peer.peerId,
|
|
773
773
|
};
|
|
774
774
|
|
|
775
775
|
if (proto.decoded.has) this.dht.addProvider(peerInfo, proto.decoded.hash);
|
|
@@ -866,7 +866,7 @@ class Peernet {
|
|
|
866
866
|
}
|
|
867
867
|
console.log({data});
|
|
868
868
|
data = new Uint8Array(Object.values(data));
|
|
869
|
-
proto = await protoFor(data);
|
|
869
|
+
const proto = await protoFor(data);
|
|
870
870
|
// TODO: store data automaticly or not
|
|
871
871
|
return proto.decoded.data
|
|
872
872
|
|
|
@@ -1069,8 +1069,6 @@ class Peernet {
|
|
|
1069
1069
|
*/
|
|
1070
1070
|
async publish(topic, data) {
|
|
1071
1071
|
// globalSub.publish(topic, data)
|
|
1072
|
-
if (topic instanceof Uint8Array === false) topic = new TextEncoder().encode(topic);
|
|
1073
|
-
if (data instanceof Uint8Array === false) data = new TextEncoder().encode(JSON.stringify(data));
|
|
1074
1072
|
const id = Math.random().toString(36).slice(-12);
|
|
1075
1073
|
data = await new globalThis.peernet.protos['peernet-ps']({data, topic});
|
|
1076
1074
|
for (const peer of this.connections) {
|
package/package.json
CHANGED
package/src/peernet.js
CHANGED
|
@@ -199,9 +199,9 @@ export default class Peernet {
|
|
|
199
199
|
const accountExists = await accountStore.has('public')
|
|
200
200
|
if (accountExists) {
|
|
201
201
|
const pub = await accountStore.get('public')
|
|
202
|
-
this.id = JSON.parse(pub).walletId
|
|
202
|
+
this.id = JSON.parse(new TextDecoder().decode(pub)).walletId;
|
|
203
203
|
let accounts = await walletStore.get('accounts')
|
|
204
|
-
|
|
204
|
+
accounts = new TextDecoder().decode(accounts)
|
|
205
205
|
|
|
206
206
|
|
|
207
207
|
// fixing account issue (string while needs to be a JSON)
|
|
@@ -325,7 +325,7 @@ export default class Peernet {
|
|
|
325
325
|
this.sendMessage(peer, id, node.encoded)
|
|
326
326
|
}
|
|
327
327
|
} else if (proto.name === 'peernet-ps' && peer.peerId !== this.id) {
|
|
328
|
-
globalSub.publish(
|
|
328
|
+
globalSub.publish(proto.decoded.topic, proto.decoded.data)
|
|
329
329
|
}
|
|
330
330
|
// }
|
|
331
331
|
}
|
|
@@ -358,7 +358,7 @@ export default class Peernet {
|
|
|
358
358
|
family: peer.connection.remoteFamily || peer.connection.localFamily,
|
|
359
359
|
address: peer.connection.remoteAddress || peer.connection.localAddress,
|
|
360
360
|
port: peer.connection.remotePort || peer.connection.localPort,
|
|
361
|
-
id: peerId,
|
|
361
|
+
id: peer.peerId,
|
|
362
362
|
}
|
|
363
363
|
|
|
364
364
|
if (proto.decoded.has) this.dht.addProvider(peerInfo, proto.decoded.hash)
|
|
@@ -455,7 +455,7 @@ export default class Peernet {
|
|
|
455
455
|
}
|
|
456
456
|
console.log({data});
|
|
457
457
|
data = new Uint8Array(Object.values(data))
|
|
458
|
-
proto = await protoFor(data)
|
|
458
|
+
const proto = await protoFor(data)
|
|
459
459
|
// TODO: store data automaticly or not
|
|
460
460
|
return proto.decoded.data
|
|
461
461
|
|
|
@@ -659,8 +659,6 @@ export default class Peernet {
|
|
|
659
659
|
*/
|
|
660
660
|
async publish(topic, data) {
|
|
661
661
|
// globalSub.publish(topic, data)
|
|
662
|
-
if (topic instanceof Uint8Array === false) topic = new TextEncoder().encode(topic)
|
|
663
|
-
if (data instanceof Uint8Array === false) data = new TextEncoder().encode(JSON.stringify(data))
|
|
664
662
|
const id = Math.random().toString(36).slice(-12)
|
|
665
663
|
data = await new globalThis.peernet.protos['peernet-ps']({data, topic})
|
|
666
664
|
for (const peer of this.connections) {
|