@leofcoin/peernet 0.14.7 → 0.14.9

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.
@@ -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(new TextDecoder().decode(proto.decoded.topic), proto.decoded.data);
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);
@@ -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) {
@@ -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(new TextDecoder().decode(proto.decoded.topic), proto.decoded.data);
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);
@@ -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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "0.14.7",
3
+ "version": "0.14.9",
4
4
  "description": "",
5
5
  "source": "src/peernet.js",
6
6
  "main": "dist/commonjs/peernet.js",
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(new TextDecoder().decode(proto.decoded.topic), proto.decoded.data)
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)
@@ -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) {