@leofcoin/peernet 1.2.21 → 1.2.23

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,2 +1,2 @@
1
- export { I as default } from './identity-BeVZQ2Dp.js';
1
+ export { I as default } from './identity-BS_eDrwh.js';
2
2
  import 'crypto';
@@ -1,4 +1,4 @@
1
- import { M as MultiWallet, h as encrypt, a as base58$1 } from './identity-BeVZQ2Dp.js';
1
+ import { M as MultiWallet, l as encrypt, a as base58$1 } from './identity-BS_eDrwh.js';
2
2
  import 'crypto';
3
3
 
4
4
  /**
@@ -1,5 +1,5 @@
1
- import { F as FormatInterface } from './peernet-DFiLLjUD.js';
2
- import './identity-BeVZQ2Dp.js';
1
+ import { F as FormatInterface } from './peernet-CgU-ZdIe.js';
2
+ import './identity-BS_eDrwh.js';
3
3
  import 'crypto';
4
4
  import './value-C3vAp-wb.js';
5
5
 
@@ -1,4 +1,4 @@
1
- import { j as index$2, b as base, a as base58$1, k as index$3, l as index$4, m as index$5, g as createSHA512, f as createSHA384, e as createSHA256, d as createSHA224, c as createSHA1, I as Identity } from './identity-BeVZQ2Dp.js';
1
+ import { i as index$2, b as base, a as base58$1, c as index$3, d as index$4, e as index$5, f as createSHA512, g as createSHA384, h as createSHA256, j as createSHA224, k as createSHA1, I as Identity } from './identity-BS_eDrwh.js';
2
2
  import { K as KeyPath, a as KeyValue } from './value-C3vAp-wb.js';
3
3
 
4
4
  const getTargets = () => Array.from([]);
@@ -126,7 +126,7 @@ var isHex = string => /^[A-F0-9]+$/i.test(
126
126
  string
127
127
  );
128
128
 
129
- /*! pako 2.1.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
129
+ /*! pako 2.2.0 https://github.com/nodeca/pako @license (MIT AND Zlib) */
130
130
  // (C) 1995-2013 Jean-loup Gailly and Mark Adler
131
131
  // (C) 2014-2017 Vitaly Puzrin and Andrey Tupitsin
132
132
  //
@@ -1548,7 +1548,7 @@ const { _tr_init, _tr_stored_block, _tr_flush_block, _tr_tally, _tr_align } = tr
1548
1548
 
1549
1549
  const {
1550
1550
  Z_NO_FLUSH: Z_NO_FLUSH$2, Z_PARTIAL_FLUSH, Z_FULL_FLUSH: Z_FULL_FLUSH$1, Z_FINISH: Z_FINISH$3, Z_BLOCK: Z_BLOCK$1,
1551
- Z_OK: Z_OK$3, Z_STREAM_END: Z_STREAM_END$3, Z_STREAM_ERROR: Z_STREAM_ERROR$2, Z_DATA_ERROR: Z_DATA_ERROR$2, Z_BUF_ERROR: Z_BUF_ERROR$1,
1551
+ Z_OK: Z_OK$3, Z_STREAM_END: Z_STREAM_END$3, Z_STREAM_ERROR: Z_STREAM_ERROR$2, Z_DATA_ERROR: Z_DATA_ERROR$2, Z_BUF_ERROR: Z_BUF_ERROR$2,
1552
1552
  Z_DEFAULT_COMPRESSION: Z_DEFAULT_COMPRESSION$1,
1553
1553
  Z_FILTERED, Z_HUFFMAN_ONLY, Z_RLE, Z_FIXED, Z_DEFAULT_STRATEGY: Z_DEFAULT_STRATEGY$1,
1554
1554
  Z_UNKNOWN,
@@ -1647,11 +1647,35 @@ const slide_hash = (s) => {
1647
1647
  };
1648
1648
 
1649
1649
  /* eslint-disable new-cap */
1650
- let HASH_ZLIB = (s, prev, data) => ((prev << s.hash_shift) ^ data) & s.hash_mask;
1651
- // This hash causes less collisions, https://github.com/nodeca/pako/issues/135
1652
- // But breaks binary compatibility
1653
- //let HASH_FAST = (s, prev, data) => ((prev << 8) + (prev >> 8) + (data << 4)) & s.hash_mask;
1654
- let HASH = HASH_ZLIB;
1650
+ let HASH = (s, prev, data) => ((prev << s.hash_shift) ^ data) & s.hash_mask;
1651
+
1652
+
1653
+ /* ===========================================================================
1654
+ * Insert string str in the dictionary and set match_head to the previous head
1655
+ * of the hash chain (the most recent string with same hash key). Return
1656
+ * the previous length of the hash chain.
1657
+ * IN assertion: all calls to INSERT_STRING are made with consecutive input
1658
+ * characters and the first MIN_MATCH bytes of str are valid (except for
1659
+ * the last MIN_MATCH-1 bytes of the input file).
1660
+ */
1661
+ const INSERT_STRING = (s, str) => {
1662
+ let h;
1663
+ if (s.legacy_hash) {
1664
+ /* UPDATE_HASH(s, s->ins_h, s->window[(str) + (MIN_MATCH-1)]); */
1665
+ h = s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);
1666
+ } else {
1667
+ // ANZAC++ hash: reads 4 bytes, matches node.js zlib output (legacyHash
1668
+ // restores classic zlib hash). Faster, with fewer collisions.
1669
+ const w = s.window;
1670
+ // Read 4 bytes little-endian. Math.imul reproduces C uint32 overflow in
1671
+ // `(value * 66521 + 66521) >> 16` exactly.
1672
+ const value = w[str] | (w[str + 1] << 8) | (w[str + 2] << 16) | (w[str + 3] << 24);
1673
+ h = s.ins_h = ((Math.imul(value, 66521) + 66521) >>> 16) & s.hash_mask;
1674
+ }
1675
+ const hash_head = s.prev[str & s.w_mask] = s.head[h];
1676
+ s.head[h] = str;
1677
+ return hash_head;
1678
+ };
1655
1679
 
1656
1680
 
1657
1681
  /* =========================================================================
@@ -1925,7 +1949,20 @@ const fill_window = (s) => {
1925
1949
  s.lookahead += n;
1926
1950
 
1927
1951
  /* Initialize the hash value now that we have some input: */
1928
- if (s.lookahead + s.insert >= MIN_MATCH) {
1952
+ if (!s.legacy_hash) {
1953
+ /* The 4-byte hash reads one extra byte, so it needs one more available. */
1954
+ if (s.lookahead + s.insert > MIN_MATCH) {
1955
+ str = s.strstart - s.insert;
1956
+ while (s.insert) {
1957
+ INSERT_STRING(s, str);
1958
+ str++;
1959
+ s.insert--;
1960
+ if (s.lookahead + s.insert <= MIN_MATCH) {
1961
+ break;
1962
+ }
1963
+ }
1964
+ }
1965
+ } else if (s.lookahead + s.insert >= MIN_MATCH) {
1929
1966
  str = s.strstart - s.insert;
1930
1967
  s.ins_h = s.window[str];
1931
1968
 
@@ -1935,11 +1972,7 @@ const fill_window = (s) => {
1935
1972
  // Call update_hash() MIN_MATCH-3 more times
1936
1973
  //#endif
1937
1974
  while (s.insert) {
1938
- /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
1939
- s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);
1940
-
1941
- s.prev[str & s.w_mask] = s.head[s.ins_h];
1942
- s.head[s.ins_h] = str;
1975
+ INSERT_STRING(s, str);
1943
1976
  str++;
1944
1977
  s.insert--;
1945
1978
  if (s.lookahead + s.insert < MIN_MATCH) {
@@ -2237,11 +2270,7 @@ const deflate_fast = (s, flush) => {
2237
2270
  */
2238
2271
  hash_head = 0/*NIL*/;
2239
2272
  if (s.lookahead >= MIN_MATCH) {
2240
- /*** INSERT_STRING(s, s.strstart, hash_head); ***/
2241
- s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);
2242
- hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
2243
- s.head[s.ins_h] = s.strstart;
2244
- /***/
2273
+ hash_head = INSERT_STRING(s, s.strstart);
2245
2274
  }
2246
2275
 
2247
2276
  /* Find the longest match, discarding those <= prev_length.
@@ -2271,11 +2300,7 @@ const deflate_fast = (s, flush) => {
2271
2300
  s.match_length--; /* string at strstart already in table */
2272
2301
  do {
2273
2302
  s.strstart++;
2274
- /*** INSERT_STRING(s, s.strstart, hash_head); ***/
2275
- s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);
2276
- hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
2277
- s.head[s.ins_h] = s.strstart;
2278
- /***/
2303
+ hash_head = INSERT_STRING(s, s.strstart);
2279
2304
  /* strstart never exceeds WSIZE-MAX_MATCH, so there are
2280
2305
  * always MIN_MATCH bytes ahead.
2281
2306
  */
@@ -2285,16 +2310,18 @@ const deflate_fast = (s, flush) => {
2285
2310
  {
2286
2311
  s.strstart += s.match_length;
2287
2312
  s.match_length = 0;
2288
- s.ins_h = s.window[s.strstart];
2289
- /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */
2290
- s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);
2313
+ if (s.legacy_hash) {
2314
+ s.ins_h = s.window[s.strstart];
2315
+ /* UPDATE_HASH(s, s.ins_h, s.window[s.strstart+1]); */
2316
+ s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + 1]);
2291
2317
 
2292
2318
  //#if MIN_MATCH != 3
2293
2319
  // Call UPDATE_HASH() MIN_MATCH-3 more times
2294
2320
  //#endif
2295
- /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
2296
- * matter since it will be recomputed at next deflate call.
2297
- */
2321
+ /* If lookahead < MIN_MATCH, ins_h is garbage, but it does not
2322
+ * matter since it will be recomputed at next deflate call.
2323
+ */
2324
+ }
2298
2325
  }
2299
2326
  } else {
2300
2327
  /* No match, output a literal byte */
@@ -2367,11 +2394,7 @@ const deflate_slow = (s, flush) => {
2367
2394
  */
2368
2395
  hash_head = 0/*NIL*/;
2369
2396
  if (s.lookahead >= MIN_MATCH) {
2370
- /*** INSERT_STRING(s, s.strstart, hash_head); ***/
2371
- s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);
2372
- hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
2373
- s.head[s.ins_h] = s.strstart;
2374
- /***/
2397
+ hash_head = INSERT_STRING(s, s.strstart);
2375
2398
  }
2376
2399
 
2377
2400
  /* Find the longest match, discarding those <= prev_length.
@@ -2419,11 +2442,7 @@ const deflate_slow = (s, flush) => {
2419
2442
  s.prev_length -= 2;
2420
2443
  do {
2421
2444
  if (++s.strstart <= max_insert) {
2422
- /*** INSERT_STRING(s, s.strstart, hash_head); ***/
2423
- s.ins_h = HASH(s, s.ins_h, s.window[s.strstart + MIN_MATCH - 1]);
2424
- hash_head = s.prev[s.strstart & s.w_mask] = s.head[s.ins_h];
2425
- s.head[s.ins_h] = s.strstart;
2426
- /***/
2445
+ hash_head = INSERT_STRING(s, s.strstart);
2427
2446
  }
2428
2447
  } while (--s.prev_length !== 0);
2429
2448
  s.match_available = 0;
@@ -2748,6 +2767,7 @@ function DeflateState() {
2748
2767
  this.head = null; /* Heads of the hash chains or NIL. */
2749
2768
 
2750
2769
  this.ins_h = 0; /* hash index of string to be inserted */
2770
+ this.legacy_hash = 0; /* use classic zlib hash instead of default ANZAC++ */
2751
2771
  this.hash_size = 0; /* number of elements in hash table */
2752
2772
  this.hash_bits = 0; /* log2(hash_size) */
2753
2773
  this.hash_mask = 0; /* hash_size-1 */
@@ -2970,7 +2990,7 @@ const deflateSetHeader = (strm, head) => {
2970
2990
  };
2971
2991
 
2972
2992
 
2973
- const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
2993
+ const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy, legacyHash) => {
2974
2994
 
2975
2995
  if (!strm) { // === Z_NULL
2976
2996
  return Z_STREAM_ERROR$2;
@@ -3016,7 +3036,13 @@ const deflateInit2 = (strm, level, method, windowBits, memLevel, strategy) => {
3016
3036
  s.w_size = 1 << s.w_bits;
3017
3037
  s.w_mask = s.w_size - 1;
3018
3038
 
3039
+ s.legacy_hash = legacyHash ? 1 : 0;
3040
+
3019
3041
  s.hash_bits = memLevel + 7;
3042
+ /* ANZAC++ hash needs >= 15 hash bits to span its 4 read bytes. */
3043
+ if (!s.legacy_hash && s.hash_bits < 15) {
3044
+ s.hash_bits = 15;
3045
+ }
3020
3046
  s.hash_size = 1 << s.hash_bits;
3021
3047
  s.hash_mask = s.hash_size - 1;
3022
3048
  s.hash_shift = ~~((s.hash_bits + MIN_MATCH - 1) / MIN_MATCH);
@@ -3108,7 +3134,7 @@ const deflate$2 = (strm, flush) => {
3108
3134
  if (!strm.output ||
3109
3135
  (strm.avail_in !== 0 && !strm.input) ||
3110
3136
  (s.status === FINISH_STATE && flush !== Z_FINISH$3)) {
3111
- return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR$1 : Z_STREAM_ERROR$2);
3137
+ return err(strm, (strm.avail_out === 0) ? Z_BUF_ERROR$2 : Z_STREAM_ERROR$2);
3112
3138
  }
3113
3139
 
3114
3140
  const old_flush = s.last_flush;
@@ -3134,12 +3160,12 @@ const deflate$2 = (strm, flush) => {
3134
3160
  */
3135
3161
  } else if (strm.avail_in === 0 && rank(flush) <= rank(old_flush) &&
3136
3162
  flush !== Z_FINISH$3) {
3137
- return err(strm, Z_BUF_ERROR$1);
3163
+ return err(strm, Z_BUF_ERROR$2);
3138
3164
  }
3139
3165
 
3140
3166
  /* User must not provide more input after the first FINISH: */
3141
3167
  if (s.status === FINISH_STATE && strm.avail_in !== 0) {
3142
- return err(strm, Z_BUF_ERROR$1);
3168
+ return err(strm, Z_BUF_ERROR$2);
3143
3169
  }
3144
3170
 
3145
3171
  /* Write the header */
@@ -3520,12 +3546,7 @@ const deflateSetDictionary = (strm, dictionary) => {
3520
3546
  let str = s.strstart;
3521
3547
  let n = s.lookahead - (MIN_MATCH - 1);
3522
3548
  do {
3523
- /* UPDATE_HASH(s, s->ins_h, s->window[str + MIN_MATCH-1]); */
3524
- s.ins_h = HASH(s, s.ins_h, s.window[str + MIN_MATCH - 1]);
3525
-
3526
- s.prev[str & s.w_mask] = s.head[s.ins_h];
3527
-
3528
- s.head[s.ins_h] = str;
3549
+ INSERT_STRING(s, str);
3529
3550
  str++;
3530
3551
  } while (--n);
3531
3552
  s.strstart = str;
@@ -3649,7 +3670,7 @@ const _utf8len = new Uint8Array(256);
3649
3670
  for (let q = 0; q < 256; q++) {
3650
3671
  _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);
3651
3672
  }
3652
- _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
3673
+ _utf8len[254] = _utf8len[255] = 1; // Invalid sequence start
3653
3674
 
3654
3675
 
3655
3676
  // convert string to array (typed, when possible)
@@ -3870,6 +3891,15 @@ const {
3870
3891
 
3871
3892
  /* ===========================================================================*/
3872
3893
 
3894
+ const defaultOptions$1 = {
3895
+ level: Z_DEFAULT_COMPRESSION,
3896
+ method: Z_DEFLATED$1,
3897
+ chunkSize: 16384,
3898
+ windowBits: 15,
3899
+ memLevel: 8,
3900
+ strategy: Z_DEFAULT_STRATEGY,
3901
+ legacyHash: true
3902
+ };
3873
3903
 
3874
3904
  /**
3875
3905
  * class Deflate
@@ -3925,6 +3955,10 @@ const {
3925
3955
  * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
3926
3956
  * for more information on these.
3927
3957
  *
3958
+ * - `legacyHash` (Boolean) - use the classic zlib hash (default), which matches
3959
+ * canonical zlib output byte-for-byte. Set to `false` to use the faster
3960
+ * ANZAC++ hash, which matches recent (chromium) node.js output instead.
3961
+ *
3928
3962
  * Additional options, for internal needs:
3929
3963
  *
3930
3964
  * - `chunkSize` - size of generated data chunks (16K by default)
@@ -3957,14 +3991,7 @@ const {
3957
3991
  * ```
3958
3992
  **/
3959
3993
  function Deflate$1(options) {
3960
- this.options = common.assign({
3961
- level: Z_DEFAULT_COMPRESSION,
3962
- method: Z_DEFLATED$1,
3963
- chunkSize: 16384,
3964
- windowBits: 15,
3965
- memLevel: 8,
3966
- strategy: Z_DEFAULT_STRATEGY
3967
- }, options || {});
3994
+ this.options = common.assign({}, defaultOptions$1, options || {});
3968
3995
 
3969
3996
  let opt = this.options;
3970
3997
 
@@ -3990,7 +4017,8 @@ function Deflate$1(options) {
3990
4017
  opt.method,
3991
4018
  opt.windowBits,
3992
4019
  opt.memLevel,
3993
- opt.strategy
4020
+ opt.strategy,
4021
+ opt.legacyHash
3994
4022
  );
3995
4023
 
3996
4024
  if (status !== Z_OK$2) {
@@ -4610,7 +4638,7 @@ const lbase = new Uint16Array([ /* Length codes 257..285 base */
4610
4638
 
4611
4639
  const lext = new Uint8Array([ /* Length codes 257..285 extra */
4612
4640
  16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
4613
- 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78
4641
+ 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 199, 75
4614
4642
  ]);
4615
4643
 
4616
4644
  const dbase = new Uint16Array([ /* Distance codes 0..29 base */
@@ -4947,7 +4975,7 @@ const DISTS = 2;
4947
4975
 
4948
4976
  const {
4949
4977
  Z_FINISH: Z_FINISH$1, Z_BLOCK, Z_TREES,
4950
- Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR,
4978
+ Z_OK: Z_OK$1, Z_STREAM_END: Z_STREAM_END$1, Z_NEED_DICT: Z_NEED_DICT$1, Z_STREAM_ERROR: Z_STREAM_ERROR$1, Z_DATA_ERROR: Z_DATA_ERROR$1, Z_MEM_ERROR: Z_MEM_ERROR$1, Z_BUF_ERROR: Z_BUF_ERROR$1,
4951
4979
  Z_DEFLATED
4952
4980
  } = constants$2;
4953
4981
 
@@ -5257,11 +5285,14 @@ const updatewindow = (strm, src, end, copy) => {
5257
5285
 
5258
5286
  /* if it hasn't been done already, allocate space for the window */
5259
5287
  if (state.window === null) {
5288
+ state.window = new Uint8Array(1 << state.wbits);
5289
+ }
5290
+
5291
+ /* if window not in use yet, initialize */
5292
+ if (state.wsize === 0) {
5260
5293
  state.wsize = 1 << state.wbits;
5261
5294
  state.wnext = 0;
5262
5295
  state.whave = 0;
5263
-
5264
- state.window = new Uint8Array(state.wsize);
5265
5296
  }
5266
5297
 
5267
5298
  /* copy state->wsize or less output bytes into the circular window */
@@ -6387,7 +6418,7 @@ const inflate$2 = (strm, flush) => {
6387
6418
  (state.mode === TYPE ? 128 : 0) +
6388
6419
  (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
6389
6420
  if (((_in === 0 && _out === 0) || flush === Z_FINISH$1) && ret === Z_OK$1) {
6390
- ret = Z_BUF_ERROR;
6421
+ ret = Z_BUF_ERROR$1;
6391
6422
  }
6392
6423
  return ret;
6393
6424
  };
@@ -6559,11 +6590,16 @@ const toString$2 = Object.prototype.toString;
6559
6590
 
6560
6591
  const {
6561
6592
  Z_NO_FLUSH, Z_FINISH,
6562
- Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR
6593
+ Z_OK, Z_STREAM_END, Z_NEED_DICT, Z_STREAM_ERROR, Z_DATA_ERROR, Z_MEM_ERROR, Z_BUF_ERROR
6563
6594
  } = constants$2;
6564
6595
 
6565
6596
  /* ===========================================================================*/
6566
6597
 
6598
+ const defaultOptions$2 = {
6599
+ chunkSize: 1024 * 64,
6600
+ windowBits: 15,
6601
+ to: ''
6602
+ };
6567
6603
 
6568
6604
  /**
6569
6605
  * class Inflate
@@ -6643,11 +6679,7 @@ const {
6643
6679
  * ```
6644
6680
  **/
6645
6681
  function Inflate$1(options) {
6646
- this.options = common.assign({
6647
- chunkSize: 1024 * 64,
6648
- windowBits: 15,
6649
- to: ''
6650
- }, options || {});
6682
+ this.options = common.assign({}, defaultOptions$2, options || {});
6651
6683
 
6652
6684
  const opt = this.options;
6653
6685
 
@@ -6778,11 +6810,19 @@ Inflate$1.prototype.push = function (data, flush_mode) {
6778
6810
  }
6779
6811
  }
6780
6812
 
6781
- // Skip snyc markers if more data follows and not raw mode
6813
+ // Only the gzip format defines concatenated members (RFC 1952: a gzip file
6814
+ // is "a series of members"). A zlib stream (RFC 1950) ends after its
6815
+ // ADLER32, and a raw DEFLATE stream (RFC 1951) ends after its final block -
6816
+ // neither format allows anything to follow, so bytes after the end are not
6817
+ // ours to interpret and must be left in the input. Restart decoding only
6818
+ // for a gzip member: `state.flags` is non-zero only once a gzip header has
6819
+ // actually been decoded (it stays 0 for a zlib member, even when the format
6820
+ // was auto-detected and the gzip bit of `wrap` is set). A trailing zero
6821
+ // byte is padding, not the start of a member (no member can begin with 0).
6782
6822
  while (strm.avail_in > 0 &&
6783
6823
  status === Z_STREAM_END &&
6784
- strm.state.wrap > 0 &&
6785
- data[strm.next_in] !== 0)
6824
+ (strm.state.wrap & 2) && strm.state.flags !== 0 &&
6825
+ strm.input[strm.next_in] !== 0)
6786
6826
  {
6787
6827
  inflate_1$2.inflateReset(strm);
6788
6828
  status = inflate_1$2.inflate(strm, _flush_mode);
@@ -6803,7 +6843,9 @@ Inflate$1.prototype.push = function (data, flush_mode) {
6803
6843
  last_avail_out = strm.avail_out;
6804
6844
 
6805
6845
  if (strm.next_out) {
6806
- if (strm.avail_out === 0 || status === Z_STREAM_END) {
6846
+ // Flush output if buffer is full, stream ended, or an explicit flush was
6847
+ // requested (e.g. Z_SYNC_FLUSH) - to push out the tail, same as node's zlib.
6848
+ if (strm.avail_out === 0 || status === Z_STREAM_END || _flush_mode > 0) {
6807
6849
 
6808
6850
  if (this.options.to === 'string') {
6809
6851
 
@@ -6821,12 +6863,22 @@ Inflate$1.prototype.push = function (data, flush_mode) {
6821
6863
 
6822
6864
  } else {
6823
6865
  this.onData(strm.output.length === strm.next_out ? strm.output : strm.output.subarray(0, strm.next_out));
6866
+
6867
+ // Force a fresh output buffer on next iteration / next push, so the
6868
+ // already emitted tail is not sent again.
6869
+ strm.avail_out = 0;
6870
+ strm.next_out = 0;
6824
6871
  }
6825
6872
  }
6826
6873
  }
6827
6874
 
6828
- // Must repeat iteration if out buffer is full
6829
- if (status === Z_OK && last_avail_out === 0) continue;
6875
+ // A full output buffer means there may be more to produce - allocate a new
6876
+ // one and call inflate again. The status depends on the flush mode: with
6877
+ // Z_NO_FLUSH a full buffer is reported as Z_OK, but with Z_FINISH the same
6878
+ // situation is reported as Z_BUF_ERROR ("could not make progress now",
6879
+ // non-fatal) even though output is still pending. Both must continue; the
6880
+ // distinction that matters is purely "was the output buffer exhausted".
6881
+ if ((status === Z_OK || status === Z_BUF_ERROR) && last_avail_out === 0) continue;
6830
6882
 
6831
6883
  // Finalize if end of stream reached.
6832
6884
  if (status === Z_STREAM_END) {
@@ -6836,7 +6888,23 @@ Inflate$1.prototype.push = function (data, flush_mode) {
6836
6888
  return true;
6837
6889
  }
6838
6890
 
6839
- if (strm.avail_in === 0) break;
6891
+ if (strm.avail_in === 0) {
6892
+ // Input is exhausted. If the caller declared this the end of the stream
6893
+ // (Z_FINISH) but we never saw Z_STREAM_END, the compressed data ended
6894
+ // before its terminating marker - i.e. it is truncated/incomplete. That
6895
+ // is an error: returning the partial output as success would be
6896
+ // indistinguishable from a complete decode, hiding the data loss. Report
6897
+ // it via Z_BUF_ERROR. (Reached only when the output buffer still had room
6898
+ // - a full buffer is handled by the `continue` above - so this genuinely
6899
+ // means "ran out of input", not "ran out of output".)
6900
+ if (_flush_mode === Z_FINISH) {
6901
+ status = inflate_1$2.inflateEnd(this.strm);
6902
+ this.onEnd(status === Z_OK ? Z_BUF_ERROR : status);
6903
+ this.ended = true;
6904
+ return false;
6905
+ }
6906
+ break;
6907
+ }
6840
6908
  }
6841
6909
 
6842
6910
  return true;
@@ -6922,7 +6990,7 @@ Inflate$1.prototype.onEnd = function (status) {
6922
6990
  function inflate$1(input, options) {
6923
6991
  const inflator = new Inflate$1(options);
6924
6992
 
6925
- inflator.push(input);
6993
+ inflator.push(input, true);
6926
6994
 
6927
6995
  // That will never happens, if you don't cheat with options :)
6928
6996
  if (inflator.err) throw inflator.msg || messages[inflator.err];
@@ -8417,6 +8485,7 @@ class Peernet {
8417
8485
  client;
8418
8486
  network;
8419
8487
  stars;
8488
+ transport;
8420
8489
  networkVersion;
8421
8490
  bw;
8422
8491
  hasDaemon = false;
@@ -8438,6 +8507,7 @@ class Peernet {
8438
8507
  * @param {String} options.root - path to root directory
8439
8508
  * @param {String} options.version - path to root directory
8440
8509
  * @param {String} options.storePrefix - prefix for datatores (lfc)
8510
+ * @param {Object} options.transport - transport selection and fallback options passed to @netpeer/swarm
8441
8511
  *
8442
8512
  * @return {Promise} instance of Peernet
8443
8513
  *
@@ -8451,6 +8521,7 @@ class Peernet {
8451
8521
  this.network = options.network || 'leofcoin';
8452
8522
  this.autoStart = options.autoStart === undefined ? true : options.autoStart;
8453
8523
  this.stars = options.stars;
8524
+ this.transport = options.transport;
8454
8525
  this.version = options.version;
8455
8526
  const parts = this.network.split(':');
8456
8527
  this.networkVersion = options.networkVersion || parts.length > 1 ? parts[1] : 'mainnet';
@@ -8544,7 +8615,7 @@ class Peernet {
8544
8615
  await getAddress();
8545
8616
  this.storePrefix = options.storePrefix;
8546
8617
  this.root = options.root;
8547
- const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-BfDvXW-x.js');
8618
+ const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile } = await import(/* webpackChunkName: "messages" */ './messages-D0Goitr6.js');
8548
8619
  /**
8549
8620
  * proto Object containing protos
8550
8621
  * @type {Object}
@@ -8591,7 +8662,7 @@ class Peernet {
8591
8662
  if (this.#starting || this.#started)
8592
8663
  return;
8593
8664
  this.#starting = true;
8594
- const importee = await import('./client-lPe0SUWx.js');
8665
+ const importee = await import('./client-eYBPUrVq.js');
8595
8666
  /**
8596
8667
  * @access public
8597
8668
  * @type {PeernetClient}
@@ -8601,7 +8672,8 @@ class Peernet {
8601
8672
  peerId: this.id,
8602
8673
  networkVersion: this.networkVersion,
8603
8674
  version: this.version,
8604
- stars: this.stars
8675
+ stars: this.stars,
8676
+ transport: this.transport
8605
8677
  });
8606
8678
  this.#started = true;
8607
8679
  this.#starting = false;
@@ -1,4 +1,4 @@
1
- export { P as default } from './peernet-DFiLLjUD.js';
2
- import './identity-BeVZQ2Dp.js';
1
+ export { P as default } from './peernet-CgU-ZdIe.js';
2
+ import './identity-BS_eDrwh.js';
3
3
  import './value-C3vAp-wb.js';
4
4
  import 'crypto';
@@ -6,6 +6,7 @@ import qrcode from 'qrcode';
6
6
 
7
7
  class Identity {
8
8
  #wallet;
9
+ #accountWallets = new Map();
9
10
  network;
10
11
  id;
11
12
  selectedAccount;
@@ -57,13 +58,36 @@ class Identity {
57
58
  this.#wallet = new MultiWallet(this.network);
58
59
  const multiWIF = await decrypt(password, base58.decode(identity.multiWIF));
59
60
  await this.#wallet.fromMultiWif(multiWIF);
61
+ await this.#loadAccountWallets();
62
+ }
63
+ async #loadAccountWallets() {
64
+ this.#accountWallets.clear();
65
+ const accounts = await this.getAccounts();
66
+ for (const [index, [, externalAddress, internalAddress]] of accounts.entries()) {
67
+ const account = this.#wallet.account(index + 1);
68
+ const external = (await account.external(1));
69
+ const internal = (await account.internal(1));
70
+ if ((await external.address) !== externalAddress || (await internal.address) !== internalAddress) {
71
+ throw new Error(`stored account ${index + 1} does not match this identity`);
72
+ }
73
+ this.#accountWallets.set(externalAddress, external);
74
+ this.#accountWallets.set(internalAddress, internal);
75
+ }
76
+ if (!this.#accountWallets.has(this.selectedAccount)) {
77
+ throw new Error(`selected account ${this.selectedAccount} is not part of this identity`);
78
+ }
60
79
  }
61
80
  selectAccount(account) {
81
+ if (!this.#accountWallets.has(account))
82
+ throw new Error(`unknown identity account ${account}`);
62
83
  this.selectedAccount = account;
63
84
  return walletStore.put('selected-account', account);
64
85
  }
65
86
  sign(hash) {
66
- return this.#wallet.sign(hash.subarray(0, 32));
87
+ const wallet = this.#accountWallets.get(this.selectedAccount);
88
+ if (!wallet)
89
+ throw new Error(`no signer available for selected account ${this.selectedAccount}`);
90
+ return wallet.sign(hash.subarray(0, 32));
67
91
  }
68
92
  lock(password) {
69
93
  this.#wallet.lock(password);
@@ -326,6 +326,7 @@ class Peernet {
326
326
  client;
327
327
  network;
328
328
  stars;
329
+ transport;
329
330
  networkVersion;
330
331
  bw;
331
332
  hasDaemon = false;
@@ -347,6 +348,7 @@ class Peernet {
347
348
  * @param {String} options.root - path to root directory
348
349
  * @param {String} options.version - path to root directory
349
350
  * @param {String} options.storePrefix - prefix for datatores (lfc)
351
+ * @param {Object} options.transport - transport selection and fallback options passed to @netpeer/swarm
350
352
  *
351
353
  * @return {Promise} instance of Peernet
352
354
  *
@@ -360,6 +362,7 @@ class Peernet {
360
362
  this.network = options.network || 'leofcoin';
361
363
  this.autoStart = options.autoStart === undefined ? true : options.autoStart;
362
364
  this.stars = options.stars;
365
+ this.transport = options.transport;
363
366
  this.version = options.version;
364
367
  const parts = this.network.split(':');
365
368
  this.networkVersion = options.networkVersion || parts.length > 1 ? parts[1] : 'mainnet';
@@ -510,7 +513,8 @@ class Peernet {
510
513
  peerId: this.id,
511
514
  networkVersion: this.networkVersion,
512
515
  version: this.version,
513
- stars: this.stars
516
+ stars: this.stars,
517
+ transport: this.transport
514
518
  });
515
519
  this.#started = true;
516
520
  this.#starting = false;
package/exports/store.js CHANGED
@@ -102,6 +102,9 @@ class Store {
102
102
  this.root = await init(root, homedir);
103
103
  this.version = version;
104
104
  this.db = new ClassicLevel(join(this.root, this.name), { valueEncoding: 'view' });
105
+ if (typeof this.db.open === 'function') {
106
+ await this.db.open();
107
+ }
105
108
  }
106
109
  toKeyPath(key) {
107
110
  if (!key.isKeyPath())
@@ -9,7 +9,7 @@ export default class Identity {
9
9
  getAccounts(): Promise<[[name: string, externalAddress: string, internalAddress: string]]>;
10
10
  load(password?: string): Promise<void>;
11
11
  selectAccount(account: string): Promise<unknown>;
12
- sign(hash: Uint8Array): any;
12
+ sign(hash: Uint8Array): Promise<Uint8Array<ArrayBufferLike>>;
13
13
  lock(password: string): void;
14
14
  unlock(password: string): void;
15
15
  export(password: string): Promise<any>;
@@ -39,6 +39,7 @@ export default class Peernet {
39
39
  client: swarm;
40
40
  network: string;
41
41
  stars: string[];
42
+ transport: any;
42
43
  networkVersion: string;
43
44
  bw: {
44
45
  up: number;
@@ -60,6 +61,7 @@ export default class Peernet {
60
61
  * @param {String} options.root - path to root directory
61
62
  * @param {String} options.version - path to root directory
62
63
  * @param {String} options.storePrefix - prefix for datatores (lfc)
64
+ * @param {Object} options.transport - transport selection and fallback options passed to @netpeer/swarm
63
65
  *
64
66
  * @return {Promise} instance of Peernet
65
67
  *