core-3nweb-client-lib 0.21.0 → 0.22.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 (61) hide show
  1. package/build/api-defs/files.d.ts +8 -7
  2. package/build/core/asmail/inbox/attachments/fs.d.ts +2 -2
  3. package/build/core/asmail/inbox/attachments/fs.js +3 -2
  4. package/build/core/asmail/msg/common.d.ts +2 -2
  5. package/build/core/asmail/msg/common.js +3 -2
  6. package/build/core/asmail/msg/opener.d.ts +2 -2
  7. package/build/core/asmail/msg/opener.js +3 -2
  8. package/build/core/asmail/msg/packer.d.ts +2 -2
  9. package/build/core/asmail/msg/packer.js +7 -6
  10. package/build/core/storage/index.js +2 -2
  11. package/build/core/storage/local/obj-files.js +8 -5
  12. package/build/core/storage/local/obj-status.js +4 -3
  13. package/build/core/storage/synced/obj-status.js +4 -3
  14. package/build/ipc-via-protobuf/bytes.js +1 -1
  15. package/build/lib-client/3nstorage/xsp-fs/attrs.d.ts +28 -0
  16. package/build/lib-client/3nstorage/xsp-fs/attrs.js +337 -0
  17. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +1 -1
  18. package/build/lib-client/3nstorage/xsp-fs/common.js +3 -2
  19. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +31 -18
  20. package/build/lib-client/3nstorage/xsp-fs/file-node.js +130 -118
  21. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +0 -1
  22. package/build/lib-client/3nstorage/xsp-fs/file.js +14 -49
  23. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.d.ts +1 -1
  24. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +95 -91
  25. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +19 -24
  26. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +133 -190
  27. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +3 -4
  28. package/build/lib-client/3nstorage/xsp-fs/fs.js +18 -21
  29. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +13 -8
  30. package/build/lib-client/3nstorage/xsp-fs/link-node.js +46 -38
  31. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +17 -35
  32. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +34 -127
  33. package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +57 -0
  34. package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +182 -0
  35. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.d.ts +3 -0
  36. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +87 -0
  37. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.d.ts +6 -0
  38. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +1022 -0
  39. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  40. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  41. package/build/lib-client/local-files/device-fs.js +7 -3
  42. package/build/lib-client/objs-on-disk/file-writing-proc.js +3 -2
  43. package/build/lib-client/objs-on-disk/obj-on-disk.js +8 -7
  44. package/build/lib-common/big-endian.d.ts +0 -24
  45. package/build/lib-common/big-endian.js +16 -78
  46. package/build/lib-common/exceptions/file.js +5 -1
  47. package/build/lib-common/obj-streaming/sink-utils.d.ts +0 -4
  48. package/build/lib-common/obj-streaming/sink-utils.js +4 -70
  49. package/build/lib-common/objs-on-disk/file-layout.js +2 -1
  50. package/build/lib-common/objs-on-disk/obj-file.js +2 -2
  51. package/build/lib-common/objs-on-disk/utils.js +2 -1
  52. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +2 -1
  53. package/package.json +2 -2
  54. package/build/lib-client/files/file-attrs.d.ts +0 -76
  55. package/build/lib-client/files/file-attrs.js +0 -549
  56. package/build/lib-client/files/file-layout.d.ts +0 -56
  57. package/build/lib-client/files/file-layout.js +0 -456
  58. package/build/lib-client/files/file-sink.d.ts +0 -33
  59. package/build/lib-client/files/file-sink.js +0 -173
  60. package/build/lib-client/files/file-source.d.ts +0 -19
  61. package/build/lib-client/files/file-source.js +0 -115
@@ -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;
@@ -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
@@ -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
  }))
@@ -0,0 +1,28 @@
1
+ /// <reference types="node" />
2
+ import { Attrs } from "./node-persistence";
3
+ export declare class CommonAttrs {
4
+ ctime: number;
5
+ mtime: number;
6
+ constructor(ctime: number, mtime: number);
7
+ static makeForTimeNow(): CommonAttrs;
8
+ static fromAttrs(attrs: Attrs): CommonAttrs;
9
+ static readonly PACK_LEN: number;
10
+ static parse(bytes: Uint8Array): CommonAttrs;
11
+ pack(): Buffer;
12
+ copy(): CommonAttrs;
13
+ updateMTime(): void;
14
+ }
15
+ export declare class XAttrs {
16
+ private readonly attrs;
17
+ private constructor();
18
+ static makeEmpty(): XAttrs;
19
+ static parseFrom(sections: Uint8Array[]): XAttrs;
20
+ copy(): XAttrs;
21
+ makeUpdated(changes: XAttrsChanges): XAttrs;
22
+ get(xaName: string): any;
23
+ list(): string[];
24
+ get isEmpty(): boolean;
25
+ pack(): Uint8Array[] | undefined;
26
+ }
27
+ declare type XAttrsChanges = web3n.files.XAttrsChanges;
28
+ export {};