core-3nweb-client-lib 0.27.1 → 0.27.3

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 (56) hide show
  1. package/build/api-defs/files.d.ts +4 -7
  2. package/build/core/asmail/inbox/attachments/fs.d.ts +2 -1
  3. package/build/core/asmail/inbox/attachments/fs.js +4 -3
  4. package/build/core/asmail/inbox/index.js +1 -1
  5. package/build/core/id-manager/index.d.ts +43 -0
  6. package/build/core/{id-manager.js → id-manager/index.js} +33 -114
  7. package/build/core/id-manager/key-storage.d.ts +21 -0
  8. package/build/core/id-manager/key-storage.js +96 -0
  9. package/build/core/index.js +21 -23
  10. package/build/core/sign-in.d.ts +1 -2
  11. package/build/core/sign-in.js +4 -13
  12. package/build/core/sign-up.d.ts +2 -0
  13. package/build/core/sign-up.js +2 -1
  14. package/build/core/storage/index.d.ts +4 -2
  15. package/build/core/storage/index.js +36 -57
  16. package/build/core/storage/local/storage.d.ts +1 -1
  17. package/build/core/storage/synced/obj-files-gc.d.ts +1 -4
  18. package/build/core/storage/synced/obj-files-gc.js +1 -18
  19. package/build/core/storage/synced/obj-files.d.ts +9 -1
  20. package/build/core/storage/synced/obj-files.js +41 -33
  21. package/build/core/storage/synced/obj-status.d.ts +18 -7
  22. package/build/core/storage/synced/obj-status.js +148 -83
  23. package/build/core/storage/synced/storage.d.ts +7 -2
  24. package/build/core/storage/synced/storage.js +50 -10
  25. package/build/core/storage/synced/upsyncer.d.ts +4 -4
  26. package/build/core/storage/synced/upsyncer.js +12 -6
  27. package/build/lib-client/3nstorage/exceptions.d.ts +13 -1
  28. package/build/lib-client/3nstorage/exceptions.js +9 -3
  29. package/build/lib-client/3nstorage/service.d.ts +6 -1
  30. package/build/lib-client/3nstorage/service.js +31 -15
  31. package/build/lib-client/3nstorage/util/file-based-json.js +2 -1
  32. package/build/lib-client/3nstorage/util/for-arrays.d.ts +1 -0
  33. package/build/lib-client/3nstorage/util/for-arrays.js +32 -0
  34. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +5 -4
  35. package/build/lib-client/3nstorage/xsp-fs/common.js +1 -0
  36. package/build/lib-client/3nstorage/xsp-fs/file.js +2 -2
  37. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +11 -5
  38. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +232 -68
  39. package/build/lib-client/3nstorage/xsp-fs/fs.js +15 -19
  40. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +4 -9
  41. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +16 -17
  42. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +1 -1
  43. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  44. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  45. package/build/lib-client/local-files/device-fs.js +11 -11
  46. package/build/lib-client/user-with-mid-session.d.ts +2 -1
  47. package/build/lib-client/user-with-mid-session.js +7 -1
  48. package/build/lib-common/async-fs-node.js +8 -8
  49. package/build/lib-common/exceptions/file.d.ts +4 -2
  50. package/build/lib-common/exceptions/file.js +24 -58
  51. package/build/lib-common/ipc/generic-ipc.js +5 -4
  52. package/build/lib-common/objs-on-disk/utils.js +1 -1
  53. package/build/lib-common/service-api/3nstorage/owner.d.ts +8 -5
  54. package/build/lib-common/service-api/3nstorage/owner.js +2 -1
  55. package/package.json +3 -2
  56. package/build/core/id-manager.d.ts +0 -46
@@ -29,6 +29,7 @@ const exceptions_1 = require("../exceptions");
29
29
  const rxjs_1 = require("rxjs");
30
30
  const operators_1 = require("rxjs/operators");
31
31
  const attrs_1 = require("./attrs");
32
+ const assert_1 = require("../../../lib-common/assert");
32
33
  class NodeInFS {
33
34
  constructor(storage, type, name, objId, currentVersion, parentId) {
34
35
  this.storage = storage;
@@ -124,7 +125,7 @@ class NodeInFS {
124
125
  else {
125
126
  if (version) {
126
127
  if (this.currentVersion !== version) {
127
- throw (0, file_1.makeFileException)(file_1.Code.versionMismatch, this.name);
128
+ throw (0, file_1.makeFileException)('versionMismatch', this.name);
128
129
  }
129
130
  }
130
131
  else {
@@ -135,15 +136,11 @@ class NodeInFS {
135
136
  return version;
136
137
  }
137
138
  }
138
- removeObj(src = 'local') {
139
- return this.doChange(true, () => this.delete(src));
139
+ removeNonFolderObj(src) {
140
+ (0, assert_1.assert)(this.type !== 'folder');
141
+ return this.doChange(true, () => this.removeThisNodeAsLeaf(src));
140
142
  }
141
- /**
142
- * This non-synchronized method deletes object from storage, and detaches
143
- * this node from storage. Make sure to call it inside access synchronization
144
- * construct.
145
- */
146
- async delete(src) {
143
+ async removeThisNodeAsLeaf(src) {
147
144
  await this.storage.removeObj(this.objId);
148
145
  this.storage.nodes.delete(this);
149
146
  this.currentVersion = -1;
@@ -171,11 +168,11 @@ class NodeInFS {
171
168
  this.writeProc = new synced_1.SingleProc();
172
169
  }
173
170
  if (!awaitPrevChange && this.writeProc.isProcessing()) {
174
- throw (0, file_1.makeFileException)(file_1.Code.concurrentUpdate, this.name + ` type ${this.type}`);
171
+ throw (0, file_1.makeFileException)('concurrentUpdate', this.name + ` type ${this.type}`);
175
172
  }
176
173
  const res = await this.writeProc.startOrChain(async () => {
177
174
  if (this.currentVersion < 0) {
178
- throw (0, file_1.makeFileException)(file_1.Code.notFound, this.name, `Object is marked removed`);
175
+ throw (0, file_1.makeFileException)('notFound', this.name, `Object is marked removed`);
179
176
  }
180
177
  try {
181
178
  const res = await change();
@@ -187,17 +184,17 @@ class NodeInFS {
187
184
  }
188
185
  if (exc.type === 'storage') {
189
186
  if (exc.concurrentTransaction) {
190
- throw (0, file_1.makeFileException)(file_1.Code.concurrentUpdate, this.name, exc);
187
+ throw (0, file_1.makeFileException)('concurrentUpdate', this.name, exc);
191
188
  }
192
189
  else if (exc.objNotFound) {
193
- throw (0, file_1.makeFileException)(file_1.Code.notFound, this.name, exc);
190
+ throw (0, file_1.makeFileException)('notFound', this.name, exc);
194
191
  }
195
192
  }
196
193
  else if ((exc.type === 'file')
197
194
  || (exc.type === 'fs-sync')) {
198
195
  throw exc;
199
196
  }
200
- throw (0, file_1.makeFileException)(file_1.Code.ioError, this.name, exc);
197
+ throw (0, file_1.makeFileException)('ioError', this.name, exc);
201
198
  }
202
199
  });
203
200
  return res;
@@ -258,7 +255,7 @@ class NodeInFS {
258
255
  async updateStatusInfo() {
259
256
  const storage = this.syncedStorage();
260
257
  const status = await storage.updateStatusInfo(this.objId);
261
- return await this.syncStatus();
258
+ return status;
262
259
  }
263
260
  isSyncedVersionOnDisk(version) {
264
261
  const storage = this.syncedStorage();
@@ -350,8 +347,7 @@ class NodeInFS {
350
347
  return;
351
348
  }
352
349
  const { localVersion, createOnRemote, uploadVersion } = toUpload;
353
- const uploadHeader = ((localVersion === uploadVersion) ? undefined :
354
- await this.uploadHeaderChange(localVersion, uploadVersion));
350
+ const uploadHeader = await this.uploadHeaderChange(localVersion, uploadVersion);
355
351
  const storage = this.syncedStorage();
356
352
  await storage.upload(this.objId, localVersion, uploadVersion, uploadHeader, createOnRemote);
357
353
  await this.doChange(true, async () => {
@@ -366,6 +362,9 @@ class NodeInFS {
366
362
  }
367
363
  }
368
364
  async uploadHeaderChange(localVersion, uploadVersion) {
365
+ if (localVersion === uploadVersion) {
366
+ return;
367
+ }
369
368
  const currentSrc = await this.storage.getObjSrc(this.objId, localVersion);
370
369
  const localHeader = await currentSrc.readHeader();
371
370
  const uploadHeader = await this.crypto.reencryptHeader(localHeader, uploadVersion);
@@ -82,6 +82,6 @@ class ReadonlyPayloadV1 {
82
82
  Object.freeze(ReadonlyPayloadV1.prototype);
83
83
  Object.freeze(ReadonlyPayloadV1);
84
84
  function makeEndlessException() {
85
- return (0, file_1.makeFileException)(file_1.Code.isEndless, '');
85
+ return (0, file_1.makeFileException)('isEndless', '');
86
86
  }
87
87
  Object.freeze(exports);