core-3nweb-client-lib 0.29.1 → 0.30.0

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.
Files changed (34) hide show
  1. package/build/api-defs/startup.d.ts +6 -1
  2. package/build/core/asmail/inbox/index.js +1 -1
  3. package/build/core/asmail/inbox/msg-indexing/sql-indexing.js +1 -1
  4. package/build/core/asmail/index.js +1 -1
  5. package/build/core/startup/sign-up.js +2 -0
  6. package/build/core/startup/startup-cap.js +21 -0
  7. package/build/core/storage/index.js +48 -14
  8. package/build/core/storage/system-folders/index.js +1 -1
  9. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -1
  10. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +1 -1
  11. package/build/lib-client/3nstorage/xsp-fs/file.js +1 -1
  12. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +1 -1
  13. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +1 -1
  14. package/build/lib-client/3nstorage/xsp-fs/fs.js +2 -2
  15. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +1 -1
  16. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  17. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  18. package/build/lib-client/{fs-collection.js → fs-utils/fs-collection.js} +1 -1
  19. package/build/lib-client/{fs-sync-utils.js → fs-utils/fs-sync-utils.js} +1 -1
  20. package/build/lib-client/local-files/device-fs.d.ts +1 -1
  21. package/build/lib-client/local-files/device-fs.js +2 -2
  22. package/build/lib-common/async-iter.d.ts +1 -1
  23. package/build/lib-common/async-iter.js +2 -1
  24. package/build/protos/startup.proto.js +203 -0
  25. package/package.json +1 -1
  26. package/protos/startup.proto +4 -0
  27. /package/build/lib-client/{files-select.d.ts → fs-utils/files-select.d.ts} +0 -0
  28. /package/build/lib-client/{files-select.js → fs-utils/files-select.js} +0 -0
  29. /package/build/lib-client/{files.d.ts → fs-utils/files.d.ts} +0 -0
  30. /package/build/lib-client/{files.js → fs-utils/files.js} +0 -0
  31. /package/build/lib-client/{fs-collection.d.ts → fs-utils/fs-collection.d.ts} +0 -0
  32. /package/build/lib-client/{fs-sync-utils.d.ts → fs-utils/fs-sync-utils.d.ts} +0 -0
  33. /package/build/lib-client/{fs-view.d.ts → fs-utils/fs-view.d.ts} +0 -0
  34. /package/build/lib-client/{fs-view.js → fs-utils/fs-view.js} +0 -0
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2016 - 2017, 2020 3NSoft Inc.
2
+ Copyright (C) 2016 - 2017, 2020, 2023 3NSoft Inc.
3
3
 
4
4
  This program is free software: you can redistribute it and/or modify it under
5
5
  the terms of the GNU General Public License as published by the Free Software
@@ -23,6 +23,11 @@ declare namespace web3n.startup {
23
23
  * functionality, when user creates new account in 3NWeb domains.
24
24
  */
25
25
  interface SignUpService {
26
+
27
+ /**
28
+ * @param serviceUrl of 3NWeb signup service url.
29
+ */
30
+ setSignUpServer(serviceUrl: string): Promise<void>;
26
31
 
27
32
  /**
28
33
  * @param name is a part of address that comes before @domain
@@ -30,7 +30,7 @@ const file_1 = require("../../../lib-common/exceptions/file");
30
30
  const msg_downloader_1 = require("./msg-downloader");
31
31
  const cached_msgs_1 = require("./cached-msgs");
32
32
  const timed_cache_1 = require("../../../lib-common/timed-cache");
33
- const fs_sync_utils_1 = require("../../../lib-client/fs-sync-utils");
33
+ const fs_sync_utils_1 = require("../../../lib-client/fs-utils/fs-sync-utils");
34
34
  const MSG_INDEX_FOLDER = 'msg-index';
35
35
  /**
36
36
  * Instance of this class represents inbox-on-mail-server.
@@ -20,7 +20,7 @@ exports.makeSqliteBasedIndexedRecords = void 0;
20
20
  const timed_cache_1 = require("../../../../lib-common/timed-cache");
21
21
  const lib_sqlite_on_3nstorage_1 = require("../../../../lib-sqlite-on-3nstorage");
22
22
  const file_1 = require("../../../../lib-common/exceptions/file");
23
- const fs_sync_utils_1 = require("../../../../lib-client/fs-sync-utils");
23
+ const fs_sync_utils_1 = require("../../../../lib-client/fs-utils/fs-sync-utils");
24
24
  const operators_1 = require("rxjs/operators");
25
25
  const tab = new lib_sqlite_on_3nstorage_1.TableColumnsAndParams('inbox_index', {
26
26
  msgId: ['msg_id', 'TEXT PRIMARY KEY'],
@@ -23,7 +23,7 @@ const keyring_1 = require("./keyring");
23
23
  const config_1 = require("./config");
24
24
  const delivery_1 = require("./delivery");
25
25
  const sending_params_1 = require("./sending-params");
26
- const fs_sync_utils_1 = require("../../lib-client/fs-sync-utils");
26
+ const fs_sync_utils_1 = require("../../lib-client/fs-utils/fs-sync-utils");
27
27
  const KEYRING_DATA_FOLDER = 'keyring';
28
28
  const INBOX_DATA_FOLDER = 'inbox';
29
29
  const CONFIG_DATA_FOLDER = 'config';
@@ -64,6 +64,7 @@ class SignUp {
64
64
  this.logError = logError;
65
65
  this.mid = undefined;
66
66
  this.store = undefined;
67
+ this.serviceURL = undefined;
67
68
  this.netLazyInit = undefined;
68
69
  this.getAvailableAddresses = async (name, signupToken) => {
69
70
  const addresses = await (0, _3nweb_signup_1.checkAvailableAddressesForName)(this.net, this.serviceURL, name, signupToken);
@@ -125,6 +126,7 @@ class SignUp {
125
126
  }
126
127
  exposedService() {
127
128
  const service = {
129
+ setSignUpServer: async (srvUrl) => this.setServiceURL(srvUrl),
128
130
  addUser: this.addUser,
129
131
  createUserParams: this.createUserParams,
130
132
  getAvailableAddresses: this.getAvailableAddresses,
@@ -43,6 +43,7 @@ function makeSignInCaller(caller, objPath) {
43
43
  exports.makeSignInCaller = makeSignInCaller;
44
44
  function wrapSignUpCAP(cap) {
45
45
  return {
46
+ setSignUpServer: setSignUpServer.wrapService(cap.setSignUpServer),
46
47
  getAvailableAddresses: getAvailableAddresses.wrapService(cap.getAvailableAddresses),
47
48
  addUser: addUser.wrapService(cap.addUser),
48
49
  createUserParams: createUserParams.wrapService(cap.createUserParams),
@@ -52,6 +53,7 @@ function wrapSignUpCAP(cap) {
52
53
  exports.wrapSignUpCAP = wrapSignUpCAP;
53
54
  function makeSignUpCaller(caller, objPath) {
54
55
  return {
56
+ setSignUpServer: setSignUpServer.makeCaller(caller, objPath),
55
57
  getAvailableAddresses: getAvailableAddresses.makeCaller(caller, objPath),
56
58
  addUser: addUser.makeCaller(caller, objPath),
57
59
  createUserParams: createUserParams.makeCaller(caller, objPath),
@@ -59,6 +61,25 @@ function makeSignUpCaller(caller, objPath) {
59
61
  };
60
62
  }
61
63
  exports.makeSignUpCaller = makeSignUpCaller;
64
+ var setSignUpServer;
65
+ (function (setSignUpServer) {
66
+ const requestType = protobuf_type_1.ProtoType.for(startup_proto_1.startup.SetSignUpServerRequestBody);
67
+ function wrapService(fn) {
68
+ return buf => {
69
+ const { serviceUrl } = requestType.unpack(buf);
70
+ const promise = fn(serviceUrl);
71
+ return { promise };
72
+ };
73
+ }
74
+ setSignUpServer.wrapService = wrapService;
75
+ function makeCaller(caller, objPath) {
76
+ const path = (0, protobuf_msg_1.methodPathFor)(objPath, 'setSignUpServer');
77
+ return serviceUrl => caller
78
+ .startPromiseCall(path, requestType.pack({ serviceUrl }));
79
+ }
80
+ setSignUpServer.makeCaller = makeCaller;
81
+ })(setSignUpServer || (setSignUpServer = {}));
82
+ Object.freeze(getAvailableAddresses);
62
83
  var getAvailableAddresses;
63
84
  (function (getAvailableAddresses) {
64
85
  const requestType = protobuf_type_1.ProtoType.for(startup_proto_1.startup.GetAvailableAddressesRequestBody);
@@ -21,7 +21,7 @@ const fs_1 = require("../../lib-client/3nstorage/xsp-fs/fs");
21
21
  const storage_1 = require("./synced/storage");
22
22
  const storage_2 = require("./local/storage");
23
23
  const file_1 = require("../../lib-common/exceptions/file");
24
- const fs_collection_1 = require("../../lib-client/fs-collection");
24
+ const fs_collection_1 = require("../../lib-client/fs-utils/fs-collection");
25
25
  const async_iter_1 = require("../../lib-common/async-iter");
26
26
  const path_1 = require("path");
27
27
  const fs = require("../../lib-common/async-fs-node");
@@ -457,12 +457,13 @@ Object.freeze(PerAppStorage.prototype);
457
457
  Object.freeze(PerAppStorage);
458
458
  async function applyPolicyToFSItem(fsi, policy, path) {
459
459
  if (fsi.isFolder) {
460
- const item = await applyPolicyToFS(fsi.item, policy, path);
461
- return { isFolder: true, item };
460
+ return {
461
+ isFolder: true,
462
+ item: await applyPolicyToFS(fsi.item, policy, path)
463
+ };
462
464
  }
463
465
  else if (fsi.isCollection) {
464
- const item = await applyPolicyToFSCollection(fsi.item, policy, path);
465
- return { isCollection: true, item };
466
+ return await applyPolicyToFSCollection(fsi.item, policy, path);
466
467
  }
467
468
  else {
468
469
  throw new Error(`Given fs item is neither folder, nor fs collection`);
@@ -482,7 +483,7 @@ async function applyPolicyToFS(fs, policy, path) {
482
483
  async function applyPolicyToFSCollection(c, policy, path) {
483
484
  if (path === undefined) {
484
485
  if (policy === 'w') {
485
- return (0, fs_collection_1.readonlyWrapFSCollection)(c);
486
+ return { isCollection: true, item: (0, fs_collection_1.readonlyWrapFSCollection)(c) };
486
487
  }
487
488
  else {
488
489
  const roFSs = (0, fs_collection_1.makeFSCollection)();
@@ -494,13 +495,13 @@ async function applyPolicyToFSCollection(c, policy, path) {
494
495
  v[1].item = await v[1].item.readonlySubRoot('/');
495
496
  await roFSs.set(v[0], v[1]);
496
497
  }
497
- return (0, fs_collection_1.readonlyWrapFSCollection)(roFSs);
498
+ return { isCollection: true, item: (0, fs_collection_1.readonlyWrapFSCollection)(roFSs) };
498
499
  }
499
500
  }
500
501
  if (path.startsWith('/')) {
501
502
  path = path.substring(1);
502
503
  }
503
- const nameAndItem = await (0, async_iter_1.asyncFind)(await c.entries(), async (v) => path.startsWith(v[0]));
504
+ const nameAndItem = await (0, async_iter_1.asyncFind)(await c.entries(), v => path.startsWith(v[0]));
504
505
  if (!nameAndItem) {
505
506
  throw (0, file_1.makeFileException)('notFound', path);
506
507
  }
@@ -510,14 +511,47 @@ async function applyPolicyToFSCollection(c, policy, path) {
510
511
  if (!item.isFolder || !fs || !fs.listFolder) {
511
512
  throw new Error('Expected item to be a folder object');
512
513
  }
513
- if (policy === 'w') {
514
- return ((path === undefined) ? fs : fs.writableSubRoot(path));
514
+ if (typeof path !== 'string') {
515
+ return {
516
+ isFolder: true,
517
+ item: await ((policy === 'w') ? fs : fs.readonlySubRoot('/'))
518
+ };
515
519
  }
516
- else {
517
- if (path === undefined) {
518
- path = '/';
520
+ const atPath = await fs.stat(path);
521
+ if (atPath.isFolder) {
522
+ return {
523
+ isFolder: true,
524
+ item: await ((policy === 'w') ?
525
+ fs.writableSubRoot(path) : fs.readonlySubRoot(path))
526
+ };
527
+ }
528
+ else if (atPath.isFile) {
529
+ return {
530
+ isFile: true,
531
+ item: await ((policy === 'w') ?
532
+ fs.writableFile(path) : fs.readonlyFile(path))
533
+ };
534
+ }
535
+ else if (atPath.isLink) {
536
+ const link = await fs.readLink(path);
537
+ if (link.isFolder) {
538
+ return {
539
+ isFolder: true,
540
+ item: await link.target()
541
+ };
519
542
  }
520
- return fs.readonlySubRoot(path);
543
+ else if (link.isFile) {
544
+ return {
545
+ isFile: true,
546
+ item: await link.target()
547
+ };
548
+ }
549
+ else {
550
+ throw (0, file_1.makeFileException)('ioError', path, `Unknown type of linked fs item`);
551
+ }
552
+ }
553
+ else {
554
+ throw (0, file_1.makeFileException)('ioError', path, `Unknown type of fs item`);
521
555
  }
522
556
  }
523
557
  Object.freeze(exports);
@@ -17,7 +17,7 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.sysFilesOnDevice = exports.userFilesOnDevice = exports.initSysFolders = exports.sysFolders = void 0;
20
- const fs_collection_1 = require("../../../lib-client/fs-collection");
20
+ const fs_collection_1 = require("../../../lib-client/fs-utils/fs-collection");
21
21
  const lib_index_1 = require("../../../lib-index");
22
22
  exports.sysFolders = {
23
23
  appData: 'Apps Data',
@@ -3,7 +3,7 @@
3
3
  * reliance set.
4
4
  */
5
5
  import { NodeInFS } from './node-in-fs';
6
- import { LinkParameters } from '../../files';
6
+ import { LinkParameters } from '../../fs-utils/files';
7
7
  import { Storage, AsyncSBoxCryptor } from './common';
8
8
  import { Subscribe, ObjSource } from 'xsp-files';
9
9
  import { CommonAttrs, XAttrs } from './attrs';
@@ -1,4 +1,4 @@
1
- import { Linkable, LinkParameters } from '../../files';
1
+ import { Linkable, LinkParameters } from '../../fs-utils/files';
2
2
  import { FileNode, FileLinkParams } from './file-node';
3
3
  import { Storage } from './common';
4
4
  declare type Stats = web3n.files.Stats;
@@ -22,7 +22,7 @@ exports.FileObject = void 0;
22
22
  * reliance set.
23
23
  */
24
24
  const file_1 = require("../../../lib-common/exceptions/file");
25
- const files_1 = require("../../files");
25
+ const files_1 = require("../../fs-utils/files");
26
26
  const file_node_1 = require("./file-node");
27
27
  const buffer_utils_1 = require("../../../lib-common/buffer-utils");
28
28
  const pipe_1 = require("../../../lib-common/byte-streaming/pipe");
@@ -2,7 +2,7 @@ import { Storage, NodeType } from './common';
2
2
  import { NodeInFS } from './node-in-fs';
3
3
  import { FileNode } from './file-node';
4
4
  import { LinkNode } from './link-node';
5
- import { LinkParameters } from '../../files';
5
+ import { LinkParameters } from '../../fs-utils/files';
6
6
  import { AsyncSBoxCryptor, Subscribe, ObjSource } from 'xsp-files';
7
7
  import { CommonAttrs, XAttrs } from './attrs';
8
8
  import { NodePersistance } from './node-persistence';
@@ -1,7 +1,7 @@
1
1
  import { FolderNode, FolderLinkParams, FolderInJSON } from './folder-node';
2
2
  import { FileNode } from './file-node';
3
3
  import { Storage } from './common';
4
- import { LinkParameters } from '../../files';
4
+ import { LinkParameters } from '../../fs-utils/files';
5
5
  import { NodeInFS } from './node-in-fs';
6
6
  declare type Stats = web3n.files.Stats;
7
7
  declare type FS = web3n.files.FS;
@@ -25,8 +25,8 @@ const file_1 = require("../../../lib-common/exceptions/file");
25
25
  const folder_node_1 = require("./folder-node");
26
26
  const file_2 = require("./file");
27
27
  const common_1 = require("./common");
28
- const files_1 = require("../../files");
29
- const files_select_1 = require("../../files-select");
28
+ const files_1 = require("../../fs-utils/files");
29
+ const files_select_1 = require("../../fs-utils/files-select");
30
30
  const path_1 = require("path");
31
31
  const pipe_1 = require("../../../lib-common/byte-streaming/pipe");
32
32
  const buffer_utils_1 = require("../../../lib-common/buffer-utils");
@@ -3,7 +3,7 @@
3
3
  * reliance set.
4
4
  */
5
5
  import { NodeInFS } from './node-in-fs';
6
- import { LinkParameters } from '../../files';
6
+ import { LinkParameters } from '../../fs-utils/files';
7
7
  import { Storage, AsyncSBoxCryptor } from './common';
8
8
  import { ObjSource, Subscribe } from 'xsp-files';
9
9
  import { CommonAttrs, XAttrs } from './attrs';