core-3nweb-client-lib 0.27.0 → 0.27.4

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 (81) hide show
  1. package/build/api-defs/files.d.ts +56 -26
  2. package/build/core/asmail/config/index.d.ts +2 -2
  3. package/build/core/asmail/config/index.js +2 -2
  4. package/build/core/asmail/config/invitations-anon.d.ts +10 -24
  5. package/build/core/asmail/config/invitations-anon.js +43 -31
  6. package/build/core/asmail/config/published-intro-key.d.ts +11 -22
  7. package/build/core/asmail/config/published-intro-key.js +47 -38
  8. package/build/core/asmail/inbox/attachments/fs.d.ts +2 -1
  9. package/build/core/asmail/inbox/attachments/fs.js +4 -3
  10. package/build/core/asmail/inbox/index.js +2 -2
  11. package/build/core/asmail/index.d.ts +1 -1
  12. package/build/core/asmail/index.js +2 -2
  13. package/build/core/asmail/keyring/correspondent-keys.d.ts +2 -2
  14. package/build/core/asmail/keyring/correspondent-keys.js +1 -1
  15. package/build/core/asmail/keyring/index.d.ts +9 -29
  16. package/build/core/asmail/keyring/index.js +82 -69
  17. package/build/core/id-manager/index.d.ts +43 -0
  18. package/build/core/{id-manager.js → id-manager/index.js} +33 -114
  19. package/build/core/id-manager/key-storage.d.ts +21 -0
  20. package/build/core/id-manager/key-storage.js +96 -0
  21. package/build/core/index.js +22 -25
  22. package/build/core/sign-in.d.ts +1 -2
  23. package/build/core/sign-in.js +5 -14
  24. package/build/core/sign-up.d.ts +2 -0
  25. package/build/core/sign-up.js +2 -1
  26. package/build/core/storage/index.d.ts +4 -2
  27. package/build/core/storage/index.js +36 -57
  28. package/build/core/storage/local/storage.d.ts +1 -1
  29. package/build/core/storage/synced/obj-files-gc.d.ts +1 -4
  30. package/build/core/storage/synced/obj-files-gc.js +1 -18
  31. package/build/core/storage/synced/obj-files.d.ts +11 -1
  32. package/build/core/storage/synced/obj-files.js +59 -34
  33. package/build/core/storage/synced/obj-status.d.ts +19 -7
  34. package/build/core/storage/synced/obj-status.js +158 -83
  35. package/build/core/storage/synced/storage.d.ts +7 -2
  36. package/build/core/storage/synced/storage.js +38 -15
  37. package/build/core/storage/synced/upsyncer.d.ts +4 -4
  38. package/build/core/storage/synced/upsyncer.js +14 -9
  39. package/build/ipc-via-protobuf/file.d.ts +7 -0
  40. package/build/ipc-via-protobuf/file.js +60 -27
  41. package/build/ipc-via-protobuf/fs.js +55 -38
  42. package/build/lib-client/3nstorage/exceptions.d.ts +13 -1
  43. package/build/lib-client/3nstorage/exceptions.js +9 -3
  44. package/build/lib-client/3nstorage/service.d.ts +6 -2
  45. package/build/lib-client/3nstorage/service.js +33 -17
  46. package/build/lib-client/3nstorage/util/file-based-json.js +2 -1
  47. package/build/lib-client/3nstorage/util/for-arrays.d.ts +1 -0
  48. package/build/lib-client/3nstorage/util/for-arrays.js +32 -0
  49. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +5 -4
  50. package/build/lib-client/3nstorage/xsp-fs/common.js +1 -0
  51. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +5 -10
  52. package/build/lib-client/3nstorage/xsp-fs/file-node.js +43 -45
  53. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +7 -6
  54. package/build/lib-client/3nstorage/xsp-fs/file.js +14 -20
  55. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +16 -5
  56. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +238 -68
  57. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +18 -17
  58. package/build/lib-client/3nstorage/xsp-fs/fs.js +32 -37
  59. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +15 -11
  60. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +72 -22
  61. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +1 -1
  62. package/build/lib-client/local-files/device-fs.js +11 -11
  63. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +5 -2
  64. package/build/lib-client/objs-on-disk/obj-on-disk.js +16 -1
  65. package/build/lib-client/user-with-mid-session.d.ts +2 -1
  66. package/build/lib-client/user-with-mid-session.js +7 -1
  67. package/build/lib-common/async-fs-node.js +8 -8
  68. package/build/lib-common/exceptions/file.d.ts +4 -2
  69. package/build/lib-common/exceptions/file.js +24 -58
  70. package/build/lib-common/ipc/generic-ipc.js +5 -4
  71. package/build/lib-common/objs-on-disk/file-layout.js +1 -1
  72. package/build/lib-common/objs-on-disk/utils.js +1 -1
  73. package/build/lib-common/service-api/3nstorage/owner.d.ts +8 -9
  74. package/build/lib-common/service-api/3nstorage/owner.js +2 -1
  75. package/build/protos/asmail.proto.js +5943 -4348
  76. package/build/protos/file.proto.js +874 -0
  77. package/build/protos/fs.proto.js +7014 -5419
  78. package/package.json +3 -2
  79. package/protos/file.proto +23 -7
  80. package/protos/fs.proto +27 -13
  81. package/build/core/id-manager.d.ts +0 -46
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015 - 2019, 2021 3NSoft Inc.
3
+ Copyright (C) 2015 - 2019, 2021 - 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
@@ -28,7 +28,7 @@ const path_1 = require("path");
28
28
  var fs_2 = require("fs");
29
29
  Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return fs_2.Stats; } });
30
30
  function makeFileExceptionFromNodes(nodeExc) {
31
- return (0, file_1.makeFileException)(nodeExc.code, nodeExc.path);
31
+ return (0, file_1.makeFileExceptionFromCode)(nodeExc.code, nodeExc.path);
32
32
  }
33
33
  function readFile(path, options) {
34
34
  return new Promise((resolve, reject) => {
@@ -307,7 +307,7 @@ async function readToBuf(fd, pos, buf) {
307
307
  while (bytesRead < buf.length) {
308
308
  const bNum = await readOrig(fd, buf, bytesRead, buf.length - bytesRead, pos);
309
309
  if (bNum === 0) {
310
- throw (0, file_1.makeFileException)(file_1.Code.endOfFile, '<file descriptor>');
310
+ throw (0, file_1.makeFileException)('endOfFile', '<file descriptor>');
311
311
  }
312
312
  bytesRead += bNum;
313
313
  pos += bNum;
@@ -379,7 +379,7 @@ async function existsFolder(path) {
379
379
  return true;
380
380
  }
381
381
  else {
382
- throw (0, file_1.makeFileException)(file_1.Code.notDirectory, path);
382
+ throw (0, file_1.makeFileException)('notDirectory', path);
383
383
  }
384
384
  }
385
385
  catch (e) {
@@ -400,7 +400,7 @@ function existsFolderSync(path) {
400
400
  return true;
401
401
  }
402
402
  else {
403
- throw (0, file_1.makeFileException)(file_1.Code.notDirectory, path);
403
+ throw (0, file_1.makeFileException)('notDirectory', path);
404
404
  }
405
405
  }
406
406
  catch (e) {
@@ -421,7 +421,7 @@ function existsFileSync(path) {
421
421
  return true;
422
422
  }
423
423
  else {
424
- throw (0, file_1.makeFileException)(file_1.Code.notFile, path);
424
+ throw (0, file_1.makeFileException)('notFile', path);
425
425
  }
426
426
  }
427
427
  catch (e) {
@@ -586,7 +586,7 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
586
586
  if (doneReading) {
587
587
  return;
588
588
  }
589
- complete((0, file_1.makeFileException)(file_1.Code.endOfFile, '<input stream>'));
589
+ complete((0, file_1.makeFileException)('endOfFile', '<input stream>'));
590
590
  });
591
591
  src.on('error', (err) => {
592
592
  complete(err);
@@ -614,7 +614,7 @@ async function read(fd, pos, buf) {
614
614
  while (bytesRead < buf.length) {
615
615
  const bNum = await readOrig(fd, buf, bytesRead, buf.length - bytesRead, pos);
616
616
  if (bNum === 0) {
617
- throw (0, file_1.makeFileException)(file_1.Code.endOfFile, '<file descriptor>');
617
+ throw (0, file_1.makeFileException)('endOfFile', '<file descriptor>');
618
618
  }
619
619
  bytesRead += bNum;
620
620
  pos += bNum;
@@ -1,6 +1,8 @@
1
- export declare const Code: web3n.files.exceptionCode;
2
1
  export declare type FileException = web3n.files.FileException;
3
- export declare function makeFileException(code: string | undefined, path: string, cause?: any): FileException;
2
+ export declare type FileExceptionFlag = web3n.files.FileExceptionFlag;
3
+ export declare const Code: web3n.files.exceptionCode;
4
+ export declare function makeFileExceptionFromCode(code: string | undefined, path: string, cause?: any): FileException;
5
+ export declare function makeFileException(flag: keyof FileExceptionFlag, path: string, cause?: any): FileException;
4
6
  export declare function maskPathInExc(pathPrefixMaskLen: number, exc: any): FileException;
5
7
  export declare function ensureCorrectFS(fs: web3n.files.FS, type: web3n.files.FSType, writable: boolean): void;
6
8
  export declare function makeNoAttrsExc(path: string): FileException;
@@ -16,28 +16,26 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.makeVersionMismatchExc = exports.makeNoAttrsExc = exports.ensureCorrectFS = exports.maskPathInExc = exports.makeFileException = exports.Code = void 0;
19
+ exports.makeVersionMismatchExc = exports.makeNoAttrsExc = exports.ensureCorrectFS = exports.maskPathInExc = exports.makeFileException = exports.makeFileExceptionFromCode = exports.Code = void 0;
20
20
  exports.Code = {
21
21
  notFound: 'ENOENT',
22
22
  alreadyExists: 'EEXIST',
23
23
  notDirectory: 'ENOTDIR',
24
24
  notFile: 'ENOTFILE',
25
- notLink: 'not-link',
26
25
  isDirectory: 'EISDIR',
27
26
  notEmpty: 'ENOTEMPTY',
28
27
  endOfFile: 'EEOF',
29
28
  opNotPermitted: 'EPERM',
30
29
  busy: 'EBUSY',
31
30
  ioError: 'EIO',
32
- concurrentUpdate: 'concurrent-update',
33
- parsingError: 'parsing-error',
34
31
  notImplemented: 'ENOSYS',
35
- isEndless: 'is-endless',
36
- storageClosed: 'storage-closed',
37
- versionMismatch: 'version-mismatch',
38
32
  };
39
33
  Object.freeze(exports.Code);
40
- function makeFileException(code, path, cause) {
34
+ const codeToFlag = {};
35
+ for (const [flag, code] of Object.entries(exports.Code)) {
36
+ codeToFlag[code] = flag;
37
+ }
38
+ function makeFileExceptionFromCode(code, path, cause) {
41
39
  const err = {
42
40
  runtimeException: true,
43
41
  type: 'file',
@@ -45,59 +43,27 @@ function makeFileException(code, path, cause) {
45
43
  path,
46
44
  cause
47
45
  };
48
- if (code === exports.Code.alreadyExists) {
49
- err.alreadyExists = true;
50
- }
51
- else if (code === exports.Code.notFound) {
52
- err.notFound = true;
53
- }
54
- else if (code === exports.Code.isDirectory) {
55
- err.isDirectory = true;
56
- }
57
- else if (code === exports.Code.notDirectory) {
58
- err.notDirectory = true;
59
- }
60
- else if (code === exports.Code.notFile) {
61
- err.notFile = true;
62
- }
63
- else if (code === exports.Code.notLink) {
64
- err.notLink = true;
65
- }
66
- else if (code === exports.Code.endOfFile) {
67
- err.endOfFile = true;
68
- }
69
- else if (code === exports.Code.busy) {
70
- err.busy = true;
71
- }
72
- else if (code === exports.Code.ioError) {
73
- err.ioError = true;
74
- }
75
- else if (code === exports.Code.notEmpty) {
76
- err.notEmpty = true;
77
- }
78
- else if (code === exports.Code.opNotPermitted) {
79
- err.opNotPermitted = true;
80
- }
81
- else if (code === exports.Code.concurrentUpdate) {
82
- err.concurrentUpdate = true;
83
- }
84
- else if (code === exports.Code.parsingError) {
85
- err.parsingError = true;
86
- }
87
- else if (code === exports.Code.notImplemented) {
88
- err.notImplemented = true;
89
- }
90
- else if (code === exports.Code.isEndless) {
91
- err.isEndless = true;
92
- }
93
- else if (code === exports.Code.storageClosed) {
94
- err.storageClosed = true;
95
- }
96
- else if (code === exports.Code.versionMismatch) {
97
- err.versionMismatch = true;
46
+ if (code) {
47
+ const flag = codeToFlag[code];
48
+ if (flag) {
49
+ err[flag] = true;
50
+ }
98
51
  }
99
52
  return err;
100
53
  }
54
+ exports.makeFileExceptionFromCode = makeFileExceptionFromCode;
55
+ function makeFileException(flag, path, cause) {
56
+ const code = exports.Code[flag];
57
+ const err = {
58
+ runtimeException: true,
59
+ type: 'file',
60
+ code,
61
+ path,
62
+ cause
63
+ };
64
+ err[flag] = true;
65
+ return err;
66
+ }
101
67
  exports.makeFileException = makeFileException;
102
68
  function maskPathInExc(pathPrefixMaskLen, exc) {
103
69
  if (!exc.runtimeException || !exc.code) {
@@ -278,11 +278,12 @@ function makeRequestServer(channel, comm) {
278
278
  return (new ReplyingSide(channel, comm)).wrap();
279
279
  }
280
280
  exports.makeRequestServer = makeRequestServer;
281
- function makeUnknownEventException() {
281
+ function makeUnknownEventException(message) {
282
282
  return {
283
283
  runtimeException: true,
284
284
  type: 'events',
285
- unknownEvent: true
285
+ unknownEvent: true,
286
+ message
286
287
  };
287
288
  }
288
289
  const SUBSCRIBE_REQ_NAME = 'subscribe';
@@ -307,7 +308,7 @@ class EventsSendingSide extends ReplyingSide {
307
308
  const event = env.req;
308
309
  const gr = this.findGroup(event);
309
310
  if (!gr) {
310
- throw makeUnknownEventException();
311
+ throw makeUnknownEventException(`Events' channel ${event} is not found in handling subscribe`);
311
312
  }
312
313
  this.subscribedEvents.add(event);
313
314
  await gr.subscribe(event);
@@ -316,7 +317,7 @@ class EventsSendingSide extends ReplyingSide {
316
317
  const event = env.req;
317
318
  const gr = this.findGroup(event);
318
319
  if (!gr) {
319
- throw makeUnknownEventException();
320
+ throw makeUnknownEventException(`Events' channel ${event} is not found in handling unsubscribe`);
320
321
  }
321
322
  this.subscribedEvents.delete(event);
322
323
  if (gr.unsubscribe) {
@@ -83,7 +83,7 @@ class ObjVersionBytesLayout {
83
83
  isFileComplete() {
84
84
  for (const chunk of this.segsChunks) {
85
85
  if ((chunk.type === 'new') || (chunk.type === 'new-endless')) {
86
- return true;
86
+ return false;
87
87
  }
88
88
  }
89
89
  return true;
@@ -111,7 +111,7 @@ async function streamToObjFile(file, content, src, maxBufferLen) {
111
111
  });
112
112
  src.on('end', () => {
113
113
  if (chunk) {
114
- complete((0, file_1.makeFileException)(file_1.Code.endOfFile, '<input stream>'));
114
+ complete((0, file_1.makeFileException)('endOfFile', '<input stream>'));
115
115
  }
116
116
  else {
117
117
  complete();
@@ -66,10 +66,6 @@ export interface GetObjQueryOpts {
66
66
  ver?: number;
67
67
  }
68
68
  export interface PutObjFirstQueryOpts {
69
- /**
70
- * This is a flag to indicate that new object should be created.
71
- */
72
- create?: boolean;
73
69
  /**
74
70
  * This parameter is object's new version.
75
71
  */
@@ -132,9 +128,10 @@ export declare namespace currentObj {
132
128
  mismatchedObjVer: number;
133
129
  objIncomplete: number;
134
130
  };
135
- interface MismatchedObjVerReply extends ErrorReply {
136
- current_version: number;
137
- }
131
+ type MismatchedObjVerReply = MismatchedObjVerErrReply;
132
+ }
133
+ export interface MismatchedObjVerErrReply extends ErrorReply {
134
+ current_version: number;
138
135
  }
139
136
  export declare namespace currentRootObj {
140
137
  const EXPRESS_URL_END = "root/current";
@@ -240,23 +237,25 @@ export declare namespace rootStatus {
240
237
  export declare namespace archiveObj {
241
238
  const EXPRESS_URL_END = "obj/:objId/archive";
242
239
  function postAndDelReqUrlEnd(objId: string, version: number): string;
243
- type VersionsList = number[];
240
+ type MismatchedObjVerReply = MismatchedObjVerErrReply;
244
241
  const SC: {
245
242
  okPost: number;
246
243
  okDelete: number;
247
244
  unknownObj: number;
248
245
  unknownObjVer: number;
246
+ mismatchedObjVer: number;
249
247
  };
250
248
  }
251
249
  export declare namespace archiveRoot {
252
250
  const EXPRESS_URL_END = "root/archive";
253
251
  function postAndDelReqUrlEnd(version: number): string;
254
- type VersionsList = archiveObj.VersionsList;
252
+ type MismatchedObjVerReply = archiveObj.MismatchedObjVerReply;
255
253
  const SC: {
256
254
  okPost: number;
257
255
  okDelete: number;
258
256
  unknownObj: number;
259
257
  unknownObjVer: number;
258
+ mismatchedObjVer: number;
260
259
  };
261
260
  }
262
261
  export interface ErrorReply {
@@ -258,7 +258,8 @@ var archiveObj;
258
258
  okPost: 200,
259
259
  okDelete: 200,
260
260
  unknownObj: 474,
261
- unknownObjVer: 494
261
+ unknownObjVer: 494,
262
+ mismatchedObjVer: 495
262
263
  };
263
264
  })(archiveObj = exports.archiveObj || (exports.archiveObj = {}));
264
265
  Object.freeze(archiveObj);