@leofcoin/peernet 1.1.64 → 1.1.65

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 { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-8bfe60c5.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-4149fb9c.js';
2
2
  import './value-4e80eeeb.js';
3
3
 
4
4
  /**
@@ -1,4 +1,4 @@
1
- import { F as FormatInterface } from './peernet-8bfe60c5.js';
1
+ import { F as FormatInterface } from './peernet-4149fb9c.js';
2
2
  import './value-4e80eeeb.js';
3
3
 
4
4
  var proto$b = {
@@ -11658,25 +11658,23 @@ var pako = {
11658
11658
  };
11659
11659
 
11660
11660
  const { fromString, toString } = index$3;
11661
- const isJson = (type) => type === "object" || "array";
11662
- const isString = (type) => type === "string";
11663
- const isNumber = (type) => type === "number";
11664
- const isBoolean = (type) => type === "boolean";
11665
- const isUint8Array$1 = (type) => type === "uint8Array";
11666
- const isBigNumber = (type) => type === "bigNumber";
11661
+ const isJson = (type) => type === 'object' || 'array';
11662
+ const isString = (type) => type === 'string';
11663
+ const isNumber = (type) => type === 'number';
11664
+ const isBoolean = (type) => type === 'boolean';
11665
+ const isUint8Array$1 = (type) => type === 'uint8Array';
11666
+ const isBigNumber = (type) => type === 'bigNumber';
11667
11667
  const tokenize = (key, value) => {
11668
- const optional = key.endsWith("?");
11668
+ const optional = key.endsWith('?');
11669
11669
  let type = value === undefined ? key : value;
11670
11670
  if (type instanceof Uint8Array)
11671
- type = "uint8Array";
11671
+ type = 'uint8Array';
11672
11672
  else if (type instanceof BigNumber)
11673
- type = "bigNumber";
11673
+ type = 'bigNumber';
11674
11674
  else
11675
- type = Array.isArray(type) ? "array" : typeof type;
11676
- const parts = key.split("?");
11677
- const minimumLength = parts[2]?.includes("min")
11678
- ? parts[2].split["min:"][1]
11679
- : 0;
11675
+ type = Array.isArray(type) ? 'array' : typeof type;
11676
+ const parts = key.split('?');
11677
+ const minimumLength = parts[2]?.includes('min') ? parts[2].split['min:'][1] : 0;
11680
11678
  return { type, optional, key: parts[0], minimumLength };
11681
11679
  };
11682
11680
  const toType = (data) => {
@@ -11690,13 +11688,13 @@ const toType = (data) => {
11690
11688
  if (data instanceof BigNumber)
11691
11689
  return new TextEncoder().encode(data._hex || data.toHexString());
11692
11690
  // returns the string as a UintArray
11693
- if (typeof data === "string")
11691
+ if (typeof data === 'string')
11694
11692
  return new TextEncoder().encode(data);
11695
11693
  // returns the object as a UintArray
11696
- if (typeof data === "object")
11694
+ if (typeof data === 'object')
11697
11695
  return new TextEncoder().encode(JSON.stringify(data));
11698
11696
  // returns the number as a UintArray
11699
- if (typeof data === "number" || typeof data === "boolean")
11697
+ if (typeof data === 'number' || typeof data === 'boolean')
11700
11698
  return new TextEncoder().encode(data.toString());
11701
11699
  throw new Error(`unsuported type ${typeof data || data}`);
11702
11700
  };
@@ -11709,17 +11707,14 @@ const encode$3 = (proto, input, compress) => {
11709
11707
  const data = input[token.key];
11710
11708
  if (!token.optional && data === undefined)
11711
11709
  throw new Error(`missing required property: ${token.key}`);
11712
- if ((token.type === "array" && token.minimumLength > data?.length) ||
11713
- (token.type === "object" &&
11714
- token.minimumLength > Object.keys(data).length))
11710
+ if ((token.type === 'array' && token.minimumLength > data?.length) ||
11711
+ (token.type === 'object' && token.minimumLength > Object.keys(data).length))
11715
11712
  throw new Error(`minimumLength for ${token.key} is set to ${token.minimumLength} but got ${data.length}`);
11716
11713
  // always push data to the set.
11717
11714
  // when data is undefined push the default value of the proto
11718
11715
  set.push(toType(data || values[i]));
11719
11716
  }
11720
- return compress
11721
- ? pako.deflate(index$7(set))
11722
- : index$7(set);
11717
+ return compress ? pako.deflate(index$7(set)) : index$7(set);
11723
11718
  };
11724
11719
  const decode$4 = (proto, uint8Array, compressed) => {
11725
11720
  if (compressed)
@@ -11737,7 +11732,7 @@ const decode$4 = (proto, uint8Array, compressed) => {
11737
11732
  else if (isString(token.type))
11738
11733
  output[token.key] = toString(deconcated[i]);
11739
11734
  else if (isBoolean(token.type))
11740
- output[token.key] = Boolean(new TextDecoder().decode(deconcated[i]));
11735
+ output[token.key] = new TextDecoder().decode(deconcated[i]) === 'true';
11741
11736
  else if (isNumber(token.type))
11742
11737
  output[token.key] = Number(new TextDecoder().decode(deconcated[i]));
11743
11738
  else if (isBigNumber(token.type))
@@ -11755,7 +11750,7 @@ const decode$4 = (proto, uint8Array, compressed) => {
11755
11750
  };
11756
11751
  var index$2 = {
11757
11752
  encode: encode$3,
11758
- decode: decode$4,
11753
+ decode: decode$4
11759
11754
  };
11760
11755
 
11761
11756
  class BasicInterface {
@@ -12306,6 +12301,13 @@ class CodecHash extends BasicInterface {
12306
12301
  let FormatInterface$1 = class FormatInterface extends BasicInterface {
12307
12302
  hashFormat;
12308
12303
  #hash;
12304
+ #encoded;
12305
+ get encoded() {
12306
+ return this.#encoded || this.encode();
12307
+ }
12308
+ set encoded(value) {
12309
+ this.#encoded = value;
12310
+ }
12309
12311
  init(buffer) {
12310
12312
  if (buffer instanceof FormatInterface && buffer?.name === this.name)
12311
12313
  return buffer;
@@ -12313,7 +12315,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12313
12315
  this.fromUint8Array(buffer);
12314
12316
  else if (buffer instanceof ArrayBuffer)
12315
12317
  this.fromArrayBuffer(buffer);
12316
- else if (typeof buffer === "string") {
12318
+ else if (typeof buffer === 'string') {
12317
12319
  if (this.isHex(buffer))
12318
12320
  this.fromHex(buffer);
12319
12321
  else if (this.isBase58(buffer))
@@ -12379,7 +12381,7 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12379
12381
  constructor(buffer, proto, options) {
12380
12382
  super();
12381
12383
  this.proto = proto;
12382
- this.hashFormat = options?.hashFormat ? options.hashFormat : "bs32";
12384
+ this.hashFormat = options?.hashFormat ? options.hashFormat : 'bs32';
12383
12385
  if (options?.name)
12384
12386
  this.name = options.name;
12385
12387
  this.init(buffer);
@@ -12388,13 +12390,16 @@ let FormatInterface$1 = class FormatInterface extends BasicInterface {
12388
12390
  const upper = this.hashFormat.charAt(0).toUpperCase();
12389
12391
  return `${upper}${this.hashFormat.substring(1, this.hashFormat.length)}`;
12390
12392
  }
12393
+ beforeHashing(decoded) {
12394
+ delete decoded.hash;
12395
+ return decoded;
12396
+ }
12391
12397
  /**
12392
12398
  * @return {PeernetHash}
12393
12399
  */
12394
12400
  get peernetHash() {
12395
- const decoded = this.decoded;
12401
+ const decoded = this.beforeHashing({ ...this.decoded });
12396
12402
  // @ts-ignore
12397
- delete decoded.hash;
12398
12403
  return new CodecHash(decoded, { name: this.name });
12399
12404
  }
12400
12405
  /**
@@ -27083,7 +27088,7 @@ class Identity {
27083
27088
  this.selectedAccount = new TextDecoder().decode(selected);
27084
27089
  }
27085
27090
  else {
27086
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-20ad607b.js');
27091
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-ddb4220d.js');
27087
27092
  const { identity, accounts } = await importee.default(password, this.network);
27088
27093
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
27089
27094
  await globalThis.walletStore.put('version', String(1));
@@ -27275,7 +27280,7 @@ class Peernet {
27275
27280
  this.root = options.root;
27276
27281
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
27277
27282
  // FolderMessageResponse
27278
- } = await import(/* webpackChunkName: "messages" */ './messages-29f5675b.js');
27283
+ } = await import(/* webpackChunkName: "messages" */ './messages-c24213c9.js');
27279
27284
  /**
27280
27285
  * proto Object containing protos
27281
27286
  * @type {Object}
@@ -1,2 +1,2 @@
1
- export { P as default } from './peernet-8bfe60c5.js';
1
+ export { P as default } from './peernet-4149fb9c.js';
2
2
  import './value-4e80eeeb.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "1.1.64",
3
+ "version": "1.1.65",
4
4
  "description": "",
5
5
  "main": "src/peernet.js",
6
6
  "exports": {