@leofcoin/peernet 1.0.5 → 1.0.6

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,6 +1,5 @@
1
- import { L as LittlePubSub } from './peernet-76472a7f.js';
1
+ import { L as LittlePubSub } from './peernet-6a78293a.js';
2
2
  import './value-157ab062.js';
3
- import 'fs/promises';
4
3
 
5
4
  var clientApi = _pubsub => {
6
5
 
@@ -1,6 +1,5 @@
1
- import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-76472a7f.js';
1
+ import { M as MultiWallet, e as encrypt, b as base58$1 } from './peernet-6a78293a.js';
2
2
  import './value-157ab062.js';
3
- import 'fs/promises';
4
3
 
5
4
  /**
6
5
  * @params {String} network
@@ -1,6 +1,5 @@
1
- import { F as FormatInterface } from './peernet-76472a7f.js';
1
+ import { F as FormatInterface } from './peernet-6a78293a.js';
2
2
  import './value-157ab062.js';
3
- import 'fs/promises';
4
3
 
5
4
  var proto$b = {
6
5
  data: new Uint8Array(),
@@ -1,5 +1,4 @@
1
1
  import { K as KeyValue } from './value-157ab062.js';
2
- import { readFile } from 'fs/promises';
3
2
 
4
3
  if (!globalThis.DEBUG) {
5
4
  if (globalThis.localStorage) globalThis.DEBUG = Boolean(globalThis.localStorage.getItem('DEBUG') === 'true');
@@ -16062,8 +16061,15 @@ class Identity {
16062
16061
  return JSON.parse(accounts);
16063
16062
  }
16064
16063
  async load(password) {
16065
- if (password && password.includes('.txt'))
16066
- password = (await readFile(password)).toString();
16064
+ if (password && password.includes('.txt')) {
16065
+ const { readFile } = await import('fs/promises');
16066
+ try {
16067
+ password = (await readFile(password)).toString();
16068
+ }
16069
+ catch (error) {
16070
+ console.error(error);
16071
+ }
16072
+ }
16067
16073
  if (!password) {
16068
16074
  const importee = await import('./src/prompts/password.js');
16069
16075
  password = await importee.default();
@@ -16076,7 +16082,7 @@ class Identity {
16076
16082
  globalThis.peernet.selectedAccount = new TextDecoder().decode(selected);
16077
16083
  }
16078
16084
  else {
16079
- const importee = await import(/* webpackChunkName: "generate-account" */ './index-ae8a0f11.js');
16085
+ const importee = await import(/* webpackChunkName: "generate-account" */ './index-88c7fc2e.js');
16080
16086
  const { identity, accounts } = await importee.default(password, this.network);
16081
16087
  await globalThis.accountStore.put('public', JSON.stringify({ walletId: identity.walletId }));
16082
16088
  await globalThis.walletStore.put('version', String(1));
@@ -16242,7 +16248,7 @@ class Peernet {
16242
16248
  this.root = options.root;
16243
16249
  const { RequestMessage, ResponseMessage, PeerMessage, PeerMessageResponse, PeernetMessage, DHTMessage, DHTMessageResponse, DataMessage, DataMessageResponse, PsMessage, ChatMessage, PeernetFile
16244
16250
  // FolderMessageResponse
16245
- } = await import(/* webpackChunkName: "messages" */ './messages-b724fbb6.js');
16251
+ } = await import(/* webpackChunkName: "messages" */ './messages-ba0fcf7e.js');
16246
16252
  /**
16247
16253
  * proto Object containing protos
16248
16254
  * @type {Object}
@@ -16291,7 +16297,7 @@ class Peernet {
16291
16297
  * @see DataHandler
16292
16298
  */
16293
16299
  pubsub.subscribe('peer:data', dataHandler);
16294
- const importee = await import('./client-d63a0806.js');
16300
+ const importee = await import('./client-cbaadd55.js');
16295
16301
  /**
16296
16302
  * @access public
16297
16303
  * @type {PeernetClient}
@@ -1,3 +1,2 @@
1
- export { P as default } from './peernet-76472a7f.js';
1
+ export { P as default } from './peernet-6a78293a.js';
2
2
  import './value-157ab062.js';
3
- import 'fs/promises';
@@ -8,7 +8,6 @@ import base58 from '@vandeurenglenn/base58';
8
8
  import { decrypt, encrypt } from '@leofcoin/identity-utils';
9
9
  import QrScanner from 'qr-scanner';
10
10
  import qrcode from 'qrcode';
11
- import { readFile } from 'fs/promises';
12
11
 
13
12
  const BufferToUint8Array = data => {
14
13
  if (data.type === 'Buffer') {
@@ -320,8 +319,15 @@ class Identity {
320
319
  return JSON.parse(accounts);
321
320
  }
322
321
  async load(password) {
323
- if (password && password.includes('.txt'))
324
- password = (await readFile(password)).toString();
322
+ if (password && password.includes('.txt')) {
323
+ const { readFile } = await import('fs/promises');
324
+ try {
325
+ password = (await readFile(password)).toString();
326
+ }
327
+ catch (error) {
328
+ console.error(error);
329
+ }
330
+ }
325
331
  if (!password) {
326
332
  const importee = await import('./src/prompts/password.js');
327
333
  password = await importee.default();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@leofcoin/peernet",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "src/peernet.js",
6
6
  "exports": {
package/src/identity.ts CHANGED
@@ -3,7 +3,6 @@ import base58 from '@vandeurenglenn/base58'
3
3
  import {encrypt, decrypt} from '@leofcoin/identity-utils'
4
4
  import QrScanner from 'qr-scanner'
5
5
  import qrcode from 'qrcode'
6
- import { readFile } from 'fs/promises'
7
6
 
8
7
  export default class Identity {
9
8
  #wallet: MultiWallet
@@ -25,7 +24,15 @@ export default class Identity {
25
24
  }
26
25
 
27
26
  async load(password?: string): Promise<void> {
28
- if (password && password.includes('.txt')) password = (await readFile(password)).toString()
27
+ if (password && password.includes('.txt')) {
28
+
29
+ const { readFile } = await import('fs/promises')
30
+ try {
31
+ password = (await readFile(password)).toString()
32
+ } catch (error) {
33
+ console.error(error)
34
+ }
35
+ }
29
36
  if (!password) {
30
37
  const importee: { default: () => Promise<string> } = await import('./prompts/password.js')
31
38
  password = await importee.default()