@leofcoin/peernet 0.18.5 → 0.18.7

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-1582ad5b.js';
1
+ import { L as LittlePubSub } from './peernet-29c659a0.js';
2
2
  import './value-40634404.js';
3
3
 
4
4
  var clientApi = _pubsub => {
@@ -1,5 +1,5 @@
1
- import MultiWallet from './index-54cdabb4.js';
2
- import './peernet-1582ad5b.js';
1
+ import MultiWallet from './index-f3625c4a.js';
2
+ import './peernet-29c659a0.js';
3
3
  import './value-40634404.js';
4
4
 
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { b as base58$1, i as index$1, a as index$2, c as index$3, d as index$4, e as createRIPEMD160, f as createHMAC, g as createSHA512, h as createKeccak } from './peernet-1582ad5b.js';
1
+ import { b as base58$1, i as index$1, a as index$2, c as index$3, d as index$4, e as createRIPEMD160, f as createHMAC, g as createSHA512, h as createKeccak } from './peernet-29c659a0.js';
2
2
  import './value-40634404.js';
3
3
 
4
4
  const randombytes = strength => crypto.getRandomValues(new Uint8Array(strength));
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './peernet-1582ad5b.js';
1
+ import { F as FormatInterface } from './peernet-29c659a0.js';
2
2
  import './value-40634404.js';
3
3
 
4
4
  var proto$b = {
@@ -121,7 +121,7 @@ class RequestMessage extends FormatInterface {
121
121
  }
122
122
 
123
123
  var proto$4 = {
124
- response: new Uint8Array()
124
+ response: {}
125
125
  };
126
126
 
127
127
  class ResponseMessage extends FormatInterface {
@@ -1395,7 +1395,7 @@ const addCodec = (codecInput) => {
1395
1395
  if (!globalThis.peernetCodecs[name])
1396
1396
  globalThis.peernetCodecs[name] = {
1397
1397
  hashAlg,
1398
- codec: isNaN(codec) ? parseInt(codec, 16) : codec
1398
+ codec: typeof codec === 'string' ? parseInt(codec, 16) : codec
1399
1399
  };
1400
1400
  };
1401
1401
  const getCodec = (name) => {
@@ -1539,26 +1539,6 @@ let BasicInterface$1 = class BasicInterface {
1539
1539
  this.encode();
1540
1540
  return toBase58(this.encoded);
1541
1541
  }
1542
- /**
1543
- * @param {Object} data
1544
- */
1545
- create(data) {
1546
- const decoded = {};
1547
- if (this.keys?.length > 0) {
1548
- for (const key of this.keys) {
1549
- Object.defineProperties(decoded, {
1550
- [key]: {
1551
- enumerable: true,
1552
- configurable: true,
1553
- set: (value) => data[key],
1554
- get: () => data[key]
1555
- }
1556
- });
1557
- }
1558
- this.decoded = decoded;
1559
- return this.encode(decoded);
1560
- }
1561
- }
1562
1542
  };
1563
1543
 
1564
1544
  let Codec$1 = class Codec extends BasicInterface$1 {
@@ -1577,7 +1557,7 @@ let Codec$1 = class Codec extends BasicInterface$1 {
1577
1557
  this.decode(buffer);
1578
1558
  }
1579
1559
  else {
1580
- this.encode(buffer);
1560
+ this.encode(Number(new TextDecoder().decode(buffer)));
1581
1561
  }
1582
1562
  }
1583
1563
  else if (buffer instanceof ArrayBuffer) {
@@ -1588,7 +1568,7 @@ let Codec$1 = class Codec extends BasicInterface$1 {
1588
1568
  this.decode(buffer);
1589
1569
  }
1590
1570
  else {
1591
- this.encode(buffer);
1571
+ this.encode(Number(new TextDecoder().decode(new Uint8Array(buffer))));
1592
1572
  }
1593
1573
  }
1594
1574
  else if (typeof buffer === 'string') {
@@ -1601,7 +1581,7 @@ let Codec$1 = class Codec extends BasicInterface$1 {
1601
1581
  else if (this.isBase58(buffer))
1602
1582
  this.fromBs58(buffer);
1603
1583
  else
1604
- throw new Error(`unsupported string ${buffer}`);
1584
+ this.fromString(buffer);
1605
1585
  }
1606
1586
  if (!isNaN(buffer))
1607
1587
  if (utils.getCodec(buffer))
@@ -1628,14 +1608,14 @@ let Codec$1 = class Codec extends BasicInterface$1 {
1628
1608
  this.name = this.getCodecName(codec);
1629
1609
  this.hashAlg = this.getHashAlg(this.name);
1630
1610
  this.codec = this.getCodec(this.name);
1631
- this.codecBuffer = index$6.encode(codec);
1611
+ this.codecBuffer = index$6.encode(this.codec);
1632
1612
  }
1633
1613
  fromName(name) {
1634
1614
  const codec = this.getCodec(name);
1635
1615
  this.name = name;
1636
1616
  this.codec = codec;
1637
1617
  this.hashAlg = this.getHashAlg(name);
1638
- this.codecBuffer = index$6.encode(codec);
1618
+ this.codecBuffer = index$6.encode(this.codec);
1639
1619
  }
1640
1620
  decode(encoded) {
1641
1621
  encoded = encoded || this.encoded;
@@ -1789,7 +1769,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface$1 {
1789
1769
  this.fromArrayBuffer(buffer);
1790
1770
  else if (buffer instanceof FormatInterface$1 && buffer?.name === this.name)
1791
1771
  return buffer;
1792
- else if (buffer instanceof String) {
1772
+ else if (typeof buffer === 'string') {
1793
1773
  if (this.isHex(buffer))
1794
1774
  this.fromHex(buffer);
1795
1775
  else if (this.isBase58(buffer))
@@ -1797,7 +1777,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface$1 {
1797
1777
  else if (this.isBase32(buffer))
1798
1778
  this.fromBs32(buffer);
1799
1779
  else
1800
- throw new Error(`unsupported ${buffer}`);
1780
+ this.fromString(buffer);
1801
1781
  }
1802
1782
  else {
1803
1783
  this.create(buffer);
@@ -1883,6 +1863,26 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface$1 {
1883
1863
  this.encoded = new Uint8Array(buffer, buffer.byteOffset, buffer.byteLength);
1884
1864
  return this.hasCodec() ? this.decode() : this.create(JSON.parse(new TextDecoder().decode(this.encoded)));
1885
1865
  }
1866
+ /**
1867
+ * @param {Object} data
1868
+ */
1869
+ create(data) {
1870
+ const decoded = {};
1871
+ if (this.keys?.length > 0) {
1872
+ for (const key of this.keys) {
1873
+ Object.defineProperties(decoded, {
1874
+ [key]: {
1875
+ enumerable: true,
1876
+ configurable: true,
1877
+ set: (value) => data[key],
1878
+ get: () => data[key]
1879
+ }
1880
+ });
1881
+ }
1882
+ this.decoded = decoded;
1883
+ return this.encode(decoded);
1884
+ }
1885
+ }
1886
1886
  };
1887
1887
  const FormatInterface = FormatInterface$1;
1888
1888
  const Codec = Codec$1;
@@ -2150,7 +2150,7 @@ class MessageHandler {
2150
2150
  let identity = await walletStore.get('identity');
2151
2151
  identity = JSON.parse(identity);
2152
2152
  if (!globalThis.MultiWallet) {
2153
- const importee = await import(/* webpackChunkName: "multi-wallet" */ './index-54cdabb4.js');
2153
+ const importee = await import(/* webpackChunkName: "multi-wallet" */ './index-f3625c4a.js');
2154
2154
  globalThis.MultiWallet = importee.default;
2155
2155
  }
2156
2156
  const wallet = new MultiWallet(this.network);
@@ -2475,7 +2475,7 @@ class Peernet {
2475
2475
  this.root = options.root;
2476
2476
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
2477
2477
  // FolderMessageResponse
2478
- } = await import(/* webpackChunkName: "messages" */ './messages-a77b03b5.js');
2478
+ } = await import(/* webpackChunkName: "messages" */ './messages-d87e15a0.js');
2479
2479
  /**
2480
2480
  * proto Object containing protos
2481
2481
  * @type {Object}
@@ -2523,7 +2523,7 @@ class Peernet {
2523
2523
  }
2524
2524
  }
2525
2525
  else {
2526
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-48e510d0.js');
2526
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-9f9f4d27.js');
2527
2527
  const generateAccount = importee.default;
2528
2528
  const { identity, accounts, config } = await generateAccount(this.network);
2529
2529
  // await accountStore.put('config', JSON.stringify(config));
@@ -2552,7 +2552,7 @@ class Peernet {
2552
2552
  * @see DataHandler
2553
2553
  */
2554
2554
  pubsub.subscribe('peer:data', dataHandler);
2555
- const importee = await import('./client-f1b87adc.js');
2555
+ const importee = await import('./client-4e947338.js');
2556
2556
  /**
2557
2557
  * @access public
2558
2558
  * @type {PeernetClient}
@@ -1,2 +1,2 @@
1
- export { P as default } from './peernet-1582ad5b.js';
1
+ export { P as default } from './peernet-29c659a0.js';
2
2
  import './value-40634404.js';
@@ -1,4 +1,4 @@
1
1
  declare namespace _default {
2
- const response: Uint8Array;
2
+ const response: {};
3
3
  }
4
4
  export default _default;
@@ -120,7 +120,7 @@ class RequestMessage extends FormatInterface {
120
120
  }
121
121
 
122
122
  var proto$4 = {
123
- response: new Uint8Array()
123
+ response: {}
124
124
  };
125
125
 
126
126
  class ResponseMessage extends FormatInterface {
@@ -426,7 +426,7 @@ class Peernet {
426
426
  this.root = options.root;
427
427
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
428
428
  // FolderMessageResponse
429
- } = await import(/* webpackChunkName: "messages" */ './messages-ebdc8c69.js');
429
+ } = await import(/* webpackChunkName: "messages" */ './messages-75fe56a4.js');
430
430
  /**
431
431
  * proto Object containing protos
432
432
  * @type {Object}
@@ -1,4 +1,4 @@
1
1
  declare namespace _default {
2
- const response: Uint8Array;
2
+ const response: {};
3
3
  }
4
4
  export default _default;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "0.18.5",
3
+ "version": "0.18.7",
4
4
  "description": "",
5
5
  "main": "src/peernet.js",
6
6
  "exports": {
@@ -1,3 +1,3 @@
1
1
  export default {
2
- response: new Uint8Array()
2
+ response: {}
3
3
  }