core-3nweb-client-lib 0.21.0 → 0.24.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 (75) hide show
  1. package/build/api-defs/common-caps.d.ts +6 -9
  2. package/build/api-defs/files.d.ts +8 -7
  3. package/build/core/asmail/inbox/attachments/fs.d.ts +2 -2
  4. package/build/core/asmail/inbox/attachments/fs.js +3 -2
  5. package/build/core/asmail/msg/common.d.ts +2 -2
  6. package/build/core/asmail/msg/common.js +3 -2
  7. package/build/core/asmail/msg/opener.d.ts +2 -2
  8. package/build/core/asmail/msg/opener.js +3 -2
  9. package/build/core/asmail/msg/packer.d.ts +2 -2
  10. package/build/core/asmail/msg/packer.js +7 -6
  11. package/build/core/index.d.ts +1 -1
  12. package/build/core/index.js +1 -1
  13. package/build/core/storage/index.js +2 -2
  14. package/build/core/storage/local/obj-files.js +8 -5
  15. package/build/core/storage/local/obj-status.js +4 -3
  16. package/build/core/storage/synced/obj-status.js +4 -3
  17. package/build/ipc-via-protobuf/bytes.d.ts +4 -4
  18. package/build/ipc-via-protobuf/bytes.js +1 -1
  19. package/build/ipc-via-protobuf/connector-clients-side.d.ts +2 -2
  20. package/build/ipc-via-protobuf/connector-services-side.d.ts +3 -3
  21. package/build/ipc-via-protobuf/connector-services-side.js +0 -1
  22. package/build/ipc-via-protobuf/connector.d.ts +6 -7
  23. package/build/ipc-via-protobuf/connector.js +1 -16
  24. package/build/ipc-via-protobuf/file.d.ts +7 -3
  25. package/build/ipc-via-protobuf/file.js +17 -15
  26. package/build/ipc-via-protobuf/fs.d.ts +2 -2
  27. package/build/ipc-via-protobuf/fs.js +1 -1
  28. package/build/ipc-via-protobuf/protobuf-msg.d.ts +3 -4
  29. package/build/lib-client/3nstorage/xsp-fs/attrs.d.ts +28 -0
  30. package/build/lib-client/3nstorage/xsp-fs/attrs.js +337 -0
  31. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +1 -1
  32. package/build/lib-client/3nstorage/xsp-fs/common.js +3 -2
  33. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +31 -18
  34. package/build/lib-client/3nstorage/xsp-fs/file-node.js +130 -118
  35. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +0 -1
  36. package/build/lib-client/3nstorage/xsp-fs/file.js +14 -49
  37. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.d.ts +1 -1
  38. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +95 -91
  39. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +19 -24
  40. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +133 -190
  41. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +3 -4
  42. package/build/lib-client/3nstorage/xsp-fs/fs.js +18 -21
  43. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +13 -8
  44. package/build/lib-client/3nstorage/xsp-fs/link-node.js +46 -38
  45. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +17 -35
  46. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +34 -127
  47. package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +57 -0
  48. package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +182 -0
  49. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.d.ts +3 -0
  50. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +87 -0
  51. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.d.ts +6 -0
  52. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +1022 -0
  53. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  54. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  55. package/build/lib-client/local-files/device-fs.js +7 -3
  56. package/build/lib-client/objs-on-disk/file-writing-proc.js +3 -2
  57. package/build/lib-client/objs-on-disk/obj-on-disk.js +8 -7
  58. package/build/lib-common/big-endian.d.ts +0 -24
  59. package/build/lib-common/big-endian.js +16 -78
  60. package/build/lib-common/exceptions/file.js +6 -2
  61. package/build/lib-common/obj-streaming/sink-utils.d.ts +0 -4
  62. package/build/lib-common/obj-streaming/sink-utils.js +4 -70
  63. package/build/lib-common/objs-on-disk/file-layout.js +2 -1
  64. package/build/lib-common/objs-on-disk/obj-file.js +2 -2
  65. package/build/lib-common/objs-on-disk/utils.js +2 -1
  66. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +2 -1
  67. package/package.json +2 -2
  68. package/build/lib-client/files/file-attrs.d.ts +0 -76
  69. package/build/lib-client/files/file-attrs.js +0 -549
  70. package/build/lib-client/files/file-layout.d.ts +0 -56
  71. package/build/lib-client/files/file-layout.js +0 -456
  72. package/build/lib-client/files/file-sink.d.ts +0 -33
  73. package/build/lib-client/files/file-sink.js +0 -173
  74. package/build/lib-client/files/file-source.d.ts +0 -19
  75. package/build/lib-client/files/file-source.js +0 -115
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2017 - 2018, 2020 - 2021 3NSoft Inc.
2
+ Copyright (C) 2017 - 2018, 2020 - 2022 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
@@ -28,14 +28,11 @@ declare namespace web3n.caps.common {
28
28
 
29
29
  type DevPathChecker = (path: string) => 'w'|'r'|false;
30
30
 
31
- interface AppManifest {
32
- appDomain: string;
33
- capsRequested: {
34
- mail?: MailCAPSetting;
35
- storage?: StorageCAPSetting;
36
- mailerid?: true;
37
- log?: LogCAPSetting;
38
- };
31
+ interface RequestedCAPs {
32
+ mail?: MailCAPSetting;
33
+ storage?: StorageCAPSetting;
34
+ mailerid?: true;
35
+ log?: LogCAPSetting;
39
36
  }
40
37
 
41
38
  interface StorageCAPSetting {
@@ -1,5 +1,5 @@
1
1
  /*
2
- Copyright (C) 2016 - 2018, 2020 3NSoft Inc.
2
+ Copyright (C) 2016 - 2018, 2020, 2022 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
@@ -39,6 +39,7 @@ declare namespace web3n.files {
39
39
  notImplemented?: true;
40
40
  attrsNotEnabledInFS?: true;
41
41
  versionMismatch?: true;
42
+ isEndless?: true;
42
43
  }
43
44
 
44
45
  interface exceptionCode {
@@ -56,6 +57,7 @@ declare namespace web3n.files {
56
57
  concurrentUpdate: 'concurrent-update';
57
58
  parsingError: 'parsing-error';
58
59
  notImplemented: 'ENOSYS';
60
+ isEndless: 'is-endless';
59
61
  }
60
62
 
61
63
  /**
@@ -99,6 +101,11 @@ declare namespace web3n.files {
99
101
  */
100
102
  size?: number;
101
103
 
104
+ /**
105
+ * Flag indicating if file is an endless (unknown place of end) stream.
106
+ */
107
+ isEndless?: boolean;
108
+
102
109
  /**
103
110
  * Last content modification time stamp.
104
111
  * If such information cannot be provided, this field will be absent.
@@ -152,12 +159,6 @@ declare namespace web3n.files {
152
159
  getPosition(): Promise<number>;
153
160
  }
154
161
 
155
- interface FileSection {
156
- hasContent: boolean;
157
- ofs: number;
158
- len: number;
159
- }
160
-
161
162
  interface LayoutSection {
162
163
  src: 'new' | 'base' | 'empty';
163
164
  ofs: number;
@@ -1,6 +1,6 @@
1
- import { StorageGetter, FolderInfoWithAttrs } from '../../../../lib-client/3nstorage/xsp-fs/common';
1
+ import { StorageGetter, FolderInJSON } from '../../../../lib-client/3nstorage/xsp-fs/common';
2
2
  import { AsyncSBoxCryptor } from 'xsp-files';
3
3
  import { MsgOnDisk } from '../msg-on-disk';
4
4
  declare type ReadonlyFS = web3n.files.ReadonlyFS;
5
- export declare function fsForAttachments(msg: MsgOnDisk, rootJson: FolderInfoWithAttrs, storages: StorageGetter, cryptor: AsyncSBoxCryptor): ReadonlyFS;
5
+ export declare function fsForAttachments(msg: MsgOnDisk, rootJson: FolderInJSON, storages: StorageGetter, cryptor: AsyncSBoxCryptor): ReadonlyFS;
6
6
  export {};
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016 - 2019 3NSoft Inc.
3
+ Copyright (C) 2016 - 2019, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.fsForAttachments = void 0;
19
20
  const common_1 = require("../../../../lib-client/3nstorage/xsp-fs/common");
@@ -1,5 +1,5 @@
1
1
  import { JsonKeyShort } from '../../../lib-common/jwkeys';
2
- import { FolderInfoWithAttrs } from '../../../lib-client/3nstorage/xsp-fs/common';
2
+ import { FolderInJSON } from '../../../lib-client/3nstorage/xsp-fs/common';
3
3
  import * as confApi from '../../../lib-common/service-api/asmail/config';
4
4
  /**
5
5
  * Metadata for message that uses established key pair.
@@ -24,7 +24,7 @@ export interface MsgEnvelope {
24
24
  'Msg Type': string;
25
25
  'Subject'?: string;
26
26
  'Body': MainBody;
27
- 'Attachments'?: FolderInfoWithAttrs;
27
+ 'Attachments'?: FolderInJSON;
28
28
  'Flow Params': FlowParams;
29
29
  'From': string;
30
30
  'To'?: string[];
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2018, 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2018, 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -13,6 +13,7 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  Object.freeze(exports);
@@ -1,7 +1,7 @@
1
1
  import * as confApi from '../../../lib-common/service-api/asmail/config';
2
2
  import { MsgEnvelope, MainBody, SuggestedNextKeyPair, SendingParams } from './common';
3
3
  import { AsyncSBoxCryptor, ObjSource } from 'xsp-files';
4
- import { FolderInfoWithAttrs } from '../../../lib-client/3nstorage/xsp-fs/common';
4
+ import { FolderInJSON } from '../../../lib-client/3nstorage/xsp-fs/common';
5
5
  import { MsgKeyRole } from '../keyring';
6
6
  export { SuggestedNextKeyPair } from './common';
7
7
  export declare class OpenedMsg {
@@ -18,6 +18,6 @@ export declare class OpenedMsg {
18
18
  get msgCount(): number;
19
19
  get nextSendingParams(): SendingParams | undefined;
20
20
  get introCryptoCerts(): confApi.p.initPubKey.Certs;
21
- get attachmentsJSON(): FolderInfoWithAttrs | undefined;
21
+ get attachmentsJSON(): FolderInJSON | undefined;
22
22
  }
23
23
  export declare function openMsg(msgId: string, mainObjId: string, mainObj: ObjSource, headerOfs: number, fKey: Uint8Array, cryptor: AsyncSBoxCryptor): Promise<OpenedMsg>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.openMsg = exports.OpenedMsg = void 0;
19
20
  const buffer_utils_1 = require("../../../lib-common/buffer-utils");
@@ -1,6 +1,6 @@
1
1
  import { AsyncSBoxCryptor, ObjSource } from 'xsp-files';
2
2
  import * as delivApi from '../../../lib-common/service-api/asmail/delivery';
3
- import { FolderInfoWithAttrs } from '../../../lib-client/3nstorage/xsp-fs/common';
3
+ import { FolderInJSON } from '../../../lib-client/3nstorage/xsp-fs/common';
4
4
  import * as confApi from '../../../lib-common/service-api/asmail/config';
5
5
  import { MsgEnvelope, SuggestedNextKeyPair, SendingParams } from './common';
6
6
  import { Encryptor } from '../../../lib-common/async-cryptor-wrap';
@@ -24,7 +24,7 @@ export interface PackJSON {
24
24
  }
25
25
  export interface MsgObj {
26
26
  json?: any;
27
- folder?: FolderInfoWithAttrs;
27
+ folder?: FolderInJSON;
28
28
  file?: PathInMsg;
29
29
  /**
30
30
  * This is object's id in the message
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2018, 2020 3NSoft Inc.
3
+ Copyright (C) 2015 - 2018, 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.MsgPacker = void 0;
19
20
  const ecma_nacl_1 = require("ecma-nacl");
@@ -139,7 +140,7 @@ class MsgPacker {
139
140
  };
140
141
  }
141
142
  async addFolderInto(outerFolder, fName, fs, fsPath) {
142
- const folder = { nodes: {} };
143
+ const folder = { nodes: {}, ctime: outerFolder.ctime };
143
144
  const list = await fs.listFolder('.');
144
145
  for (const entry of list) {
145
146
  const fName = entry.name;
@@ -282,7 +283,7 @@ class MsgPacker {
282
283
  throw new Error(`Attachments are already set.`);
283
284
  }
284
285
  // attachments folder json to insert into main
285
- const attachments = { nodes: {} };
286
+ const attachments = { nodes: {}, ctime: Date.now() };
286
287
  // populate attachments json
287
288
  const path = { start: 'attachments', path: [] };
288
289
  if (att.container && !attachments_container_1.isContainerEmpty(att.container)) {
@@ -346,7 +347,7 @@ class MsgPacker {
346
347
  }
347
348
  const msgKeyPack = await msgKeyEnc.pack(obj.key);
348
349
  const bytes = buffer_utils_1.utf8.pack(JSON.stringify(obj.json));
349
- const segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs }, random.bytes, cryptor);
350
+ const segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random.bytes, cryptor);
350
351
  // make source that inserts message key pack into header
351
352
  return makeMainObjSrc(msgKeyPack, bytes, segWriter);
352
353
  }
@@ -412,7 +413,7 @@ class MsgPacker {
412
413
  segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'restart', header }, random.bytes, cryptor);
413
414
  }
414
415
  else {
415
- segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs }, random.bytes, cryptor);
416
+ segWriter = await xsp_files_1.makeSegmentsWriter(obj.key, xsp_files_1.idToHeaderNonce(obj.id), 0, { type: 'new', segSize: this.segSizeIn256bs, payloadFormat: 1 }, random.bytes, cryptor);
416
417
  }
417
418
  // make object source
418
419
  let src;
@@ -2,7 +2,7 @@ import { FactoryOfFSs } from './storage';
2
2
  import { makeCryptor } from '../lib-client/cryptor/cryptor';
3
3
  import { NetClient } from '../lib-client/request-utils';
4
4
  import { ServiceLocatorMaker } from '../lib-client/service-locator';
5
- declare type RequestedCAPs = web3n.caps.common.AppManifest['capsRequested'];
5
+ declare type RequestedCAPs = web3n.caps.common.RequestedCAPs;
6
6
  declare type W3N = web3n.caps.common.W3N;
7
7
  export interface CoreConf {
8
8
  dataDir: string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2021 3NSoft Inc.
3
+ Copyright (C) 2015 - 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -36,13 +36,13 @@ function makeBadAppNameExc(appName) {
36
36
  appName
37
37
  };
38
38
  }
39
- function makeNotAllowedToOpenAppFSExc(appName) {
39
+ function makeNotAllowedToOpenAppFSExc(appFolder) {
40
40
  return {
41
41
  runtimeException: true,
42
42
  type: 'storage',
43
43
  storageSegment: 'app',
44
44
  notAllowedToOpenFS: true,
45
- appName
45
+ appName: reverseDomain(appFolder)
46
46
  };
47
47
  }
48
48
  function makeNotAllowedToOpenUserFSExc(storageType) {
@@ -23,8 +23,6 @@ const processes_1 = require("../../../lib-common/processes");
23
23
  const path_1 = require("path");
24
24
  const obj_files_gc_1 = require("./obj-files-gc");
25
25
  const obj_status_1 = require("./obj-status");
26
- const operators_1 = require("rxjs/operators");
27
- const utils_for_observables_1 = require("../../../lib-common/utils-for-observables");
28
26
  const timed_cache_1 = require("../../../lib-common/timed-cache");
29
27
  class ObjFiles {
30
28
  constructor(folders, logError) {
@@ -141,12 +139,17 @@ class LocalObj {
141
139
  }
142
140
  const fPath = this.path(version);
143
141
  const { obj, write$ } = await obj_on_disk_1.ObjOnDisk.createFileForWriteOfNewVersion(this.objId, version, fPath, encSub, undefined, this.objSegsGetterFromDisk);
144
- // this.verObjs.set(version, obj);
145
- await write$.pipe(operators_1.tap(undefined, err => {
142
+ try {
143
+ await write$.toPromise();
144
+ }
145
+ catch (err) {
146
146
  if (this.verObjs.get(version) === obj) {
147
147
  this.verObjs.delete(version);
148
148
  }
149
- }), utils_for_observables_1.flatTap(undefined, undefined, () => this.status.setNewCurrentVersion(version, obj.getBaseVersion()))).toPromise();
149
+ throw err;
150
+ }
151
+ this.verObjs.set(version, obj);
152
+ await this.status.setNewCurrentVersion(version, obj.getBaseVersion());
150
153
  this.scheduleGC(this);
151
154
  }
152
155
  isArchived() {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016 - 2020 3NSoft Inc.
3
+ Copyright (C) 2016 - 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.ObjStatus = void 0;
19
20
  const fs = require("../../../lib-common/async-fs-node");
@@ -63,7 +64,6 @@ class ObjStatus {
63
64
  };
64
65
  }
65
66
  async setNewCurrentVersion(newVersion, baseVer) {
66
- this.status.currentVersion = newVersion;
67
67
  if (baseVer !== undefined) {
68
68
  // base->diff links should be added before removals
69
69
  addBaseToDiffLinkInStatus(this.status, newVersion, baseVer);
@@ -71,6 +71,7 @@ class ObjStatus {
71
71
  if (typeof this.status.currentVersion === 'number') {
72
72
  rmNonArchVersionsIn(this.status, this.status.currentVersion);
73
73
  }
74
+ this.status.currentVersion = newVersion;
74
75
  await this.saveProc.trigger();
75
76
  }
76
77
  async removeCurrentVersion(verObjs) {
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016 - 2020 3NSoft Inc.
3
+ Copyright (C) 2016 - 2020, 2022 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
15
  You should have received a copy of the GNU General Public License along with
16
- this program. If not, see <http://www.gnu.org/licenses/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.ObjStatus = void 0;
19
20
  const processes_1 = require("../../../lib-common/processes");
@@ -184,7 +185,6 @@ function rmNonArchVersionsIn(status, ver) {
184
185
  // status: ObjStatusInfo, newVersion: number, baseVer: number|undefined
185
186
  // ): void {
186
187
  // if (status.isArchived) { return; }
187
- // status.versions.current = newVersion;
188
188
  // if (status.syncState === 'synced') {
189
189
  // status.syncState = 'unsynced';
190
190
  // }
@@ -195,6 +195,7 @@ function rmNonArchVersionsIn(status, ver) {
195
195
  // if (status.versions.current) {
196
196
  // rmNonArchVersionsIn(status, status.versions.current);
197
197
  // }
198
+ // status.versions.current = newVersion;
198
199
  // }
199
200
  // export function addConflictingRemoteVersionTo(
200
201
  // status: ObjStatusInfo, conflictVersion: number
@@ -2,8 +2,8 @@ import { ObjectReference } from './protobuf-msg';
2
2
  import { ExposedServices, Caller } from './connector';
3
3
  declare type FileByteSink = web3n.files.FileByteSink;
4
4
  declare type FileByteSource = web3n.files.FileByteSource;
5
- export declare function makeSinkCaller(caller: Caller, ref: ObjectReference): FileByteSink;
6
- export declare function exposeSinkService(sink: FileByteSink, expServices: ExposedServices): ObjectReference;
7
- export declare function makeSrcCaller(caller: Caller, ref: ObjectReference): FileByteSource;
8
- export declare function exposeSrcService(src: FileByteSource, expServices: ExposedServices): ObjectReference;
5
+ export declare function makeSinkCaller(caller: Caller, ref: ObjectReference<'FileByteSink'>): FileByteSink;
6
+ export declare function exposeSinkService(sink: FileByteSink, expServices: ExposedServices): ObjectReference<'FileByteSink'>;
7
+ export declare function makeSrcCaller(caller: Caller, ref: ObjectReference<'FileByteSource'>): FileByteSource;
8
+ export declare function exposeSrcService(src: FileByteSource, expServices: ExposedServices): ObjectReference<'FileByteSource'>;
9
9
  export {};
@@ -147,7 +147,7 @@ var sinkShowLayout;
147
147
  }
148
148
  function unpackLayout(msg) {
149
149
  return {
150
- base: protobuf_msg_1.valOfOpt(msg.base),
150
+ base: protobuf_msg_1.valOfOptInt(msg.base),
151
151
  sections: protobuf_msg_1.fixArray(msg.sections).map(({ src, ofs, len }) => ({
152
152
  src, ofs: protobuf_msg_1.fixInt(ofs), len: protobuf_msg_1.fixInt(len)
153
153
  }))
@@ -20,9 +20,9 @@ export declare class ClientsSideImpl implements ClientsSide {
20
20
  private startCall;
21
21
  startPromiseCall(path: string[], req: EnvelopeBody): Promise<EnvelopeBody>;
22
22
  startObservableCall(path: string[], req: EnvelopeBody, obs: Subject<EnvelopeBody>): () => void;
23
- registerClientDrop(o: any, srvRef: ObjectReference): void;
23
+ registerClientDrop(o: any, srvRef: ObjectReference<any>): void;
24
24
  private makeClientDropCB;
25
25
  private sendObjDropMsg;
26
- srvRefOf(clientObj: any): ObjectReference;
26
+ srvRefOf(clientObj: any): ObjectReference<any>;
27
27
  listObj(path: string[]): string[];
28
28
  }
@@ -1,4 +1,4 @@
1
- import { ObjectReference, ExposedObjType } from "./protobuf-msg";
1
+ import { ObjectReference } from "./protobuf-msg";
2
2
  import { ServicesSide, Envelope, EnvelopeBody, ExposedFn, ExposedObj, ExposedServices } from "./connector";
3
3
  export declare class ServicesSideImpl implements ServicesSide {
4
4
  private readonly sendMsg;
@@ -16,8 +16,8 @@ export declare class ServicesSideImpl implements ServicesSide {
16
16
  }
17
17
  export declare class ExposedObjs {
18
18
  private readonly objs;
19
- exposeDroppableService(objType: ExposedObjType, exp: ExposedFn | ExposedObj<any>, original: any): ObjectReference;
20
- getOriginalObj<T>(ref: ObjectReference): T;
19
+ exposeDroppableService<T>(objType: T, exp: ExposedFn | ExposedObj<any>, original: any): ObjectReference<T>;
20
+ getOriginalObj<T>(ref: ObjectReference<any>): T;
21
21
  exposeW3NService(exp: ExposedFn | ExposedObj<any>): void;
22
22
  drop(name: string): void;
23
23
  find(path: string[] | undefined): ExposedFn | ExposedObj<any> | undefined;
@@ -149,7 +149,6 @@ class ExposedObjs {
149
149
  this.objs = new Map();
150
150
  }
151
151
  exposeDroppableService(objType, exp, original) {
152
- connector_1.ensureCorrectRefObjType(objType);
153
152
  let id;
154
153
  do {
155
154
  id = random_node_1.stringOfB64CharsSync(20);
@@ -1,9 +1,9 @@
1
1
  /// <reference types="node" />
2
2
  import { Observable, Observer, Subject } from "rxjs";
3
- import { ObjectReference, ExposedObjType, Value } from "./protobuf-msg";
3
+ import { ObjectReference, Value } from "./protobuf-msg";
4
4
  export interface ExposedServices {
5
- exposeDroppableService(objType: ExposedObjType, exp: ExposedFn | ExposedObj<any>, original: any): ObjectReference;
6
- getOriginalObj<T>(ref: ObjectReference): T;
5
+ exposeDroppableService<T>(objType: T, exp: ExposedFn | ExposedObj<any>, original: any): ObjectReference<T>;
6
+ getOriginalObj<T>(ref: ObjectReference<any>): T;
7
7
  exposeW3NService(exp: ExposedFn | ExposedObj<any>): void;
8
8
  listObj(path: string[]): string[] | null;
9
9
  }
@@ -18,8 +18,8 @@ export interface ServicesSide {
18
18
  export interface Caller {
19
19
  startPromiseCall(path: string[], req: EnvelopeBody): Promise<EnvelopeBody>;
20
20
  startObservableCall(path: string[], req: EnvelopeBody, obs: Subject<EnvelopeBody>): () => void;
21
- registerClientDrop(o: any, srvRef: ObjectReference): void;
22
- srvRefOf(clientObj: any): ObjectReference;
21
+ registerClientDrop(o: any, srvRef: ObjectReference<any>): void;
22
+ srvRefOf(clientObj: any): ObjectReference<any>;
23
23
  listObj(path: string[]): string[];
24
24
  }
25
25
  export interface ClientsSide {
@@ -43,7 +43,6 @@ export declare class ObjectsConnector {
43
43
  private sendCallError;
44
44
  }
45
45
  export declare const W3N_NAME = "w3n";
46
- export declare function ensureCorrectRefObjType(objType: ExposedObjType): void;
47
46
  /**
48
47
  * Envelope is a message form that is sent in IPC channel.
49
48
  */
@@ -86,4 +85,4 @@ export interface IPCException extends web3n.RuntimeException {
86
85
  path?: string[];
87
86
  }
88
87
  export declare function makeIPCException(fields: Partial<IPCException>): IPCException;
89
- export declare function checkRefObjTypeIs(expected: ExposedObjType, ref: ObjectReference): void;
88
+ export declare function checkRefObjTypeIs<T>(expected: T, ref: ObjectReference<T>): void;
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.checkRefObjTypeIs = exports.makeIPCException = exports.msgProtoType = exports.ensureCorrectRefObjType = exports.W3N_NAME = exports.ObjectsConnector = void 0;
19
+ exports.checkRefObjTypeIs = exports.makeIPCException = exports.msgProtoType = exports.W3N_NAME = exports.ObjectsConnector = void 0;
20
20
  const protobuf_msg_1 = require("./protobuf-msg");
21
21
  // Note that make_?_Side functions could've been imported normally, but client
22
22
  // side uses weakrefs, while services side doesn't, and services side is used
@@ -156,21 +156,6 @@ exports.ObjectsConnector = ObjectsConnector;
156
156
  Object.freeze(ObjectsConnector.prototype);
157
157
  Object.freeze(ObjectsConnector);
158
158
  exports.W3N_NAME = 'w3n';
159
- function ensureCorrectRefObjType(objType) {
160
- switch (objType) {
161
- case 'FileByteSink':
162
- case 'FileByteSource':
163
- case 'FileImpl':
164
- case 'FSImpl':
165
- case 'SymLinkImpl':
166
- case 'FSCollection':
167
- case 'FSItemsIter':
168
- return;
169
- default:
170
- throw new Error(`Object type ${objType} is not known`);
171
- }
172
- }
173
- exports.ensureCorrectRefObjType = ensureCorrectRefObjType;
174
159
  exports.msgProtoType = protobuf_msg_1.makeProtobufTypeFrom('ipc.proto', 'ipc.Envelope');
175
160
  function makeIPCException(fields) {
176
161
  const exc = {
@@ -20,7 +20,7 @@ export interface FileMsg {
20
20
  isVersioned: boolean;
21
21
  name: string;
22
22
  isNew: boolean;
23
- impl: ObjectReference;
23
+ impl: ObjectReference<'FileImpl'>;
24
24
  }
25
25
  export declare function packXAttrValue(val: any): EnvelopeBody;
26
26
  export declare function unpackXAttrValue(buf: EnvelopeBody): any;
@@ -42,6 +42,10 @@ export declare namespace vGetXAttr {
42
42
  bytes?: Value<Buffer>;
43
43
  }
44
44
  const replyType: ProtoType<Reply>;
45
+ function unpackReply(buf: EnvelopeBody): {
46
+ attr: any;
47
+ version: number;
48
+ };
45
49
  function wrapService(fn: ReadonlyFileVersionedAPI['getXAttr']): ExposedFn;
46
50
  function makeCaller(caller: Caller, objPath: string[]): ReadonlyFileVersionedAPI['getXAttr'];
47
51
  }
@@ -87,7 +91,7 @@ export declare namespace vReadJSON {
87
91
  export declare namespace vGetByteSource {
88
92
  interface Reply {
89
93
  version: number;
90
- src: ObjectReference;
94
+ src: ObjectReference<'FileByteSource'>;
91
95
  }
92
96
  const replyType: ProtoType<Reply>;
93
97
  function wrapService(fn: ReadonlyFileVersionedAPI['getByteSource'], expServices: ExposedServices): ExposedFn;
@@ -116,7 +120,7 @@ export declare namespace updateXAttrs {
116
120
  export declare namespace vGetByteSink {
117
121
  interface Reply {
118
122
  version: number;
119
- sink: ObjectReference;
123
+ sink: ObjectReference<'FileByteSink'>;
120
124
  }
121
125
  const replyType: ProtoType<Reply>;
122
126
  function wrapService(fn: WritableFileVersionedAPI['getByteSink'], expServices: ExposedServices): ExposedFn;
@@ -214,8 +214,8 @@ var getXAttr;
214
214
  getXAttr.wrapService = wrapService;
215
215
  function makeCaller(caller, objPath) {
216
216
  const path = objPath.concat('getXAttr');
217
- return () => caller
218
- .startPromiseCall(path, undefined)
217
+ return xaName => caller
218
+ .startPromiseCall(path, requestType.pack({ xaName }))
219
219
  .then(unpackXAttrValue);
220
220
  }
221
221
  getXAttr.makeCaller = makeCaller;
@@ -413,6 +413,20 @@ var vGetXAttr;
413
413
  (function (vGetXAttr) {
414
414
  const requestType = makeFileType('GetXAttrRequestBody');
415
415
  vGetXAttr.replyType = makeFileType('VersionedGetXAttrReplyBody');
416
+ function unpackReply(buf) {
417
+ const { json, str, bytes, version: v } = vGetXAttr.replyType.unpack(buf);
418
+ const version = protobuf_msg_1.fixInt(v);
419
+ if (bytes) {
420
+ return { version, attr: protobuf_msg_1.valOf(bytes) };
421
+ }
422
+ else if (str) {
423
+ return { version, attr: protobuf_msg_1.valOf(str) };
424
+ }
425
+ else {
426
+ return { version, attr: protobuf_msg_1.valOfOptJson(json) };
427
+ }
428
+ }
429
+ vGetXAttr.unpackReply = unpackReply;
416
430
  function wrapService(fn) {
417
431
  return buf => {
418
432
  const { xaName } = requestType.unpack(buf);
@@ -436,19 +450,7 @@ var vGetXAttr;
436
450
  const path = objPath.concat('getXAttr');
437
451
  return () => caller
438
452
  .startPromiseCall(path, undefined)
439
- .then(buf => {
440
- const { json, str, bytes, version: v } = vGetXAttr.replyType.unpack(buf);
441
- const version = protobuf_msg_1.fixInt(v);
442
- if (bytes) {
443
- return { version, attr: protobuf_msg_1.valOf(bytes) };
444
- }
445
- else if (str) {
446
- return { version, attr: protobuf_msg_1.valOf(str) };
447
- }
448
- else {
449
- return { version, attr: protobuf_msg_1.valOfOptJson(json) };
450
- }
451
- });
453
+ .then(unpackReply);
452
454
  }
453
455
  vGetXAttr.makeCaller = makeCaller;
454
456
  })(vGetXAttr = exports.vGetXAttr || (exports.vGetXAttr = {}));
@@ -11,7 +11,7 @@ export interface FSMsg {
11
11
  isVersioned: boolean;
12
12
  writable: boolean;
13
13
  name: string;
14
- impl: ObjectReference;
14
+ impl: ObjectReference<'FSImpl'>;
15
15
  }
16
16
  export declare const fsMsgType: ProtoType<FSMsg>;
17
17
  export declare namespace fsItem {
@@ -23,7 +23,7 @@ export declare namespace fsItem {
23
23
  item?: {
24
24
  fs?: FSMsg;
25
25
  file?: FileMsg;
26
- collection?: ObjectReference;
26
+ collection?: ObjectReference<'FSCollection'>;
27
27
  };
28
28
  location?: {
29
29
  fs: FSMsg;
@@ -1043,7 +1043,7 @@ var vGetXAttr;
1043
1043
  const ipcPath = objPath.concat('getXAttr');
1044
1044
  return (path, xaName) => caller
1045
1045
  .startPromiseCall(ipcPath, getXAttr.requestType.pack({ path, xaName }))
1046
- .then(file_1.unpackXAttrValue);
1046
+ .then(file.vGetXAttr.unpackReply);
1047
1047
  }
1048
1048
  vGetXAttr.makeCaller = makeCaller;
1049
1049
  })(vGetXAttr || (vGetXAttr = {}));
@@ -3,12 +3,11 @@ import { EnvelopeBody } from './connector';
3
3
  import { ProtoType } from '../lib-client/protobuf-loader';
4
4
  declare type RuntimeException = web3n.RuntimeException;
5
5
  export declare function makeProtobufTypeFrom<T extends object>(protoFile: string, typeName: string): ProtoType<T>;
6
- export declare type ExposedObjType = 'FileByteSink' | 'FileByteSource' | 'FileImpl' | 'FSImpl' | 'SymLinkImpl' | 'FSCollection' | 'FSItemsIter';
7
- export interface ObjectReference {
8
- objType: ExposedObjType;
6
+ export interface ObjectReference<T> {
7
+ objType: T;
9
8
  path: string[];
10
9
  }
11
- export declare const objRefType: ProtoType<ObjectReference>;
10
+ export declare const objRefType: ProtoType<ObjectReference<any>>;
12
11
  export interface BooleanValue {
13
12
  value: boolean;
14
13
  }