core-3nweb-client-lib 0.26.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 (211) hide show
  1. package/build/api-defs/asmail.d.ts +1 -1
  2. package/build/api-defs/files.d.ts +281 -75
  3. package/build/core/app-files.js +7 -7
  4. package/build/core/asmail/config/common.js +2 -2
  5. package/build/core/asmail/config/index.js +2 -2
  6. package/build/core/asmail/config/published-intro-key.js +1 -1
  7. package/build/core/asmail/delivery/common.js +7 -7
  8. package/build/core/asmail/delivery/index.js +5 -5
  9. package/build/core/asmail/delivery/msg.js +4 -4
  10. package/build/core/asmail/delivery/per-recipient-wip.js +1 -1
  11. package/build/core/asmail/inbox/attachments/fs.d.ts +2 -1
  12. package/build/core/asmail/inbox/attachments/fs.js +9 -4
  13. package/build/core/asmail/inbox/cached-msgs.js +1 -1
  14. package/build/core/asmail/inbox/inbox-events.js +4 -4
  15. package/build/core/asmail/inbox/index.js +10 -10
  16. package/build/core/asmail/inbox/msg-downloader.js +1 -1
  17. package/build/core/asmail/inbox/msg-indexing.js +1 -1
  18. package/build/core/asmail/inbox/msg-on-disk.js +5 -5
  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 +2 -1
  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 +2 -2
  31. package/build/core/asmail/sending-params/params-from-others.js +1 -1
  32. package/build/core/id-manager/index.d.ts +43 -0
  33. package/build/core/{id-manager.js → id-manager/index.js} +36 -114
  34. package/build/core/id-manager/key-storage.d.ts +21 -0
  35. package/build/core/id-manager/key-storage.js +96 -0
  36. package/build/core/index.d.ts +2 -1
  37. package/build/core/index.js +31 -33
  38. package/build/core/sign-in.d.ts +1 -2
  39. package/build/core/sign-in.js +8 -17
  40. package/build/core/sign-up.d.ts +2 -0
  41. package/build/core/sign-up.js +11 -10
  42. package/build/core/storage/common/json-saving.js +2 -2
  43. package/build/core/storage/common/obj-info-file.d.ts +12 -4
  44. package/build/core/storage/common/obj-info-file.js +66 -34
  45. package/build/core/storage/common/utils.d.ts +2 -0
  46. package/build/core/storage/common/utils.js +32 -0
  47. package/build/core/storage/index.d.ts +5 -17
  48. package/build/core/storage/index.js +78 -119
  49. package/build/core/storage/local/obj-files-gc.d.ts +2 -0
  50. package/build/core/storage/local/obj-files-gc.js +49 -37
  51. package/build/core/storage/local/obj-files.d.ts +4 -7
  52. package/build/core/storage/local/obj-files.js +7 -10
  53. package/build/core/storage/local/obj-status.d.ts +12 -6
  54. package/build/core/storage/local/obj-status.js +24 -9
  55. package/build/core/storage/local/storage.d.ts +10 -7
  56. package/build/core/storage/local/storage.js +29 -18
  57. package/build/core/storage/synced/downloader.js +1 -1
  58. package/build/core/storage/synced/obj-files-gc.d.ts +1 -0
  59. package/build/core/storage/synced/obj-files-gc.js +76 -39
  60. package/build/core/storage/synced/obj-files.d.ts +50 -36
  61. package/build/core/storage/synced/obj-files.js +201 -162
  62. package/build/core/storage/synced/obj-status.d.ts +99 -86
  63. package/build/core/storage/synced/obj-status.js +520 -251
  64. package/build/core/storage/synced/remote-events.d.ts +11 -12
  65. package/build/core/storage/synced/remote-events.js +73 -56
  66. package/build/core/storage/synced/storage.d.ts +24 -10
  67. package/build/core/storage/synced/storage.js +147 -47
  68. package/build/core/storage/synced/upload-header-file.d.ts +4 -0
  69. package/build/core/storage/synced/upload-header-file.js +64 -0
  70. package/build/core/storage/synced/upsyncer.d.ts +12 -7
  71. package/build/core/storage/synced/upsyncer.js +210 -280
  72. package/build/core/storage/system-folders/apps-data.d.ts +16 -0
  73. package/build/core/storage/system-folders/apps-data.js +110 -0
  74. package/build/core/storage/system-folders/index.d.ts +18 -0
  75. package/build/core/storage/system-folders/index.js +77 -0
  76. package/build/core-ipc/common-caps.js +3 -3
  77. package/build/core-ipc/generic.js +8 -8
  78. package/build/core-ipc/startup-caps.js +2 -2
  79. package/build/cryptors.js +6 -2
  80. package/build/ipc-via-protobuf/asmail-cap.js +58 -57
  81. package/build/ipc-via-protobuf/bytes.js +16 -17
  82. package/build/ipc-via-protobuf/connector-clients-side.d.ts +1 -0
  83. package/build/ipc-via-protobuf/connector-clients-side.js +14 -15
  84. package/build/ipc-via-protobuf/connector-services-side.js +10 -10
  85. package/build/ipc-via-protobuf/connector.js +4 -4
  86. package/build/ipc-via-protobuf/file.d.ts +48 -12
  87. package/build/ipc-via-protobuf/file.js +474 -126
  88. package/build/ipc-via-protobuf/fs.d.ts +8 -0
  89. package/build/ipc-via-protobuf/fs.js +577 -142
  90. package/build/ipc-via-protobuf/log-cap.js +2 -2
  91. package/build/ipc-via-protobuf/mailerid.js +3 -3
  92. package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -0
  93. package/build/ipc-via-protobuf/protobuf-msg.js +11 -7
  94. package/build/ipc-via-protobuf/startup-cap.js +21 -21
  95. package/build/ipc-via-protobuf/storage-cap.js +12 -12
  96. package/build/ipc.js +7 -2
  97. package/build/lib-client/3nstorage/exceptions.d.ts +16 -1
  98. package/build/lib-client/3nstorage/exceptions.js +21 -3
  99. package/build/lib-client/3nstorage/service.d.ts +21 -3
  100. package/build/lib-client/3nstorage/service.js +128 -46
  101. package/build/lib-client/3nstorage/util/file-based-json.d.ts +2 -1
  102. package/build/lib-client/3nstorage/util/file-based-json.js +3 -2
  103. package/build/lib-client/3nstorage/util/for-arrays.d.ts +1 -0
  104. package/build/lib-client/3nstorage/util/for-arrays.js +32 -0
  105. package/build/lib-client/3nstorage/xsp-fs/attrs.js +17 -17
  106. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +44 -19
  107. package/build/lib-client/3nstorage/xsp-fs/common.js +30 -19
  108. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +1 -0
  109. package/build/lib-client/3nstorage/xsp-fs/file-node.js +17 -13
  110. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +31 -6
  111. package/build/lib-client/3nstorage/xsp-fs/file.js +73 -25
  112. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +4 -4
  113. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +32 -13
  114. package/build/lib-client/3nstorage/xsp-fs/folder-node.js +752 -192
  115. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +35 -4
  116. package/build/lib-client/3nstorage/xsp-fs/fs.js +236 -119
  117. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +1 -0
  118. package/build/lib-client/3nstorage/xsp-fs/link-node.js +7 -2
  119. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +30 -29
  120. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +232 -127
  121. package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +1 -1
  122. package/build/lib-client/3nstorage/xsp-fs/node-persistence.js +17 -18
  123. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +3 -3
  124. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +53 -53
  125. package/build/lib-client/3nweb-signup.js +4 -4
  126. package/build/lib-client/asmail/recipient.js +15 -15
  127. package/build/lib-client/asmail/sender.js +22 -22
  128. package/build/lib-client/asmail/service-config.js +3 -3
  129. package/build/lib-client/cryptor/cryptor-in-worker.js +18 -16
  130. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  131. package/build/lib-client/cryptor/cryptor.js +4 -2
  132. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  133. package/build/lib-client/cryptor/in-proc-js.js +1 -1
  134. package/build/lib-client/cryptor/in-proc-wasm.js +6 -6
  135. package/build/lib-client/cryptor/worker-js.js +2 -2
  136. package/build/lib-client/cryptor/worker-wasm.js +2 -2
  137. package/build/lib-client/files-select.js +1 -1
  138. package/build/lib-client/files.d.ts +1 -1
  139. package/build/lib-client/files.js +71 -6
  140. package/build/lib-client/fs-collection.js +1 -1
  141. package/build/lib-client/fs-sync-utils.d.ts +5 -0
  142. package/build/lib-client/fs-sync-utils.js +61 -0
  143. package/build/lib-client/fs-view.d.ts +14 -0
  144. package/build/lib-client/fs-view.js +33 -0
  145. package/build/lib-client/key-derivation.js +1 -1
  146. package/build/lib-client/local-files/dev-file-sink.js +9 -9
  147. package/build/lib-client/local-files/dev-file-src.js +2 -2
  148. package/build/lib-client/local-files/device-fs.d.ts +1 -1
  149. package/build/lib-client/local-files/device-fs.js +56 -54
  150. package/build/lib-client/logging/log-to-file.d.ts +1 -1
  151. package/build/lib-client/logging/log-to-file.js +7 -7
  152. package/build/lib-client/mailer-id/login.js +7 -7
  153. package/build/lib-client/mailer-id/provisioner.js +12 -12
  154. package/build/lib-client/objs-on-disk/file-writing-proc.js +3 -3
  155. package/build/lib-client/objs-on-disk/obj-folders.js +31 -31
  156. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +13 -2
  157. package/build/lib-client/objs-on-disk/obj-on-disk.js +24 -9
  158. package/build/lib-client/request-utils.d.ts +1 -0
  159. package/build/lib-client/request-utils.js +13 -13
  160. package/build/lib-client/server-events.d.ts +3 -3
  161. package/build/lib-client/server-events.js +9 -8
  162. package/build/lib-client/service-locator.js +10 -10
  163. package/build/lib-client/user-with-mid-session.d.ts +2 -1
  164. package/build/lib-client/user-with-mid-session.js +14 -8
  165. package/build/lib-client/user-with-pkl-session.js +25 -25
  166. package/build/lib-client/ws-utils.js +2 -2
  167. package/build/lib-common/async-cryptor-wrap.js +4 -4
  168. package/build/lib-common/async-fs-node.d.ts +5 -3
  169. package/build/lib-common/async-fs-node.js +17 -17
  170. package/build/lib-common/byte-streaming/pipe.js +1 -1
  171. package/build/lib-common/byte-streaming/wrapping.js +13 -13
  172. package/build/lib-common/canonical-address.js +1 -1
  173. package/build/lib-common/exceptions/error.d.ts +1 -0
  174. package/build/lib-common/exceptions/error.js +7 -6
  175. package/build/lib-common/exceptions/file.d.ts +4 -2
  176. package/build/lib-common/exceptions/file.js +24 -54
  177. package/build/lib-common/ipc/generic-ipc.js +5 -4
  178. package/build/lib-common/ipc/ws-ipc.js +2 -2
  179. package/build/lib-common/mid-sigs-NaCl-Ed.js +14 -14
  180. package/build/lib-common/objs-on-disk/file-layout.d.ts +19 -0
  181. package/build/lib-common/objs-on-disk/file-layout.js +130 -12
  182. package/build/lib-common/objs-on-disk/obj-file.d.ts +13 -2
  183. package/build/lib-common/objs-on-disk/obj-file.js +96 -35
  184. package/build/lib-common/objs-on-disk/utils.d.ts +1 -0
  185. package/build/lib-common/objs-on-disk/utils.js +3 -3
  186. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +14 -14
  187. package/build/lib-common/processes/labelled-exec-pools.d.ts +1 -1
  188. package/build/lib-common/processes/labelled-exec-pools.js +1 -1
  189. package/build/lib-common/processes/pressure.js +2 -2
  190. package/build/lib-common/processes/synced.js +1 -1
  191. package/build/lib-common/processes/timeout.js +2 -2
  192. package/build/lib-common/random-node.js +7 -7
  193. package/build/lib-common/service-api/3nstorage/owner.d.ts +101 -42
  194. package/build/lib-common/service-api/3nstorage/owner.js +83 -40
  195. package/build/lib-common/service-api/asmail/delivery.js +2 -2
  196. package/build/lib-common/service-api/asmail/retrieval.js +1 -1
  197. package/build/lib-common/timed-cache.d.ts +1 -0
  198. package/build/lib-common/timed-non-weak-cache.d.ts +1 -0
  199. package/build/lib-common/timed-non-weak-cache.js +11 -0
  200. package/build/lib-common/utils-for-observables.js +4 -4
  201. package/build/lib-common/weak-cache.d.ts +1 -0
  202. package/build/lib-common/weak-cache.js +12 -1
  203. package/build/lib-index.d.ts +2 -1
  204. package/build/lib-index.js +10 -7
  205. package/build/protos/asmail.proto.js +12955 -7496
  206. package/build/protos/file.proto.js +4867 -2744
  207. package/build/protos/fs.proto.js +9227 -3768
  208. package/package.json +7 -5
  209. package/protos/file.proto +91 -19
  210. package/protos/fs.proto +107 -8
  211. package/build/core/id-manager.d.ts +0 -46
@@ -17,16 +17,18 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.makeInProcessWasmCryptor = exports.makeInProcessCryptor = exports.makeInWorkerWasmCryptor = exports.makeInWorkerCryptor = void 0;
20
- exports.makeInWorkerCryptor = (logErr, logWarning, maxThreads) => {
20
+ const makeInWorkerCryptor = (logErr, logWarning, maxThreads) => {
21
21
  const mod = require('./cryptor-in-worker');
22
22
  const makeInWorkerCryptor = mod.makeInWorkerCryptor;
23
23
  return makeInWorkerCryptor(logErr, logWarning, maxThreads);
24
24
  };
25
- exports.makeInWorkerWasmCryptor = (logErr, logWarning, maxThreads) => {
25
+ exports.makeInWorkerCryptor = makeInWorkerCryptor;
26
+ const makeInWorkerWasmCryptor = (logErr, logWarning, maxThreads) => {
26
27
  const mod = require('./cryptor-in-worker');
27
28
  const makeInWorkerWasmCryptor = mod.makeInWorkerWasmCryptor;
28
29
  return makeInWorkerWasmCryptor(logErr, logWarning, maxThreads);
29
30
  };
31
+ exports.makeInWorkerWasmCryptor = makeInWorkerWasmCryptor;
30
32
  function makeInProcessCryptor() {
31
33
  const mod = require('./in-proc-js');
32
34
  const makeInProcessCryptor = mod.makeInProcessCryptor;
@@ -31,7 +31,7 @@ function inNextTick(f) {
31
31
  function makeInProcessCryptor() {
32
32
  const arrFactory = ecma_nacl_1.arrays.makeFactory();
33
33
  return {
34
- scrypt: (passwd, salt, logN, r, p, dkLen, progressCB) => inNextTick(() => ecma_nacl_1.scrypt(passwd, salt, logN, r, p, dkLen, progressCB, arrFactory)),
34
+ scrypt: (passwd, salt, logN, r, p, dkLen, progressCB) => inNextTick(() => (0, ecma_nacl_1.scrypt)(passwd, salt, logN, r, p, dkLen, progressCB, arrFactory)),
35
35
  box: {
36
36
  calc_dhshared_key: (pk, sk) => inNextTick(() => ecma_nacl_1.box.calc_dhshared_key(pk, sk, arrFactory)),
37
37
  generate_pubkey: sk => inNextTick(() => ecma_nacl_1.box.generate_pubkey(sk, arrFactory))
@@ -35,9 +35,9 @@ function wasmBytes() {
35
35
  const asarInd = __dirname.indexOf('app.asar');
36
36
  const dirWithThis = ((asarInd < 0) ?
37
37
  __dirname : `${__dirname.substring(0, asarInd + 8)}.unpacked${__dirname.substring(asarInd + 8)}`);
38
- const wasmPath = path_1.join(dirWithThis, 'cryptor.wasm');
38
+ const wasmPath = (0, path_1.join)(dirWithThis, 'cryptor.wasm');
39
39
  try {
40
- return fs_1.readFileSync(wasmPath);
40
+ return (0, fs_1.readFileSync)(wasmPath);
41
41
  }
42
42
  catch (err) {
43
43
  // chances are that error is due to wasm file not being packaged, so, we
@@ -65,7 +65,7 @@ const replyType = protobuf_type_1.ProtoType.for(cryptor_proto_1.cryptor.Reply);
65
65
  const boolValType = protobuf_type_1.ProtoType.for(cryptor_proto_1.cryptor.BoolVal);
66
66
  const kpairType = protobuf_type_1.ProtoType.for(cryptor_proto_1.cryptor.Keypair);
67
67
  function makeInProcessWasmCryptor() {
68
- const wasmInstance = wasm_mp1_modules_1.startWasmFrom(wasmBytes());
68
+ const wasmInstance = (0, wasm_mp1_modules_1.startWasmFrom)(wasmBytes());
69
69
  let deferred = undefined;
70
70
  let interimSink = undefined;
71
71
  async function call(req, interim) {
@@ -77,7 +77,7 @@ function makeInProcessWasmCryptor() {
77
77
  }
78
78
  catch (err) { }
79
79
  }
80
- deferred = deferred_1.defer();
80
+ deferred = (0, deferred_1.defer)();
81
81
  if (interim) {
82
82
  interimSink = interim;
83
83
  }
@@ -92,7 +92,7 @@ function makeInProcessWasmCryptor() {
92
92
  return deferred.promise;
93
93
  }
94
94
  wasmInstance.setMsgListener(msg => {
95
- assert_1.assert(!!deferred, `Deferred is expected to be available for this output from wasm`);
95
+ (0, assert_1.assert)(!!deferred, `Deferred is expected to be available for this output from wasm`);
96
96
  try {
97
97
  const reply = replyType.unpack(msg);
98
98
  if (reply.res) {
@@ -101,7 +101,7 @@ function makeInProcessWasmCryptor() {
101
101
  interimSink = undefined;
102
102
  }
103
103
  else if (reply.err) {
104
- deferred.reject(error_1.errWithCause(toLocalErr(reply.err), `Error in cryptor`));
104
+ deferred.reject((0, error_1.errWithCause)(toLocalErr(reply.err), `Error in cryptor`));
105
105
  deferred = undefined;
106
106
  interimSink = undefined;
107
107
  }
@@ -40,7 +40,7 @@ const funcs = {
40
40
  const reply = { interim: n };
41
41
  worker_threads_1.parentPort.postMessage(reply);
42
42
  };
43
- const res = ecma_nacl_1.scrypt(args[0], args[1], args[2], args[3], args[4], args[5], progressCB, arrFactory);
43
+ const res = (0, ecma_nacl_1.scrypt)(args[0], args[1], args[2], args[3], args[4], args[5], progressCB, arrFactory);
44
44
  wipe(args[0]);
45
45
  return { res };
46
46
  // electron v.11.0.3 worker thread fails on memory move
@@ -117,7 +117,7 @@ function wrapError(err) {
117
117
  }
118
118
  else {
119
119
  exc.message = `Error occured in cryptor worker thread`;
120
- exc.cause = error_1.stringifyErr(err);
120
+ exc.cause = (0, error_1.stringifyErr)(err);
121
121
  }
122
122
  return exc;
123
123
  }
@@ -24,8 +24,8 @@ if (!worker_threads_1.parentPort) {
24
24
  throw new Error(`Missing expected parentPort. Is this called within WebWorker process?`);
25
25
  }
26
26
  const wasmFName = 'cryptor.wasm';
27
- const wasmModPath = path_1.join(worker_threads_1.workerData.loadDir, wasmFName);
28
- const wasmInstance = wasm_mp1_modules_1.startWasmFrom(fs_1.readFileSync(wasmModPath));
27
+ const wasmModPath = (0, path_1.join)(worker_threads_1.workerData.loadDir, wasmFName);
28
+ const wasmInstance = (0, wasm_mp1_modules_1.startWasmFrom)((0, fs_1.readFileSync)(wasmModPath));
29
29
  wasmInstance.setMsgListener(msg => worker_threads_1.parentPort.postMessage(msg));
30
30
  worker_threads_1.parentPort.on('message', (msg) => {
31
31
  try {
@@ -22,7 +22,7 @@ async function selectInFS(fs, path, criteria) {
22
22
  // besides limiting fs to path, turning fs into readonly subroot ensures
23
23
  // that fs object is a wrapped view and doesn't leak internals,
24
24
  fs = await fs.readonlySubRoot(path);
25
- const items = fs_collection_1.makeFSCollection();
25
+ const items = (0, fs_collection_1.makeFSCollection)();
26
26
  const iterCB = (parentPath, entry) => {
27
27
  if (match(entry, criteria)) {
28
28
  if (criteria.action === 'include') {
@@ -1,10 +1,10 @@
1
1
  declare type FS = web3n.files.FS;
2
+ declare type FSType = web3n.files.FSType;
2
3
  declare type ReadonlyFS = web3n.files.ReadonlyFS;
3
4
  declare type WritableFS = web3n.files.WritableFS;
4
5
  declare type File = web3n.files.File;
5
6
  declare type ReadonlyFile = web3n.files.ReadonlyFile;
6
7
  declare type WritableFile = web3n.files.WritableFile;
7
- declare type FSType = web3n.files.FSType;
8
8
  export interface LinkParameters<T> {
9
9
  storageType: FSType;
10
10
  readonly?: boolean;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016 - 2018 3NSoft Inc.
3
+ Copyright (C) 2016 - 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
@@ -69,7 +69,24 @@ function wrapWritableFileVersionedAPI(vImpl) {
69
69
  readTxt: vImpl.readTxt.bind(vImpl),
70
70
  writeBytes: vImpl.writeBytes.bind(vImpl),
71
71
  writeJSON: vImpl.writeJSON.bind(vImpl),
72
- writeTxt: vImpl.writeTxt.bind(vImpl)
72
+ writeTxt: vImpl.writeTxt.bind(vImpl),
73
+ archiveCurrent: vImpl.archiveCurrent.bind(vImpl),
74
+ listVersions: vImpl.listVersions.bind(vImpl),
75
+ sync: wrapWritableFileSyncAPI(vImpl.sync)
76
+ };
77
+ return Object.freeze(w);
78
+ }
79
+ function wrapWritableFileSyncAPI(sImpl) {
80
+ if (!sImpl) {
81
+ return;
82
+ }
83
+ const w = {
84
+ status: sImpl.status.bind(sImpl),
85
+ updateStatusInfo: sImpl.updateStatusInfo.bind(sImpl),
86
+ download: sImpl.download.bind(sImpl),
87
+ isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
88
+ upload: sImpl.upload.bind(sImpl),
89
+ adoptRemote: sImpl.adoptRemote.bind(sImpl),
73
90
  };
74
91
  return Object.freeze(w);
75
92
  }
@@ -106,7 +123,22 @@ function wrapReadonlyFileVersionedAPI(vImpl) {
106
123
  getByteSource: vImpl.getByteSource.bind(vImpl),
107
124
  readBytes: vImpl.readBytes.bind(vImpl),
108
125
  readJSON: vImpl.readJSON.bind(vImpl),
109
- readTxt: vImpl.readTxt.bind(vImpl)
126
+ readTxt: vImpl.readTxt.bind(vImpl),
127
+ listVersions: vImpl.listVersions.bind(vImpl),
128
+ sync: wrapReadonlyFileSyncAPI(vImpl.sync)
129
+ };
130
+ return Object.freeze(w);
131
+ }
132
+ function wrapReadonlyFileSyncAPI(sImpl) {
133
+ if (!sImpl) {
134
+ return;
135
+ }
136
+ const w = {
137
+ status: sImpl.status.bind(sImpl),
138
+ updateStatusInfo: sImpl.updateStatusInfo.bind(sImpl),
139
+ download: sImpl.download.bind(sImpl),
140
+ isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
141
+ adoptRemote: sImpl.adoptRemote.bind(sImpl),
110
142
  };
111
143
  return Object.freeze(w);
112
144
  }
@@ -187,6 +219,25 @@ function wrapWritableFSVersionedAPI(vImpl) {
187
219
  readTxtFile: vImpl.readTxtFile.bind(vImpl),
188
220
  writeJSONFile: vImpl.writeJSONFile.bind(vImpl),
189
221
  writeTxtFile: vImpl.writeTxtFile.bind(vImpl),
222
+ archiveCurrent: vImpl.archiveCurrent.bind(vImpl),
223
+ listVersions: vImpl.listVersions.bind(vImpl),
224
+ sync: wrapWritableFSSyncAPI(vImpl.sync)
225
+ };
226
+ return Object.freeze(w);
227
+ }
228
+ function wrapWritableFSSyncAPI(sImpl) {
229
+ if (!sImpl) {
230
+ return;
231
+ }
232
+ const w = {
233
+ status: sImpl.status.bind(sImpl),
234
+ updateStatusInfo: sImpl.updateStatusInfo.bind(sImpl),
235
+ download: sImpl.download.bind(sImpl),
236
+ isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
237
+ adoptRemote: sImpl.adoptRemote.bind(sImpl),
238
+ diffCurrentAndRemoteFolderVersions: sImpl.diffCurrentAndRemoteFolderVersions.bind(sImpl),
239
+ upload: sImpl.upload.bind(sImpl),
240
+ adoptRemoteFolderItem: sImpl.adoptRemoteFolderItem.bind(sImpl),
190
241
  };
191
242
  return Object.freeze(w);
192
243
  }
@@ -230,7 +281,23 @@ function wrapReadonlyFSVersionedAPI(vImpl) {
230
281
  readBytes: vImpl.readBytes.bind(vImpl),
231
282
  listFolder: vImpl.listFolder.bind(vImpl),
232
283
  readJSONFile: vImpl.readJSONFile.bind(vImpl),
233
- readTxtFile: vImpl.readTxtFile.bind(vImpl)
284
+ readTxtFile: vImpl.readTxtFile.bind(vImpl),
285
+ listVersions: vImpl.listVersions.bind(vImpl),
286
+ sync: wrapReadonlyFSSyncAPI(vImpl.sync)
287
+ };
288
+ return Object.freeze(w);
289
+ }
290
+ function wrapReadonlyFSSyncAPI(sImpl) {
291
+ if (!sImpl) {
292
+ return;
293
+ }
294
+ const w = {
295
+ status: sImpl.status.bind(sImpl),
296
+ updateStatusInfo: sImpl.updateStatusInfo.bind(sImpl),
297
+ download: sImpl.download.bind(sImpl),
298
+ isRemoteVersionOnDisk: sImpl.isRemoteVersionOnDisk.bind(sImpl),
299
+ adoptRemote: sImpl.adoptRemote.bind(sImpl),
300
+ diffCurrentAndRemoteFolderVersions: sImpl.diffCurrentAndRemoteFolderVersions.bind(sImpl),
234
301
  };
235
302
  return Object.freeze(w);
236
303
  }
@@ -255,7 +322,6 @@ function wrapIntoVersionlessReadonlyFS(fs, type) {
255
322
  stat: async (path) => {
256
323
  const stats = await fs.stat(path);
257
324
  delete stats.version;
258
- delete stats.sync;
259
325
  return stats;
260
326
  },
261
327
  readonlyFile: async (path) => toVersionlessReadonlyFile(await fs.readonlyFile(path)),
@@ -292,7 +358,6 @@ function toVersionlessReadonlyFile(f) {
292
358
  stat: async () => {
293
359
  const stats = await f.stat();
294
360
  delete stats.version;
295
- delete stats.sync;
296
361
  return stats;
297
362
  },
298
363
  watch: f.watch.bind(f),
@@ -70,7 +70,7 @@ class FSItemsCollection {
70
70
  return allItems;
71
71
  }
72
72
  watch(observer) {
73
- const sub = this.change$.subscribe(utils_for_observables_1.toRxObserver(observer));
73
+ const sub = this.change$.subscribe((0, utils_for_observables_1.toRxObserver)(observer));
74
74
  return () => sub.unsubscribe();
75
75
  }
76
76
  wrap() {
@@ -0,0 +1,5 @@
1
+ declare type WritableFS = web3n.files.WritableFS;
2
+ export declare function getRemoteFolderChanges(fs: WritableFS): Promise<void>;
3
+ export declare function getOrMakeAndUploadFolderIn(fs: WritableFS, folder: string): Promise<WritableFS>;
4
+ export declare function uploadFolderChangesIfAny(fs: WritableFS): Promise<void>;
5
+ export {};
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2022 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
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/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.uploadFolderChangesIfAny = exports.getOrMakeAndUploadFolderIn = exports.getRemoteFolderChanges = void 0;
20
+ const exceptions_1 = require("./3nstorage/exceptions");
21
+ async function getRemoteFolderChanges(fs) {
22
+ const { state } = await fs.v.sync.updateStatusInfo('');
23
+ if (state === 'behind') {
24
+ await fs.v.sync.adoptRemote('');
25
+ }
26
+ else if (state === 'conflicting') {
27
+ const path = ((typeof fs.name === 'string') ? fs.name : '');
28
+ throw (0, exceptions_1.makeFSSyncException)(path, {
29
+ conflict: true,
30
+ message: `Getting remote changes can't settle conflict in this function`
31
+ });
32
+ }
33
+ }
34
+ exports.getRemoteFolderChanges = getRemoteFolderChanges;
35
+ async function getOrMakeAndUploadFolderIn(fs, folder) {
36
+ try {
37
+ const childFolder = await fs.writableSubRoot(folder, { create: false });
38
+ return childFolder;
39
+ }
40
+ catch (exc) {
41
+ if ((exc.type === 'file')
42
+ && exc.notFound) {
43
+ const childFolder = await fs.writableSubRoot(folder);
44
+ await fs.v.sync.upload(folder);
45
+ return childFolder;
46
+ }
47
+ else {
48
+ throw exc;
49
+ }
50
+ }
51
+ }
52
+ exports.getOrMakeAndUploadFolderIn = getOrMakeAndUploadFolderIn;
53
+ async function uploadFolderChangesIfAny(fs) {
54
+ const { state } = await fs.v.sync.updateStatusInfo('');
55
+ if ((state === 'synced') || (state === 'behind')) {
56
+ return;
57
+ }
58
+ await fs.v.sync.upload('');
59
+ }
60
+ exports.uploadFolderChangesIfAny = uploadFolderChangesIfAny;
61
+ Object.freeze(exports);
@@ -0,0 +1,14 @@
1
+ declare type ReadonlyFS = web3n.files.ReadonlyFS;
2
+ declare type WritableFS = web3n.files.WritableFS;
3
+ declare type WritableFile = web3n.files.WritableFile;
4
+ export interface FSReadView extends ReadonlyFS {
5
+ }
6
+ export interface FSWriteView extends WritableFS {
7
+ rollbackWrite(): Promise<void>;
8
+ }
9
+ export declare type FSWrite = FSReadView | FSWriteView;
10
+ export interface FileWriteView extends WritableFile {
11
+ rollbackWrite(): Promise<void>;
12
+ }
13
+ export declare function readonlyFSView(fs: ReadonlyFS, state: any): Promise<FSReadView>;
14
+ export {};
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2022 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
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/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.readonlyFSView = void 0;
20
+ async function readonlyFSView(fs, state) {
21
+ // XXX
22
+ // Notes:
23
+ // - state info with objId->version can't expose objId to user here,
24
+ // keeping it on core's side.
25
+ // ! Hiding objId is incompatible with idea of having syncWall info
26
+ // accessible, if/when objId is used in it.
27
+ // - Map path->num-id-within-given-sync-wall
28
+ // - When anything is changed within FSWriteView, it is added to map,
29
+ // as being part of sync wall.
30
+ throw new Error('Function not implemented.');
31
+ }
32
+ exports.readonlyFSView = readonlyFSView;
33
+ Object.freeze(exports);
@@ -46,7 +46,7 @@ async function deriveMidKeyPair(cryptor, pass, derivParams, progressCB, use = ''
46
46
  const saltBytes = buffer_utils_1.base64.open(derivParams.salt);
47
47
  const skey = await cryptor.scrypt(passBytes, saltBytes, derivParams.logN, derivParams.r, derivParams.p, ecma_nacl_1.box.KEY_LENGTH, progressCB);
48
48
  const pkey = await cryptor.box.generate_pubkey(skey);
49
- const pkeyJSON = jwkeys_1.keyToJson({
49
+ const pkeyJSON = (0, jwkeys_1.keyToJson)({
50
50
  k: pkey,
51
51
  alg: ecma_nacl_1.box.JWK_ALG_NAME,
52
52
  use: use,
@@ -29,9 +29,9 @@ class DevFileByteSink {
29
29
  Object.seal(this);
30
30
  }
31
31
  static make(path, pathPrefixMaskLen, stat) {
32
- assert_1.assert(Number.isInteger(stat.size) && (stat.size >= 0));
32
+ (0, assert_1.assert)(Number.isInteger(stat.size) && (stat.size >= 0));
33
33
  const sink = new DevFileByteSink(path, pathPrefixMaskLen, stat.size);
34
- return wrapping_1.wrapAndSyncFileSink(sink);
34
+ return (0, wrapping_1.wrapAndSyncFileSink)(sink);
35
35
  }
36
36
  async done() { }
37
37
  async getSize() {
@@ -44,12 +44,12 @@ class DevFileByteSink {
44
44
  };
45
45
  }
46
46
  async truncate(size) {
47
- assert_1.assert(Number.isInteger(size) && (size >= 0), `Invalid parameters given`);
47
+ (0, assert_1.assert)(Number.isInteger(size) && (size >= 0), `Invalid parameters given`);
48
48
  await fs.truncate(this.path, size);
49
49
  this.size = size;
50
50
  }
51
51
  async splice(pos, del, bytes) {
52
- assert_1.assert(Number.isInteger(pos) && (pos >= 0)
52
+ (0, assert_1.assert)(Number.isInteger(pos) && (pos >= 0)
53
53
  && Number.isInteger(del) && (del >= 0), `Invalid parameters given`);
54
54
  const ins = (bytes ? bytes.length : 0);
55
55
  if ((del === 0) && (ins === 0)) {
@@ -74,10 +74,10 @@ class DevFileByteSink {
74
74
  let fd = undefined;
75
75
  try {
76
76
  fd = await fs.open(this.path, 'r+');
77
- await fs.writeFromBuf(fd, pos, buffer_utils_1.toBuffer(bytes));
77
+ await fs.writeFromBuf(fd, pos, (0, buffer_utils_1.toBuffer)(bytes));
78
78
  }
79
79
  catch (e) {
80
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
80
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
81
81
  }
82
82
  finally {
83
83
  if (fd !== undefined) {
@@ -89,7 +89,7 @@ class DevFileByteSink {
89
89
  if (delta === 0) {
90
90
  return;
91
91
  }
92
- assert_1.assert(Number.isInteger(pos) && (pos >= 0)
92
+ (0, assert_1.assert)(Number.isInteger(pos) && (pos >= 0)
93
93
  && Number.isInteger(delta) && Number.isInteger(initFileLen)
94
94
  && (pos <= initFileLen), `Invalid parameters given`);
95
95
  if (delta > 0) {
@@ -120,7 +120,7 @@ class DevFileByteSink {
120
120
  }
121
121
  }
122
122
  catch (e) {
123
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
123
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
124
124
  }
125
125
  finally {
126
126
  if (fd !== undefined) {
@@ -149,7 +149,7 @@ class DevFileByteSink {
149
149
  await fs.ftruncate(fd, pos + bytesToMove);
150
150
  }
151
151
  catch (e) {
152
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
152
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
153
153
  }
154
154
  finally {
155
155
  if (fd !== undefined) {
@@ -29,7 +29,7 @@ class DevFileByteSource {
29
29
  }
30
30
  static make(path, pathPrefixMaskLen, stat) {
31
31
  const src = new DevFileByteSource(path, pathPrefixMaskLen, stat);
32
- return wrapping_1.wrapAndSyncSource(src);
32
+ return (0, wrapping_1.wrapAndSyncSource)(src);
33
33
  }
34
34
  async getSize() {
35
35
  return { size: this.size, isEndless: false };
@@ -54,7 +54,7 @@ class DevFileByteSource {
54
54
  return buf;
55
55
  }
56
56
  catch (e) {
57
- throw file_1.maskPathInExc(this.pathPrefixMaskLen, e);
57
+ throw (0, file_1.maskPathInExc)(this.pathPrefixMaskLen, e);
58
58
  }
59
59
  finally {
60
60
  if (fd !== undefined) {
@@ -81,7 +81,7 @@ export declare class DeviceFS implements WritableFS, Linkable {
81
81
  writableFile(path: string, flags?: web3n.files.FileFlags): Promise<WritableFile>;
82
82
  watchFolder(path: string, observer: Observer<FolderEvent>): () => void;
83
83
  watchFile(path: string, observer: Observer<FileEvent>): () => void;
84
- watchTree(path: string, observer: Observer<FolderEvent | FileEvent>): () => void;
84
+ watchTree(path: string, depth: number | undefined, observer: Observer<FolderEvent | FileEvent>): () => void;
85
85
  copyFile(src: string, dst: string, overwrite?: boolean): Promise<void>;
86
86
  copyFolder(src: string, dst: string, mergeAndOverwrite?: boolean): Promise<void>;
87
87
  saveFile(file: File, dst: string, overwrite?: boolean): Promise<void>;