@leofcoin/peernet 0.18.2 → 0.18.5

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-2796cdb2.js';
1
+ import { L as LittlePubSub } from './peernet-1582ad5b.js';
2
2
  import './value-40634404.js';
3
3
 
4
4
  var clientApi = _pubsub => {
@@ -1,5 +1,5 @@
1
- import MultiWallet from './index-7018cab6.js';
2
- import './peernet-2796cdb2.js';
1
+ import MultiWallet from './index-54cdabb4.js';
2
+ import './peernet-1582ad5b.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-2796cdb2.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-1582ad5b.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-2796cdb2.js';
1
+ import { F as FormatInterface } from './peernet-1582ad5b.js';
2
2
  import './value-40634404.js';
3
3
 
4
4
  var proto$b = {
@@ -1389,27 +1389,30 @@ const codecs = [
1389
1389
  }
1390
1390
  ];
1391
1391
 
1392
- globalThis.peernet = globalThis.peernet || {};
1393
- globalThis.peernet.codecs = globalThis.peernet.codecs || {};
1392
+ globalThis.peernetCodecs = globalThis.peernetCodecs || {};
1394
1393
  const addCodec = (codecInput) => {
1395
1394
  let { hashAlg, codec, name } = codecInput;
1396
- if (!globalThis.peernet.codecs[name])
1397
- globalThis.peernet.codecs[name] = {
1395
+ if (!globalThis.peernetCodecs[name])
1396
+ globalThis.peernetCodecs[name] = {
1398
1397
  hashAlg,
1399
- codec: parseInt(codec, 16)
1398
+ codec: isNaN(codec) ? parseInt(codec, 16) : codec
1400
1399
  };
1401
1400
  };
1402
- const getCodec = (name) => globalThis.peernet.codecs[name];
1401
+ const getCodec = (name) => {
1402
+ if (typeof name === 'number')
1403
+ return name;
1404
+ return getCodecByName(name).codec;
1405
+ };
1403
1406
  const getCodecName = (codec) => {
1404
- return Object.keys(globalThis.peernet.codecs).reduce((p, c) => {
1405
- const item = globalThis.peernet.codecs[c];
1407
+ return Object.keys(globalThis.peernetCodecs).reduce((p, c) => {
1408
+ const item = globalThis.peernetCodecs[c];
1406
1409
  if (item.codec === codec)
1407
1410
  return c;
1408
1411
  else
1409
1412
  return p;
1410
1413
  }, undefined);
1411
1414
  };
1412
- const getCodecByName = (name) => globalThis.peernet.codecs[name];
1415
+ const getCodecByName = (name) => globalThis.peernetCodecs[name];
1413
1416
  const getHashAlg = (name) => {
1414
1417
  if (typeof name === 'number')
1415
1418
  return getCodecByName(getCodecName(name)).hashAlg;
@@ -1436,7 +1439,7 @@ var utils = {
1436
1439
  getHashAlg,
1437
1440
  getCodecName,
1438
1441
  validateCodec,
1439
- codecs: globalThis.peernet.codecs
1442
+ codecs: globalThis.peernetCodecs
1440
1443
  };
1441
1444
 
1442
1445
  /**
@@ -2147,7 +2150,7 @@ class MessageHandler {
2147
2150
  let identity = await walletStore.get('identity');
2148
2151
  identity = JSON.parse(identity);
2149
2152
  if (!globalThis.MultiWallet) {
2150
- const importee = await import(/* webpackChunkName: "multi-wallet" */ './index-7018cab6.js');
2153
+ const importee = await import(/* webpackChunkName: "multi-wallet" */ './index-54cdabb4.js');
2151
2154
  globalThis.MultiWallet = importee.default;
2152
2155
  }
2153
2156
  const wallet = new MultiWallet(this.network);
@@ -2335,7 +2338,6 @@ class LeofcoinStorage {
2335
2338
  async size() {
2336
2339
  let size = 0;
2337
2340
  const query = await this.db.iterate();
2338
- console.log(query);
2339
2341
  for await (const item of query) {
2340
2342
  size += item.value ? item.value.length : item[1].length;
2341
2343
  }
@@ -2473,7 +2475,7 @@ class Peernet {
2473
2475
  this.root = options.root;
2474
2476
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
2475
2477
  // FolderMessageResponse
2476
- } = await import(/* webpackChunkName: "messages" */ './messages-452642e3.js');
2478
+ } = await import(/* webpackChunkName: "messages" */ './messages-a77b03b5.js');
2477
2479
  /**
2478
2480
  * proto Object containing protos
2479
2481
  * @type {Object}
@@ -2521,7 +2523,7 @@ class Peernet {
2521
2523
  }
2522
2524
  }
2523
2525
  else {
2524
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-ddd5774f.js');
2526
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-48e510d0.js');
2525
2527
  const generateAccount = importee.default;
2526
2528
  const { identity, accounts, config } = await generateAccount(this.network);
2527
2529
  // await accountStore.put('config', JSON.stringify(config));
@@ -2550,7 +2552,7 @@ class Peernet {
2550
2552
  * @see DataHandler
2551
2553
  */
2552
2554
  pubsub.subscribe('peer:data', dataHandler);
2553
- const importee = await import('./client-ed00c639.js');
2555
+ const importee = await import('./client-f1b87adc.js');
2554
2556
  /**
2555
2557
  * @access public
2556
2558
  * @type {PeernetClient}
@@ -1,2 +1,2 @@
1
- export { P as default } from './peernet-2796cdb2.js';
1
+ export { P as default } from './peernet-1582ad5b.js';
2
2
  import './value-40634404.js';
package/exports/store.js CHANGED
@@ -179,8 +179,12 @@ class Store {
179
179
  return value.uint8Array
180
180
  }
181
181
 
182
+ toUint8Array(buffer) {
183
+ return Buffer.isBuffer(buffer) ? new Uint8Array(buffer.buffer, buffer.byteOffset, buffer.byteLength / Uint8Array.BYTES_PER_ELEMENT) : buffer
184
+ }
185
+
182
186
  async get(key) {
183
- return this.db.get(this.toKeyPath(key))
187
+ return this.toUint8Array(await this.db.get(this.toKeyPath(key)))
184
188
  }
185
189
 
186
190
  async put(key, value) {
@@ -198,7 +202,7 @@ class Store {
198
202
  async values(limit = -1) {
199
203
  const values = [];
200
204
  for await (const value of this.db.values({limit})) {
201
- values.push(value);
205
+ values.push(this.toUint8Array(value));
202
206
  }
203
207
  return values
204
208
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "0.18.2",
3
+ "version": "0.18.5",
4
4
  "description": "",
5
5
  "main": "src/peernet.js",
6
6
  "exports": {