core-3nweb-client-lib 0.25.6 → 0.27.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 (215) hide show
  1. package/README.md +2 -2
  2. package/build/api-defs/asmail.d.ts +1 -1
  3. package/build/api-defs/files.d.ts +282 -70
  4. package/build/core/app-files.js +7 -7
  5. package/build/core/asmail/config/common.js +4 -4
  6. package/build/core/asmail/config/index.js +2 -2
  7. package/build/core/asmail/config/published-intro-key.js +1 -1
  8. package/build/core/asmail/delivery/common.js +7 -7
  9. package/build/core/asmail/delivery/index.js +7 -6
  10. package/build/core/asmail/delivery/msg.js +8 -7
  11. package/build/core/asmail/delivery/per-recipient-wip.js +3 -3
  12. package/build/core/asmail/inbox/attachments/fs.js +11 -1
  13. package/build/core/asmail/inbox/cached-msgs.js +3 -3
  14. package/build/core/asmail/inbox/inbox-events.js +5 -4
  15. package/build/core/asmail/inbox/index.js +12 -12
  16. package/build/core/asmail/inbox/msg-downloader.js +3 -3
  17. package/build/core/asmail/inbox/msg-indexing.js +4 -4
  18. package/build/core/asmail/inbox/msg-on-disk.js +7 -7
  19. package/build/core/asmail/index.d.ts +3 -3
  20. package/build/core/asmail/index.js +13 -8
  21. package/build/core/asmail/key-verification.js +5 -5
  22. package/build/core/asmail/keyring/common.js +7 -6
  23. package/build/core/asmail/keyring/correspondent-keys.js +8 -7
  24. package/build/core/asmail/keyring/id-to-email-map.js +2 -1
  25. package/build/core/asmail/keyring/index.d.ts +7 -8
  26. package/build/core/asmail/keyring/index.js +15 -14
  27. package/build/core/asmail/keyring/keyring-storage.js +4 -3
  28. package/build/core/asmail/msg/opener.js +3 -3
  29. package/build/core/asmail/msg/packer.js +13 -13
  30. package/build/core/asmail/sending-params/own-params.js +4 -4
  31. package/build/core/asmail/sending-params/params-from-others.js +3 -3
  32. package/build/core/id-manager.js +8 -5
  33. package/build/core/index.d.ts +2 -1
  34. package/build/core/index.js +14 -14
  35. package/build/core/sign-in.d.ts +5 -4
  36. package/build/core/sign-in.js +12 -14
  37. package/build/core/sign-up.d.ts +1 -0
  38. package/build/core/sign-up.js +15 -11
  39. package/build/core/storage/common/json-saving.d.ts +21 -0
  40. package/build/core/storage/common/json-saving.js +82 -0
  41. package/build/core/storage/common/obj-info-file.d.ts +51 -0
  42. package/build/core/storage/common/obj-info-file.js +153 -5
  43. package/build/core/storage/common/utils.d.ts +2 -0
  44. package/build/core/storage/common/utils.js +32 -0
  45. package/build/core/storage/index.d.ts +3 -17
  46. package/build/core/storage/index.js +57 -77
  47. package/build/core/storage/local/obj-files-gc.d.ts +2 -0
  48. package/build/core/storage/local/obj-files-gc.js +53 -39
  49. package/build/core/storage/local/obj-files.d.ts +6 -9
  50. package/build/core/storage/local/obj-files.js +16 -19
  51. package/build/core/storage/local/obj-status.d.ts +20 -30
  52. package/build/core/storage/local/obj-status.js +46 -113
  53. package/build/core/storage/local/storage.d.ts +15 -5
  54. package/build/core/storage/local/storage.js +37 -18
  55. package/build/core/storage/synced/downloader.js +7 -6
  56. package/build/core/storage/synced/obj-files-gc.d.ts +6 -1
  57. package/build/core/storage/synced/obj-files-gc.js +106 -13
  58. package/build/core/storage/synced/obj-files.d.ts +46 -47
  59. package/build/core/storage/synced/obj-files.js +207 -154
  60. package/build/core/storage/synced/obj-status.d.ts +103 -42
  61. package/build/core/storage/synced/obj-status.js +525 -137
  62. package/build/core/storage/synced/remote-events.d.ts +11 -12
  63. package/build/core/storage/synced/remote-events.js +80 -57
  64. package/build/core/storage/synced/storage.d.ts +24 -5
  65. package/build/core/storage/synced/storage.js +123 -38
  66. package/build/core/storage/synced/upload-header-file.d.ts +4 -0
  67. package/build/core/storage/synced/upload-header-file.js +64 -0
  68. package/build/core/storage/synced/upsyncer.d.ts +15 -9
  69. package/build/core/storage/synced/upsyncer.js +219 -246
  70. package/build/core/storage/system-folders/apps-data.d.ts +16 -0
  71. package/build/core/storage/system-folders/apps-data.js +110 -0
  72. package/build/core/storage/system-folders/index.d.ts +18 -0
  73. package/build/core/storage/system-folders/index.js +77 -0
  74. package/build/core-ipc/common-caps.js +3 -3
  75. package/build/core-ipc/generic.js +8 -8
  76. package/build/core-ipc/startup-caps.js +2 -2
  77. package/build/cryptors.js +6 -2
  78. package/build/ipc-via-protobuf/asmail-cap.js +67 -83
  79. package/build/ipc-via-protobuf/bytes.js +16 -17
  80. package/build/ipc-via-protobuf/connector-clients-side.d.ts +3 -0
  81. package/build/ipc-via-protobuf/connector-clients-side.js +62 -25
  82. package/build/ipc-via-protobuf/connector-services-side.js +10 -10
  83. package/build/ipc-via-protobuf/connector.js +4 -4
  84. package/build/ipc-via-protobuf/file.d.ts +48 -12
  85. package/build/ipc-via-protobuf/file.js +476 -120
  86. package/build/ipc-via-protobuf/fs.d.ts +8 -0
  87. package/build/ipc-via-protobuf/fs.js +592 -159
  88. package/build/ipc-via-protobuf/log-cap.js +2 -2
  89. package/build/ipc-via-protobuf/mailerid.js +3 -3
  90. package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -0
  91. package/build/ipc-via-protobuf/protobuf-msg.js +11 -7
  92. package/build/ipc-via-protobuf/startup-cap.js +23 -23
  93. package/build/ipc-via-protobuf/storage-cap.js +12 -12
  94. package/build/ipc.js +7 -2
  95. package/build/lib-client/3nstorage/exceptions.d.ts +12 -8
  96. package/build/lib-client/3nstorage/exceptions.js +31 -10
  97. package/build/lib-client/3nstorage/service.d.ts +16 -2
  98. package/build/lib-client/3nstorage/service.js +109 -39
  99. package/build/lib-client/3nstorage/util/file-based-json.d.ts +2 -1
  100. package/build/lib-client/3nstorage/util/file-based-json.js +1 -1
  101. package/build/lib-client/3nstorage/xsp-fs/attrs.js +17 -17
  102. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +52 -14
  103. package/build/lib-client/3nstorage/xsp-fs/common.js +31 -16
  104. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -0
  105. package/build/lib-client/3nstorage/xsp-fs/file-node.js +18 -14
  106. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +31 -6
  107. package/build/lib-client/3nstorage/xsp-fs/file.js +74 -23
  108. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +4 -4
  109. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +24 -11
  110. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +599 -189
  111. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +45 -9
  112. package/build/lib-client/3nstorage/xsp-fs/fs.js +326 -74
  113. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +1 -0
  114. package/build/lib-client/3nstorage/xsp-fs/link-node.js +7 -2
  115. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +30 -20
  116. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +239 -106
  117. package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -1
  118. package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +18 -19
  119. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +5 -5
  120. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +56 -56
  121. package/build/lib-client/3nweb-signup.js +4 -4
  122. package/build/lib-client/asmail/recipient.js +15 -15
  123. package/build/lib-client/asmail/sender.js +22 -22
  124. package/build/lib-client/asmail/service-config.js +3 -3
  125. package/build/lib-client/cryptor/cryptor-in-worker.js +19 -17
  126. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  127. package/build/lib-client/cryptor/cryptor.js +4 -2
  128. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  129. package/build/lib-client/cryptor/in-proc-js.js +1 -1
  130. package/build/lib-client/cryptor/in-proc-wasm.js +7 -7
  131. package/build/lib-client/cryptor/worker-js.js +2 -2
  132. package/build/lib-client/cryptor/worker-wasm.js +2 -2
  133. package/build/lib-client/files-select.js +1 -1
  134. package/build/lib-client/files.d.ts +1 -1
  135. package/build/lib-client/files.js +71 -4
  136. package/build/lib-client/fs-collection.js +3 -2
  137. package/build/lib-client/fs-sync-utils.d.ts +5 -0
  138. package/build/lib-client/fs-sync-utils.js +61 -0
  139. package/build/lib-client/fs-view.d.ts +14 -0
  140. package/build/lib-client/fs-view.js +33 -0
  141. package/build/lib-client/key-derivation.js +1 -1
  142. package/build/lib-client/local-files/dev-file-sink.js +9 -9
  143. package/build/lib-client/local-files/dev-file-src.js +2 -2
  144. package/build/lib-client/local-files/device-fs.d.ts +1 -1
  145. package/build/lib-client/local-files/device-fs.js +56 -54
  146. package/build/lib-client/logging/log-to-file.d.ts +1 -1
  147. package/build/lib-client/logging/log-to-file.js +11 -11
  148. package/build/lib-client/mailer-id/login.js +7 -7
  149. package/build/lib-client/mailer-id/provisioner.js +12 -12
  150. package/build/lib-client/objs-on-disk/file-writing-proc.js +5 -5
  151. package/build/lib-client/objs-on-disk/obj-folders.js +33 -33
  152. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +13 -2
  153. package/build/lib-client/objs-on-disk/obj-on-disk.js +24 -9
  154. package/build/lib-client/request-utils.d.ts +1 -0
  155. package/build/lib-client/request-utils.js +14 -14
  156. package/build/lib-client/server-events.d.ts +3 -3
  157. package/build/lib-client/server-events.js +12 -10
  158. package/build/lib-client/service-locator.js +10 -10
  159. package/build/lib-client/user-with-mid-session.js +7 -7
  160. package/build/lib-client/user-with-pkl-session.js +25 -25
  161. package/build/lib-client/ws-utils.js +3 -3
  162. package/build/lib-common/async-cryptor-wrap.js +4 -4
  163. package/build/lib-common/async-fs-node.d.ts +5 -3
  164. package/build/lib-common/async-fs-node.js +19 -18
  165. package/build/lib-common/byte-streaming/pipe.js +1 -1
  166. package/build/lib-common/byte-streaming/wrapping.js +17 -17
  167. package/build/lib-common/canonical-address.js +1 -1
  168. package/build/lib-common/exceptions/error.d.ts +1 -0
  169. package/build/lib-common/exceptions/error.js +7 -6
  170. package/build/lib-common/exceptions/file.js +10 -1
  171. package/build/lib-common/ipc/generic-ipc.js +2 -2
  172. package/build/lib-common/ipc/ws-ipc.js +2 -2
  173. package/build/lib-common/json-utils.js +2 -1
  174. package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
  175. package/build/lib-common/objs-on-disk/file-layout.d.ts +19 -0
  176. package/build/lib-common/objs-on-disk/file-layout.js +130 -12
  177. package/build/lib-common/objs-on-disk/obj-file.d.ts +13 -2
  178. package/build/lib-common/objs-on-disk/obj-file.js +99 -37
  179. package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
  180. package/build/lib-common/objs-on-disk/utils.js +4 -4
  181. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +14 -14
  182. package/build/lib-common/processes/deferred.d.ts +6 -0
  183. package/build/lib-common/processes/deferred.js +30 -0
  184. package/build/lib-common/processes/labelled-exec-pools.d.ts +33 -0
  185. package/build/lib-common/processes/labelled-exec-pools.js +141 -0
  186. package/build/lib-common/processes/pressure.d.ts +7 -0
  187. package/build/lib-common/processes/pressure.js +56 -0
  188. package/build/lib-common/processes/sleep.d.ts +1 -0
  189. package/build/lib-common/processes/sleep.js +26 -0
  190. package/build/lib-common/{processes.d.ts → processes/synced.d.ts} +0 -40
  191. package/build/lib-common/{processes.js → processes/synced.js} +187 -204
  192. package/build/lib-common/processes/timeout.d.ts +1 -0
  193. package/build/lib-common/processes/timeout.js +51 -0
  194. package/build/lib-common/random-node.js +7 -7
  195. package/build/lib-common/service-api/3nstorage/owner.d.ts +100 -39
  196. package/build/lib-common/service-api/3nstorage/owner.js +85 -42
  197. package/build/lib-common/service-api/asmail/delivery.js +2 -2
  198. package/build/lib-common/service-api/asmail/retrieval.js +1 -1
  199. package/build/lib-common/timed-cache.d.ts +1 -0
  200. package/build/lib-common/timed-non-weak-cache.d.ts +1 -0
  201. package/build/lib-common/timed-non-weak-cache.js +11 -0
  202. package/build/lib-common/utils-for-observables.d.ts +15 -1
  203. package/build/lib-common/utils-for-observables.js +70 -19
  204. package/build/lib-common/weak-cache.d.ts +1 -0
  205. package/build/lib-common/weak-cache.js +12 -1
  206. package/build/lib-index.d.ts +2 -1
  207. package/build/lib-index.js +10 -7
  208. package/build/protos/asmail.proto.js +12912 -7127
  209. package/build/protos/file.proto.js +4848 -2399
  210. package/build/protos/fs.proto.js +9230 -3445
  211. package/package.json +8 -7
  212. package/protos/file.proto +91 -11
  213. package/protos/fs.proto +107 -8
  214. package/build/core/storage/synced/upsync-status.d.ts +0 -41
  215. package/build/core/storage/synced/upsync-status.js +0 -158
@@ -49,7 +49,7 @@ async function makeFolder(root, path, exclusive = false) {
49
49
  pathStr += '/' + path[i];
50
50
  const stats = await fs.lstat(pathStr).catch((exc) => {
51
51
  if (exc.code !== file_1.Code.notFound) {
52
- throw file_1.maskPathInExc(root.length, exc);
52
+ throw (0, file_1.maskPathInExc)(root.length, exc);
53
53
  }
54
54
  return fs.mkdir(pathStr)
55
55
  .catch((exc) => {
@@ -62,10 +62,10 @@ async function makeFolder(root, path, exclusive = false) {
62
62
  continue;
63
63
  }
64
64
  if (!stats.isDirectory()) {
65
- throw file_1.makeFileException(file_1.Code.notDirectory, path.slice(0, i + 1).join('/'));
65
+ throw (0, file_1.makeFileException)(file_1.Code.notDirectory, path.slice(0, i + 1).join('/'));
66
66
  }
67
67
  else if ((i === lastIndex) && exclusive) {
68
- throw file_1.makeFileException(file_1.Code.alreadyExists, path.join('/'));
68
+ throw (0, file_1.makeFileException)(file_1.Code.alreadyExists, path.join('/'));
69
69
  }
70
70
  }
71
71
  }
@@ -107,7 +107,7 @@ async function checkPresence(type, root, path, throwIfMissing) {
107
107
  if (!throwIfMissing && (exc.code === file_1.Code.notFound)) {
108
108
  return false;
109
109
  }
110
- throw file_1.maskPathInExc(root.length, exc);
110
+ throw (0, file_1.maskPathInExc)(root.length, exc);
111
111
  }
112
112
  }
113
113
  const sep = pathMod.sep;
@@ -227,14 +227,14 @@ class DeviceFS {
227
227
  await fs.lstat(root)
228
228
  .then(stat => {
229
229
  if (create && exclusive) {
230
- throw file_1.makeFileException(file_1.Code.alreadyExists, root);
230
+ throw (0, file_1.makeFileException)(file_1.Code.alreadyExists, root);
231
231
  }
232
232
  if (!stat.isDirectory()) {
233
- throw file_1.makeFileException(file_1.Code.notDirectory, root);
233
+ throw (0, file_1.makeFileException)(file_1.Code.notDirectory, root);
234
234
  }
235
235
  }, async (e) => {
236
236
  if (!e.notFound || !create) {
237
- throw file_1.maskPathInExc(0, e);
237
+ throw (0, file_1.maskPathInExc)(0, e);
238
238
  }
239
239
  await fs.mkdir(root);
240
240
  });
@@ -242,11 +242,11 @@ class DeviceFS {
242
242
  return DeviceFS.makeAndWrapWrFS(root, folderName);
243
243
  }
244
244
  static makeAndWrapWrFS(root, name) {
245
- const wrFS = files_1.wrapWritableFS(new DeviceFS(root, true, name));
245
+ const wrFS = (0, files_1.wrapWritableFS)(new DeviceFS(root, true, name));
246
246
  return wrFS;
247
247
  }
248
248
  static makeAndWrapRoFS(root, name) {
249
- const roFS = files_1.wrapReadonlyFS(new DeviceFS(root, false, name));
249
+ const roFS = (0, files_1.wrapReadonlyFS)(new DeviceFS(root, false, name));
250
250
  return roFS;
251
251
  }
252
252
  static async makeReadonly(root) {
@@ -284,7 +284,7 @@ class DeviceFS {
284
284
  }
285
285
  async stat(path) {
286
286
  const stats = await fs.lstat(this.fullPath(path, true)).catch((e) => {
287
- throw file_1.maskPathInExc(this.root.length, e);
287
+ throw (0, file_1.maskPathInExc)(this.root.length, e);
288
288
  });
289
289
  if (stats.isFile()) {
290
290
  return {
@@ -316,16 +316,16 @@ class DeviceFS {
316
316
  }
317
317
  }
318
318
  updateXAttrs(path, changes) {
319
- throw file_1.makeNoAttrsExc(path);
319
+ throw (0, file_1.makeNoAttrsExc)(path);
320
320
  }
321
321
  getXAttr(path, xaName) {
322
- throw file_1.makeNoAttrsExc(path);
322
+ throw (0, file_1.makeNoAttrsExc)(path);
323
323
  }
324
324
  listXAttrs(path) {
325
- throw file_1.makeNoAttrsExc(path);
325
+ throw (0, file_1.makeNoAttrsExc)(path);
326
326
  }
327
327
  select(path, criteria) {
328
- return files_select_1.selectInFS(this, path, criteria);
328
+ return (0, files_select_1.selectInFS)(this, path, criteria);
329
329
  }
330
330
  async readBytes(path, start, end) {
331
331
  if ((typeof start === 'number') && (start < 0)) {
@@ -356,7 +356,7 @@ class DeviceFS {
356
356
  return bytes;
357
357
  }
358
358
  catch (e) {
359
- throw file_1.maskPathInExc(this.root.length, e);
359
+ throw (0, file_1.maskPathInExc)(this.root.length, e);
360
360
  }
361
361
  finally {
362
362
  if (fd !== undefined) {
@@ -396,7 +396,7 @@ class DeviceFS {
396
396
  return dev_file_sink_1.DevFileByteSink.make(pathStr, this.root.length, stats);
397
397
  }
398
398
  catch (e) {
399
- throw file_1.maskPathInExc(this.root.length, e);
399
+ throw (0, file_1.maskPathInExc)(this.root.length, e);
400
400
  }
401
401
  finally {
402
402
  if (fd !== undefined) {
@@ -407,7 +407,7 @@ class DeviceFS {
407
407
  async getByteSource(path) {
408
408
  const pathStr = this.fullPath(path);
409
409
  const stats = await fs.lstat(pathStr).catch((e) => {
410
- throw file_1.maskPathInExc(this.root.length, e);
410
+ throw (0, file_1.maskPathInExc)(this.root.length, e);
411
411
  });
412
412
  const byteSrc = dev_file_src_1.DevFileByteSource.make(pathStr, this.root.length, stats);
413
413
  return {
@@ -433,10 +433,10 @@ class DeviceFS {
433
433
  fd = await fs.open(pathStr, 'r+');
434
434
  await fs.ftruncate(fd, 0);
435
435
  }
436
- await fs.writeFromBuf(fd, 0, buffer_utils_1.toBuffer(bytes));
436
+ await fs.writeFromBuf(fd, 0, (0, buffer_utils_1.toBuffer)(bytes));
437
437
  }
438
438
  catch (e) {
439
- throw file_1.maskPathInExc(this.root.length, e);
439
+ throw (0, file_1.maskPathInExc)(this.root.length, e);
440
440
  }
441
441
  finally {
442
442
  if (fd !== undefined) {
@@ -455,7 +455,7 @@ class DeviceFS {
455
455
  return txt;
456
456
  }
457
457
  catch (err) {
458
- throw file_1.makeFileException(file_1.Code.parsingError, path, err);
458
+ throw (0, file_1.makeFileException)(file_1.Code.parsingError, path, err);
459
459
  }
460
460
  }
461
461
  writeJSONFile(path, json, flags = WRITE_NONEXCL_FLAGS) {
@@ -469,7 +469,7 @@ class DeviceFS {
469
469
  return json;
470
470
  }
471
471
  catch (err) {
472
- throw file_1.makeFileException(file_1.Code.parsingError, path, err);
472
+ throw (0, file_1.makeFileException)(file_1.Code.parsingError, path, err);
473
473
  }
474
474
  }
475
475
  async deleteFile(path) {
@@ -479,7 +479,7 @@ class DeviceFS {
479
479
  if (e.isDirectory) {
480
480
  e.notFile = true;
481
481
  }
482
- throw file_1.maskPathInExc(this.root.length, e);
482
+ throw (0, file_1.maskPathInExc)(this.root.length, e);
483
483
  });
484
484
  }
485
485
  makeFolder(path, exclusive = false) {
@@ -503,7 +503,7 @@ class DeviceFS {
503
503
  }
504
504
  }
505
505
  catch (e) {
506
- throw file_1.maskPathInExc(this.root.length, e);
506
+ throw (0, file_1.maskPathInExc)(this.root.length, e);
507
507
  }
508
508
  }
509
509
  async listFolder(folder) {
@@ -537,7 +537,7 @@ class DeviceFS {
537
537
  return lst;
538
538
  }
539
539
  catch (exc) {
540
- throw file_1.maskPathInExc(this.root.length, exc);
540
+ throw (0, file_1.maskPathInExc)(this.root.length, exc);
541
541
  }
542
542
  }
543
543
  async move(initPath, newPath) {
@@ -557,7 +557,7 @@ class DeviceFS {
557
557
  const dstPath = this.root + '/' + dst.join('/');
558
558
  await fs.lstat(dstPath)
559
559
  .then(() => {
560
- throw file_1.makeFileException(file_1.Code.alreadyExists, newPath);
560
+ throw (0, file_1.makeFileException)(file_1.Code.alreadyExists, newPath);
561
561
  }, (exc) => {
562
562
  if (!exc.notFound) {
563
563
  throw exc;
@@ -570,7 +570,7 @@ class DeviceFS {
570
570
  await fs.rename(srcPath, dstPath);
571
571
  }
572
572
  catch (e) {
573
- throw file_1.maskPathInExc(this.root.length, e);
573
+ throw (0, file_1.maskPathInExc)(this.root.length, e);
574
574
  }
575
575
  }
576
576
  checkLinkPresence(path, throwIfMissing = true) {
@@ -595,7 +595,7 @@ class DeviceFS {
595
595
  if (err.isDirectory) {
596
596
  err.notLink = true;
597
597
  }
598
- throw file_1.maskPathInExc(this.root.length, err);
598
+ throw (0, file_1.maskPathInExc)(this.root.length, err);
599
599
  }
600
600
  }
601
601
  async readLink(path) {
@@ -651,7 +651,7 @@ class DeviceFS {
651
651
  }
652
652
  }
653
653
  catch (e) {
654
- throw file_1.maskPathInExc(this.root.length, e);
654
+ throw (0, file_1.maskPathInExc)(this.root.length, e);
655
655
  }
656
656
  }
657
657
  async link(path, target) {
@@ -687,21 +687,21 @@ class DeviceFS {
687
687
  }
688
688
  async readonlyFile(path) {
689
689
  await this.checkFilePresence(path, true);
690
- return files_1.wrapReadonlyFile(new FileObject(this, path, true, false));
690
+ return (0, files_1.wrapReadonlyFile)(new FileObject(this, path, true, false));
691
691
  }
692
692
  async writableFile(path, flags = WRITE_NONEXCL_FLAGS) {
693
693
  const exists = await this.checkFilePresence(path);
694
694
  if (exists && flags.create && flags.exclusive) {
695
- throw file_1.makeFileException(file_1.Code.alreadyExists, path);
695
+ throw (0, file_1.makeFileException)(file_1.Code.alreadyExists, path);
696
696
  }
697
697
  if (!exists && !flags.create) {
698
- throw file_1.makeFileException(file_1.Code.notFound, path);
698
+ throw (0, file_1.makeFileException)(file_1.Code.notFound, path);
699
699
  }
700
- return files_1.wrapWritableFile(new FileObject(this, path, exists, true));
700
+ return (0, files_1.wrapWritableFile)(new FileObject(this, path, exists, true));
701
701
  }
702
702
  watchFolder(path, observer) {
703
703
  const fullFolderPath = this.fullPath(path, true);
704
- let watcher = fs_1.watch(fullFolderPath);
704
+ let watcher = (0, fs_1.watch)(fullFolderPath);
705
705
  if (observer.next) {
706
706
  watcher.on('change', (fsEvent, name) => {
707
707
  if (fsEvent !== 'rename') {
@@ -727,6 +727,7 @@ class DeviceFS {
727
727
  const folderEvent = {
728
728
  type: 'entry-addition',
729
729
  path,
730
+ src: 'local',
730
731
  entry
731
732
  };
732
733
  observer.next(folderEvent);
@@ -738,6 +739,7 @@ class DeviceFS {
738
739
  const folderEvent = {
739
740
  type: 'entry-removal',
740
741
  path,
742
+ src: 'local',
741
743
  name
742
744
  };
743
745
  observer.next(folderEvent);
@@ -745,7 +747,7 @@ class DeviceFS {
745
747
  }
746
748
  try {
747
749
  if (observer.error) {
748
- observer.error(file_1.maskPathInExc(this.root.length, err));
750
+ observer.error((0, file_1.maskPathInExc)(this.root.length, err));
749
751
  }
750
752
  else if (observer.complete) {
751
753
  observer.complete();
@@ -763,7 +765,7 @@ class DeviceFS {
763
765
  }
764
766
  try {
765
767
  if (observer.error) {
766
- observer.error(file_1.makeFileException(sig, path, { code, sig }));
768
+ observer.error((0, file_1.makeFileException)(sig, path, { code, sig }));
767
769
  }
768
770
  else if (observer.complete) {
769
771
  observer.complete();
@@ -787,7 +789,7 @@ class DeviceFS {
787
789
  // XXX
788
790
  throw new Error('Not implemented, yet');
789
791
  }
790
- watchTree(path, observer) {
792
+ watchTree(path, depth, observer) {
791
793
  // XXX
792
794
  throw new Error('Not implemented, yet');
793
795
  }
@@ -799,7 +801,7 @@ class DeviceFS {
799
801
  truncate: true
800
802
  };
801
803
  const sink = await this.getByteSink(dst, flags);
802
- await pipe_1.pipe(srcBytes, sink);
804
+ await (0, pipe_1.pipe)(srcBytes, sink);
803
805
  }
804
806
  async copyFolder(src, dst, mergeAndOverwrite = false) {
805
807
  const list = await this.listFolder(src);
@@ -824,7 +826,7 @@ class DeviceFS {
824
826
  truncate: true
825
827
  };
826
828
  const sink = await this.getByteSink(dst, flags);
827
- await pipe_1.pipe(src, sink);
829
+ await (0, pipe_1.pipe)(src, sink);
828
830
  }
829
831
  async saveFolder(folder, dst, mergeAndOverwrite = false) {
830
832
  const lst = await folder.listFolder('/');
@@ -838,7 +840,7 @@ class DeviceFS {
838
840
  truncate: true
839
841
  };
840
842
  const sink = await this.getByteSink(`${dst}/${f.name}`, flags);
841
- await pipe_1.pipe(src, sink);
843
+ await (0, pipe_1.pipe)(src, sink);
842
844
  }
843
845
  else if (f.isFolder) {
844
846
  const subFolder = await folder.readonlySubRoot(f.name);
@@ -871,10 +873,10 @@ function pathUnderRoot(root, path, canBeRoot = false) {
871
873
  }
872
874
  async function checkFolderPresence(path) {
873
875
  const stat = await fs.lstat(path).catch((e) => {
874
- throw file_1.maskPathInExc(0, e);
876
+ throw (0, file_1.maskPathInExc)(0, e);
875
877
  });
876
878
  if (!stat.isDirectory()) {
877
- throw file_1.makeFileException(file_1.Code.notDirectory, path);
879
+ throw (0, file_1.makeFileException)(file_1.Code.notDirectory, path);
878
880
  }
879
881
  }
880
882
  class FileObject {
@@ -903,7 +905,7 @@ class FileObject {
903
905
  this.exists = true;
904
906
  }
905
907
  catch (e) {
906
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
908
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
907
909
  }
908
910
  }
909
911
  async writeJSON(json) {
@@ -914,7 +916,7 @@ class FileObject {
914
916
  this.exists = true;
915
917
  }
916
918
  catch (e) {
917
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
919
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
918
920
  }
919
921
  }
920
922
  async writeTxt(txt) {
@@ -925,7 +927,7 @@ class FileObject {
925
927
  this.exists = true;
926
928
  }
927
929
  catch (e) {
928
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
930
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
929
931
  }
930
932
  }
931
933
  readBytes(start, end) {
@@ -933,7 +935,7 @@ class FileObject {
933
935
  return this.fs.readBytes(this.path, start, end);
934
936
  }
935
937
  catch (e) {
936
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
938
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
937
939
  }
938
940
  }
939
941
  readTxt() {
@@ -941,7 +943,7 @@ class FileObject {
941
943
  return this.fs.readTxtFile(this.path);
942
944
  }
943
945
  catch (e) {
944
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
946
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
945
947
  }
946
948
  }
947
949
  readJSON() {
@@ -949,7 +951,7 @@ class FileObject {
949
951
  return this.fs.readJSONFile(this.path);
950
952
  }
951
953
  catch (e) {
952
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
954
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
953
955
  }
954
956
  }
955
957
  getByteSink(truncate = true) {
@@ -959,7 +961,7 @@ class FileObject {
959
961
  });
960
962
  }
961
963
  catch (e) {
962
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
964
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
963
965
  }
964
966
  }
965
967
  getByteSource() {
@@ -967,7 +969,7 @@ class FileObject {
967
969
  return this.fs.getByteSource(this.path);
968
970
  }
969
971
  catch (e) {
970
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
972
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
971
973
  }
972
974
  }
973
975
  stat() {
@@ -975,22 +977,22 @@ class FileObject {
975
977
  return this.fs.stat(this.path);
976
978
  }
977
979
  catch (e) {
978
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
980
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
979
981
  }
980
982
  }
981
983
  updateXAttrs(changes) {
982
- throw file_1.makeNoAttrsExc(this.path);
984
+ throw (0, file_1.makeNoAttrsExc)(this.path);
983
985
  }
984
986
  getXAttr(xaName) {
985
- throw file_1.makeNoAttrsExc(this.path);
987
+ throw (0, file_1.makeNoAttrsExc)(this.path);
986
988
  }
987
989
  listXAttrs() {
988
- throw file_1.makeNoAttrsExc(this.path);
990
+ throw (0, file_1.makeNoAttrsExc)(this.path);
989
991
  }
990
992
  async copy(file) {
991
993
  const sink = await this.getByteSink();
992
994
  const src = await file.getByteSource();
993
- await pipe_1.pipe(src, sink);
995
+ await (0, pipe_1.pipe)(src, sink);
994
996
  }
995
997
  watch(observer) {
996
998
  return this.fs.watchFile(this.path, observer);
@@ -1,6 +1,6 @@
1
1
  export declare const LOGS_FOLDER = "logs";
2
2
  export declare function makeLogger(utilDir: string): Readonly<{
3
- logError: (err: any, msg?: string | undefined) => Promise<void>;
3
+ logError: (err: any, msg?: string) => Promise<void>;
4
4
  logWarning: (msg: string, err?: any) => Promise<void>;
5
5
  appLog: (type: 'error' | 'info' | 'warning', appDomain: string, msg: string, err?: any) => Promise<void>;
6
6
  recordUnhandledRejectionsInProcess: () => void;
@@ -18,7 +18,7 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.makeLogger = exports.LOGS_FOLDER = void 0;
20
20
  const error_1 = require("../../lib-common/exceptions/error");
21
- const processes_1 = require("../../lib-common/processes");
21
+ const synced_1 = require("../../lib-common/processes/synced");
22
22
  const async_fs_node_1 = require("../../lib-common/async-fs-node");
23
23
  const path_1 = require("path");
24
24
  exports.LOGS_FOLDER = 'logs';
@@ -55,7 +55,7 @@ ${now} ==================================
55
55
  Core version ${getCurrentCoreVersion()}
56
56
  Log level: error.${msg ? `
57
57
  ${msg}` : ''}
58
- ${error_1.stringifyErr(err)}`;
58
+ ${(0, error_1.stringifyErr)(err)}`;
59
59
  await appendLog(entry, now);
60
60
  }
61
61
  catch (err2) {
@@ -63,19 +63,19 @@ ${error_1.stringifyErr(err)}`;
63
63
  console.error(err2);
64
64
  }
65
65
  }
66
- const loggingProc = new processes_1.SingleProc();
66
+ const loggingProc = new synced_1.SingleProc();
67
67
  function appendLog(s, now, appDomain) {
68
68
  return loggingProc.startOrChain(async () => {
69
- const logFile = path_1.join(utilDir, exports.LOGS_FOLDER, logFileName(now, appDomain));
69
+ const logFile = (0, path_1.join)(utilDir, exports.LOGS_FOLDER, logFileName(now, appDomain));
70
70
  try {
71
- await async_fs_node_1.appendFile(logFile, s, { encoding: 'utf8' });
71
+ await (0, async_fs_node_1.appendFile)(logFile, s, { encoding: 'utf8' });
72
72
  }
73
73
  catch (exc) {
74
74
  if (!exc.notFound) {
75
75
  throw exc;
76
76
  }
77
- await async_fs_node_1.ensureFolderExists(path_1.dirname(logFile));
78
- await async_fs_node_1.appendFile(logFile, s, { encoding: 'utf8' });
77
+ await (0, async_fs_node_1.ensureFolderExists)((0, path_1.dirname)(logFile));
78
+ await (0, async_fs_node_1.appendFile)(logFile, s, { encoding: 'utf8' });
79
79
  }
80
80
  });
81
81
  }
@@ -87,7 +87,7 @@ ${now} ==================================
87
87
  Core version ${getCurrentCoreVersion()}
88
88
  Log level: warning.
89
89
  ${msg}
90
- ${err ? error_1.stringifyErr(err) : ''}`;
90
+ ${err ? (0, error_1.stringifyErr)(err) : ''}`;
91
91
  await appendLog(entry, now);
92
92
  }
93
93
  catch (err2) {
@@ -106,7 +106,7 @@ ${now} ==================================
106
106
  App ${appDomain}, running on core version ${getCurrentCoreVersion()}
107
107
  Log level: ${type}.${msg ? `
108
108
  ${msg}` : ''}
109
- ${error_1.stringifyErr(err)}`;
109
+ ${(0, error_1.stringifyErr)(err)}`;
110
110
  await appendLog(entry, now, appDomain);
111
111
  }
112
112
  catch (err2) {
@@ -115,11 +115,11 @@ ${error_1.stringifyErr(err)}`;
115
115
  }
116
116
  function recordUnhandledRejectionsInProcess() {
117
117
  process.on('unhandledRejection', (err, p) => {
118
- console.log(' -- Unhandled rejection of promise:', err);
118
+ console.error(' -- Unhandled rejection of promise:', err);
119
119
  logError(err, 'Unhandled rejection of promise');
120
120
  });
121
121
  process.on('uncaughtException', err => {
122
- console.log(' -- Unhandled exception:', err);
122
+ console.error(' -- Unhandled exception:', err);
123
123
  logError(err, 'Unhandled exception');
124
124
  });
125
125
  }
@@ -33,29 +33,29 @@ async function startMidSession(userId, net, loginUrl) {
33
33
  if (rep.status === api.startSession.SC.ok) {
34
34
  const r = rep.data;
35
35
  if (!r || (typeof r.sessionId !== 'string') || !r.sessionId) {
36
- throw request_utils_1.makeException(rep, 'Malformed reply to starting session');
36
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply to starting session');
37
37
  }
38
38
  return { sessionId: r.sessionId };
39
39
  }
40
40
  else if (rep.status === api.startSession.SC.redirect) {
41
41
  const rd = rep.data;
42
42
  if (!rd || ('string' !== typeof rd.redirect) || !rd.redirect) {
43
- throw request_utils_1.makeException(rep, 'Malformed redirect reply to starting session');
43
+ throw (0, request_utils_1.makeException)(rep, 'Malformed redirect reply to starting session');
44
44
  }
45
45
  return { redirect: rd.redirect };
46
46
  }
47
47
  else if (rep.status === api.startSession.SC.unknownUser) {
48
- const exc = request_utils_1.makeException(rep);
48
+ const exc = (0, request_utils_1.makeException)(rep);
49
49
  exc.unknownUser = true;
50
50
  throw exc;
51
51
  }
52
52
  else {
53
- throw request_utils_1.makeException(rep, 'Unexpected status');
53
+ throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
54
54
  }
55
55
  }
56
56
  exports.startMidSession = startMidSession;
57
57
  async function authenticateMidSession(sessionId, midSigner, net, loginUrl) {
58
- const domain = url_1.parse(loginUrl).hostname;
58
+ const domain = (0, url_1.parse)(loginUrl).hostname;
59
59
  const reqData = {
60
60
  assertion: midSigner.generateAssertionFor(domain, sessionId),
61
61
  userCert: midSigner.userCert,
@@ -73,12 +73,12 @@ async function authenticateMidSession(sessionId, midSigner, net, loginUrl) {
73
73
  return;
74
74
  }
75
75
  else if (rep.status === api.authSession.SC.authFailed) {
76
- const exc = request_utils_1.makeException(rep);
76
+ const exc = (0, request_utils_1.makeException)(rep);
77
77
  exc.loginFailed = true;
78
78
  throw exc;
79
79
  }
80
80
  else {
81
- throw request_utils_1.makeException(rep, 'Unexpected status');
81
+ throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
82
82
  }
83
83
  }
84
84
  exports.authenticateMidSession = authenticateMidSession;
@@ -57,8 +57,8 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
57
57
  Object.seal(this);
58
58
  }
59
59
  async setUrlAndDomain() {
60
- const info = await service_locator_1.mailerIdInfoAt(this.net, this.entryURI);
61
- this.midDomain = url_1.parse(this.serviceURI).hostname;
60
+ const info = await (0, service_locator_1.mailerIdInfoAt)(this.net, this.entryURI);
61
+ this.midDomain = (0, url_1.parse)(this.serviceURI).hostname;
62
62
  this.serviceURI = info.provisioning;
63
63
  this.rootCert = info.currentCert;
64
64
  }
@@ -71,7 +71,7 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
71
71
  * the MailerId server.
72
72
  */
73
73
  async getCertificates(pkey, duration) {
74
- assert_1.assert(!!this.encryptor);
74
+ (0, assert_1.assert)(!!this.encryptor);
75
75
  const plainReqData = {
76
76
  pkey: pkey,
77
77
  duration: duration
@@ -89,25 +89,25 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
89
89
  certs = this.encryptor.openJSON(rep.data);
90
90
  }
91
91
  catch (err) {
92
- throw request_utils_1.makeException(rep, 'Malformed reply: ' + err.message);
92
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply: ' + err.message);
93
93
  }
94
94
  if (!certs.userCert || !certs.provCert) {
95
- throw request_utils_1.makeException(rep, 'Malformed reply: Certificates are missing.');
95
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply: Certificates are missing.');
96
96
  }
97
97
  const pkeyAndId = mid.relyingParty.verifyChainAndGetUserKey({ user: certs.userCert, prov: certs.provCert,
98
- root: this.rootCert }, this.midDomain, jwkeys_1.getKeyCert(certs.userCert).issuedAt + 1);
99
- if (pkeyAndId.address !== canonical_address_1.toCanonicalAddress(this.userId)) {
100
- throw request_utils_1.makeException(rep, 'Malformed reply: Certificate is for a wrong address.');
98
+ root: this.rootCert }, this.midDomain, (0, jwkeys_1.getKeyCert)(certs.userCert).issuedAt + 1);
99
+ if (pkeyAndId.address !== (0, canonical_address_1.toCanonicalAddress)(this.userId)) {
100
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply: Certificate is for a wrong address.');
101
101
  }
102
- const keyInCert = jwkeys_1.keyToJson(pkeyAndId.pkey);
103
- if (!json_utils_1.deepEqual(keyInCert, pkey)) {
104
- throw request_utils_1.makeException(rep, 'Malformed reply: Certificate is for a wrong key.');
102
+ const keyInCert = (0, jwkeys_1.keyToJson)(pkeyAndId.pkey);
103
+ if (!(0, json_utils_1.deepEqual)(keyInCert, pkey)) {
104
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply: Certificate is for a wrong key.');
105
105
  }
106
106
  this.userCert = certs.userCert;
107
107
  this.provCert = certs.provCert;
108
108
  }
109
109
  else {
110
- throw request_utils_1.makeException(rep, 'Unexpected status');
110
+ throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
111
111
  }
112
112
  }
113
113
  finally {
@@ -17,7 +17,7 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.FileWritingProc = void 0;
20
- const processes_1 = require("../../lib-common/processes");
20
+ const pressure_1 = require("../../lib-common/processes/pressure");
21
21
  const rxjs_1 = require("rxjs");
22
22
  const operators_1 = require("rxjs/operators");
23
23
  const buffer_utils_1 = require("../../lib-common/buffer-utils");
@@ -27,7 +27,7 @@ const BACKPRESSURE_BUF_SIZE = 5 * 1024 * 1024;
27
27
  class FileWritingProc {
28
28
  constructor(objFile) {
29
29
  this.objFile = objFile;
30
- this.pValve = new processes_1.PressureValve();
30
+ this.pValve = new pressure_1.PressureValve();
31
31
  this.buffer = { segs: [], size: 0 };
32
32
  Object.seal(this);
33
33
  }
@@ -37,7 +37,7 @@ class FileWritingProc {
37
37
  }
38
38
  assembleProc(encSub) {
39
39
  const ee$ = new rxjs_1.Observable(obs => encSub(obs, this.pValve.pressure));
40
- const main$ = ee$.pipe(operators_1.map(ee => this.addToBuffer(ee)), operators_1.filter(() => this.canSaveBuffered()), operators_1.mergeMap(() => this.saveBuffered(), 1), utils_for_observables_1.flatMapComplete(() => this.saveBuffered(true)));
40
+ const main$ = ee$.pipe((0, operators_1.map)(ee => this.addToBuffer(ee)), (0, operators_1.filter)(() => this.canSaveBuffered()), (0, operators_1.mergeMap)(() => this.saveBuffered(), 1), (0, utils_for_observables_1.flatMapComplete)(() => this.saveBuffered(true)));
41
41
  return main$;
42
42
  }
43
43
  addToBuffer(ee) {
@@ -126,7 +126,7 @@ function combineSegsFrom(segs) {
126
126
  chunkSegs.push(seg);
127
127
  }
128
128
  else if (chunkEnd < sOfs) {
129
- chunks.push({ ofs: chunkStart, bytes: buffer_utils_1.joinByteArrs(chunkSegs) });
129
+ chunks.push({ ofs: chunkStart, bytes: (0, buffer_utils_1.joinByteArrs)(chunkSegs) });
130
130
  chunkSegs = [seg];
131
131
  chunkStart = sOfs;
132
132
  chunkEnd = chunkStart + seg.length;
@@ -135,7 +135,7 @@ function combineSegsFrom(segs) {
135
135
  throw new Error(`Got missorted segment`);
136
136
  }
137
137
  }
138
- chunks.push({ ofs: chunkStart, bytes: buffer_utils_1.joinByteArrs(chunkSegs) });
138
+ chunks.push({ ofs: chunkStart, bytes: (0, buffer_utils_1.joinByteArrs)(chunkSegs) });
139
139
  return chunks;
140
140
  }
141
141
  Object.freeze(exports);