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
@@ -23,16 +23,16 @@ var headerChunkInfo;
23
23
  (function (headerChunkInfo) {
24
24
  function toBytes(hInfo) {
25
25
  const buf = Buffer.allocUnsafe(12);
26
- big_endian_1.packUintTo4Bytes(hInfo.len, buf, 0);
27
- big_endian_1.packUintTo8Bytes(hInfo.fileOfs, buf, 4);
26
+ (0, big_endian_1.packUintTo4Bytes)(hInfo.len, buf, 0);
27
+ (0, big_endian_1.packUintTo8Bytes)(hInfo.fileOfs, buf, 4);
28
28
  return buf;
29
29
  }
30
30
  headerChunkInfo.toBytes = toBytes;
31
31
  function fromBytes(b, i) {
32
32
  let bytesRead = 0;
33
- const len = big_endian_1.uintFrom4Bytes(b, i + bytesRead);
33
+ const len = (0, big_endian_1.uintFrom4Bytes)(b, i + bytesRead);
34
34
  bytesRead += 4;
35
- const fileOfs = big_endian_1.uintFrom8Bytes(b, i + bytesRead);
35
+ const fileOfs = (0, big_endian_1.uintFrom8Bytes)(b, i + bytesRead);
36
36
  bytesRead += 8;
37
37
  const hInfo = { len, fileOfs };
38
38
  return { hInfo: Object.freeze(hInfo), bytesRead };
@@ -60,18 +60,18 @@ var segsChunkInfo;
60
60
  let i = 0;
61
61
  buf[i] = flag;
62
62
  i += 1;
63
- big_endian_1.packUintTo8Bytes(sInfo.thisVerOfs, buf, i);
63
+ (0, big_endian_1.packUintTo8Bytes)(sInfo.thisVerOfs, buf, i);
64
64
  i += 8;
65
65
  if (sInfo.type !== 'new-endless') {
66
- big_endian_1.packUintTo8Bytes(sInfo.len, buf, 9);
66
+ (0, big_endian_1.packUintTo8Bytes)(sInfo.len, buf, 9);
67
67
  i += 8;
68
68
  }
69
69
  if ((sInfo.type === 'new-on-disk') || (sInfo.type === 'base-on-disk')) {
70
- big_endian_1.packUintTo8Bytes(sInfo.fileOfs, buf, i);
70
+ (0, big_endian_1.packUintTo8Bytes)(sInfo.fileOfs, buf, i);
71
71
  i += 8;
72
72
  }
73
73
  if ((sInfo.type === 'base') || (sInfo.type === 'base-on-disk')) {
74
- big_endian_1.packUintTo8Bytes(sInfo.baseVerOfs, buf, i);
74
+ (0, big_endian_1.packUintTo8Bytes)(sInfo.baseVerOfs, buf, i);
75
75
  }
76
76
  return buf;
77
77
  }
@@ -80,21 +80,21 @@ var segsChunkInfo;
80
80
  let bytesRead = 0;
81
81
  const flag = b[i + bytesRead];
82
82
  bytesRead += 1;
83
- const thisVerOfs = big_endian_1.uintFrom8Bytes(b, i + bytesRead);
83
+ const thisVerOfs = (0, big_endian_1.uintFrom8Bytes)(b, i + bytesRead);
84
84
  bytesRead += 8;
85
85
  let len = undefined;
86
86
  if ((flag & IS_ENDLESS_BITMASK) === 0) {
87
- len = big_endian_1.uintFrom8Bytes(b, i + bytesRead);
87
+ len = (0, big_endian_1.uintFrom8Bytes)(b, i + bytesRead);
88
88
  bytesRead += 8;
89
89
  }
90
90
  let fileOfs = undefined;
91
91
  if (flag & FILE_OFS_PRESENT_BITMASK) {
92
- fileOfs = big_endian_1.uintFrom8Bytes(b, i + bytesRead);
92
+ fileOfs = (0, big_endian_1.uintFrom8Bytes)(b, i + bytesRead);
93
93
  bytesRead += 8;
94
94
  }
95
95
  let baseVerOfs = undefined;
96
96
  if (flag & BASE_VER_OFS_PRESENT_BITMASK) {
97
- baseVerOfs = big_endian_1.uintFrom8Bytes(b, i + bytesRead);
97
+ baseVerOfs = (0, big_endian_1.uintFrom8Bytes)(b, i + bytesRead);
98
98
  bytesRead += 8;
99
99
  }
100
100
  const isOnDisk = (fileOfs !== undefined);
@@ -168,7 +168,7 @@ var layoutV1;
168
168
  if (a.baseVersion !== undefined) {
169
169
  flag |= BASE_PRESENT_BITMASK;
170
170
  baseBytes = Buffer.allocUnsafe(8);
171
- big_endian_1.packUintTo8Bytes(a.baseVersion, baseBytes, 0);
171
+ (0, big_endian_1.packUintTo8Bytes)(a.baseVersion, baseBytes, 0);
172
172
  if (a.allBaseBytesInFile) {
173
173
  flag |= ALL_BASE_BYTES_IN_FILE_BITMASK;
174
174
  }
@@ -214,7 +214,7 @@ var layoutV1;
214
214
  i += 1;
215
215
  let baseVersion = undefined;
216
216
  if (flag & BASE_PRESENT_BITMASK) {
217
- baseVersion = big_endian_1.uintFrom8Bytes(b, i);
217
+ baseVersion = (0, big_endian_1.uintFrom8Bytes)(b, i);
218
218
  i += 8;
219
219
  }
220
220
  let headerChunk = undefined;
@@ -10,7 +10,7 @@ declare class ProcessingPool<PoolLabel extends string> {
10
10
  private readonly inProcess;
11
11
  private readonly queue;
12
12
  isRunning: boolean;
13
- constructor(label: PoolLabel, maxProcs: number, logError?: ((err: any, msg?: string | undefined) => Promise<void>) | undefined);
13
+ constructor(label: PoolLabel, maxProcs: number, logError?: ((err: any, msg?: string) => Promise<void>) | undefined);
14
14
  add(task: Task<any>): void;
15
15
  private processNextQueued;
16
16
  pause(): void;
@@ -92,7 +92,7 @@ class LabelledExecPools {
92
92
  constructor(setup, logError) {
93
93
  this.pools = new Map();
94
94
  this.isRunning = false;
95
- assert_1.assert(setup.length > 0);
95
+ (0, assert_1.assert)(setup.length > 0);
96
96
  for (const { label, maxProcs } of setup) {
97
97
  const pool = new ProcessingPool(label, maxProcs, logError);
98
98
  this.pools.set(pool.label, pool);
@@ -35,7 +35,7 @@ class PressureValve {
35
35
  if (this.stopper) {
36
36
  return;
37
37
  }
38
- this.stopper = deferred_1.defer();
38
+ this.stopper = (0, deferred_1.defer)();
39
39
  }
40
40
  else {
41
41
  if (!this.stopper) {
@@ -47,7 +47,7 @@ class PressureValve {
47
47
  }
48
48
  pressWithError(err) {
49
49
  this.toggle(true);
50
- this.stopper.reject(error_1.errWithCause(err, `Backpressure error`));
50
+ this.stopper.reject((0, error_1.errWithCause)(err, `Backpressure error`));
51
51
  }
52
52
  }
53
53
  exports.PressureValve = PressureValve;
@@ -149,7 +149,7 @@ class SingleProc {
149
149
  }
150
150
  }
151
151
  startOrChain(action) {
152
- const deferred = deferred_1.defer();
152
+ const deferred = (0, deferred_1.defer)();
153
153
  this.actions.push({ action, deferred });
154
154
  this.runIfIdle();
155
155
  return deferred.promise;
@@ -21,7 +21,7 @@ const deferred_1 = require("./deferred");
21
21
  const sleep_1 = require("./sleep");
22
22
  function callWithTimeout(f, timeout, timeoutErr) {
23
23
  let isDone = false;
24
- const deferred = deferred_1.defer();
24
+ const deferred = (0, deferred_1.defer)();
25
25
  f().then(res => {
26
26
  if (isDone) {
27
27
  return;
@@ -35,7 +35,7 @@ function callWithTimeout(f, timeout, timeoutErr) {
35
35
  isDone = true;
36
36
  deferred.reject(err);
37
37
  });
38
- sleep_1.sleep(timeout).then(() => {
38
+ (0, sleep_1.sleep)(timeout).then(() => {
39
39
  if (isDone) {
40
40
  return;
41
41
  }
@@ -19,11 +19,11 @@ exports.stringOfB64Chars = exports.stringOfB64UrlSafeChars = exports.stringOfB64
19
19
  const buffer_utils_1 = require("./buffer-utils");
20
20
  const crypto_1 = require("crypto");
21
21
  function bytesSync(numOfBytes) {
22
- return crypto_1.randomBytes(numOfBytes);
22
+ return (0, crypto_1.randomBytes)(numOfBytes);
23
23
  }
24
24
  exports.bytesSync = bytesSync;
25
25
  function bytes(numOfBytes) {
26
- return new Promise((res, rej) => crypto_1.randomBytes(numOfBytes, (err, buf) => {
26
+ return new Promise((res, rej) => (0, crypto_1.randomBytes)(numOfBytes, (err, buf) => {
27
27
  if (err) {
28
28
  rej(err);
29
29
  }
@@ -34,15 +34,15 @@ function bytes(numOfBytes) {
34
34
  }
35
35
  exports.bytes = bytes;
36
36
  function uint8Sync() {
37
- return crypto_1.randomBytes(1)[0];
37
+ return (0, crypto_1.randomBytes)(1)[0];
38
38
  }
39
39
  exports.uint8Sync = uint8Sync;
40
40
  async function uint8() {
41
- return (await crypto_1.randomBytes(1))[0];
41
+ return (await (0, crypto_1.randomBytes)(1))[0];
42
42
  }
43
43
  exports.uint8 = uint8;
44
44
  function uint48Sync() {
45
- const b = crypto_1.randomBytes(6);
45
+ const b = (0, crypto_1.randomBytes)(6);
46
46
  const l = b[0] + (b[1] << 8) + (b[2] << 16) + (b[3] << 24);
47
47
  const h = b[4] + (b[5] << 8);
48
48
  return h * 0x100000000 + l;
@@ -57,13 +57,13 @@ async function uint48() {
57
57
  exports.uint48 = uint48;
58
58
  function stringOfB64UrlSafeCharsSync(numOfChars) {
59
59
  const numOfbytes = 3 * (1 + Math.floor(numOfChars / 4));
60
- const byteArr = crypto_1.randomBytes(numOfbytes);
60
+ const byteArr = (0, crypto_1.randomBytes)(numOfbytes);
61
61
  return buffer_utils_1.base64urlSafe.pack(byteArr).substring(0, numOfChars);
62
62
  }
63
63
  exports.stringOfB64UrlSafeCharsSync = stringOfB64UrlSafeCharsSync;
64
64
  function stringOfB64CharsSync(numOfChars) {
65
65
  const numOfbytes = 3 * (1 + Math.floor(numOfChars / 4));
66
- return crypto_1.randomBytes(numOfbytes).toString('base64').substring(0, numOfChars);
66
+ return (0, crypto_1.randomBytes)(numOfbytes).toString('base64').substring(0, numOfChars);
67
67
  }
68
68
  exports.stringOfB64CharsSync = stringOfB64CharsSync;
69
69
  async function stringOfB64UrlSafeChars(numOfChars) {
@@ -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
  */
@@ -109,6 +105,7 @@ export interface PutObjSecondQueryOpts {
109
105
  export declare namespace currentObj {
110
106
  const EXPRESS_URL_END = "obj/:objId/current";
111
107
  function getReqUrlEnd(objId: string, opts?: GetObjQueryOpts): string;
108
+ function delReqUrlEnd(objId: string, ver?: number): string;
112
109
  function firstPutReqUrlEnd(objId: string, opts: PutObjFirstQueryOpts): string;
113
110
  function secondPutReqUrlEnd(objId: string, opts: PutObjSecondQueryOpts): string;
114
111
  interface ReplyToPut {
@@ -131,9 +128,10 @@ export declare namespace currentObj {
131
128
  mismatchedObjVer: number;
132
129
  objIncomplete: number;
133
130
  };
134
- interface MismatchedObjVerReply extends ErrorReply {
135
- current_version: number;
136
- }
131
+ type MismatchedObjVerReply = MismatchedObjVerErrReply;
132
+ }
133
+ export interface MismatchedObjVerErrReply extends ErrorReply {
134
+ current_version: number;
137
135
  }
138
136
  export declare namespace currentRootObj {
139
137
  const EXPRESS_URL_END = "root/current";
@@ -157,24 +155,20 @@ export declare namespace currentRootObj {
157
155
  }
158
156
  export declare namespace archivedObjVersion {
159
157
  const EXPRESS_URL_END = "/obj/:objId/archived";
160
- function getReqUrlEnd(objId: string, version: number, opts?: GetObjQueryOpts): string;
158
+ function getReqUrlEnd(objId: string, opts: GetObjQueryOpts): string;
161
159
  const SC: {
162
160
  okGet: number;
163
- okDelete: number;
164
- missing: number;
165
- concurrentTransaction: number;
166
- incompatibleObjState: number;
161
+ unknownObj: number;
162
+ unknownObjVer: number;
167
163
  };
168
164
  }
169
165
  export declare namespace archivedRootVersion {
170
166
  const EXPRESS_URL_END = "root/archived";
171
- function getReqUrlEnd(version: number, opts?: GetObjQueryOpts): string;
167
+ function getReqUrlEnd(opts: GetObjQueryOpts): string;
172
168
  const SC: {
173
169
  okGet: number;
174
- okDelete: number;
175
- missing: number;
176
- concurrentTransaction: number;
177
- incompatibleObjState: number;
170
+ unknownObj: number;
171
+ unknownObjVer: number;
178
172
  };
179
173
  }
180
174
  export interface DiffInfo {
@@ -218,21 +212,50 @@ export declare namespace cancelRootTransaction {
218
212
  missing: number;
219
213
  };
220
214
  }
215
+ export interface ObjStatus {
216
+ current?: number;
217
+ archived?: number[];
218
+ }
219
+ export declare namespace objStatus {
220
+ const EXPRESS_URL_END = "obj/:objId/status";
221
+ function getReqUrlEnd(objId: string): string;
222
+ type Reply = ObjStatus;
223
+ const SC: {
224
+ ok: number;
225
+ unknownObj: number;
226
+ };
227
+ }
228
+ export declare namespace rootStatus {
229
+ const EXPRESS_URL_END = "root/status";
230
+ function getReqUrlEnd(): string;
231
+ type Reply = ObjStatus;
232
+ const SC: {
233
+ ok: number;
234
+ unknownObj: number;
235
+ };
236
+ }
221
237
  export declare namespace archiveObj {
222
238
  const EXPRESS_URL_END = "obj/:objId/archive";
223
- function getReqUrlEnd(objId: string): string;
239
+ function postAndDelReqUrlEnd(objId: string, version: number): string;
240
+ type MismatchedObjVerReply = MismatchedObjVerErrReply;
224
241
  const SC: {
225
- okGet: number;
226
- okPut: number;
227
- missing: number;
242
+ okPost: number;
243
+ okDelete: number;
244
+ unknownObj: number;
245
+ unknownObjVer: number;
246
+ mismatchedObjVer: number;
228
247
  };
229
248
  }
230
249
  export declare namespace archiveRoot {
231
- const URL_END = "root/archive";
250
+ const EXPRESS_URL_END = "root/archive";
251
+ function postAndDelReqUrlEnd(version: number): string;
252
+ type MismatchedObjVerReply = archiveObj.MismatchedObjVerReply;
232
253
  const SC: {
233
- okGet: number;
234
- okPut: number;
235
- missing: number;
254
+ okPost: number;
255
+ okDelete: number;
256
+ unknownObj: number;
257
+ unknownObjVer: number;
258
+ mismatchedObjVer: number;
236
259
  };
237
260
  }
238
261
  export interface ErrorReply {
@@ -244,23 +267,59 @@ export declare namespace wsEventChannel {
244
267
  ok: number;
245
268
  };
246
269
  }
247
- export declare namespace objChanged {
248
- const EVENT_NAME = "obj-changed";
249
- interface Event {
250
- /**
251
- * This indentifies a non-root object by its string id, while null value
252
- * identifies root object.
253
- */
254
- objId: string | null;
255
- newVer: number;
270
+ export declare namespace events {
271
+ namespace objChanged {
272
+ const EVENT_NAME = "obj-changed";
273
+ interface Event {
274
+ /**
275
+ * This indentifies a non-root object by its string id, while null
276
+ * value identifies root object.
277
+ */
278
+ objId: string | null;
279
+ /**
280
+ * New current version on the server.
281
+ */
282
+ newVer: number;
283
+ }
256
284
  }
257
- }
258
- export declare namespace objRemoved {
259
- const EVENT_NAME = "obj-removed";
260
- interface Event {
261
- /**
262
- * This indentifies a removed non-root object by its string id.
263
- */
264
- objId: string;
285
+ namespace objRemoved {
286
+ const EVENT_NAME = "obj-removed";
287
+ interface Event {
288
+ /**
289
+ * This indentifies a removed non-root object by its string id.
290
+ */
291
+ objId: string;
292
+ }
293
+ }
294
+ namespace objVersionArchived {
295
+ const EVENT_NAME = "obj-ver-archived";
296
+ interface Event {
297
+ /**
298
+ * This indentifies a non-root object by its string id, while null
299
+ * value identifies root object.
300
+ */
301
+ objId: string | null;
302
+ /**
303
+ * Version that was set archived on the server.
304
+ */
305
+ archivedVer: number;
306
+ }
307
+ }
308
+ namespace objArchivedVersionRemoved {
309
+ const EVENT_NAME = "obj-ver-removed";
310
+ interface Event {
311
+ /**
312
+ * This indentifies a non-root object by its string id, while null
313
+ * value identifies root object.
314
+ */
315
+ objId: string | null;
316
+ /**
317
+ * Archived version that was removed on the server.
318
+ */
319
+ archivedVer: number;
320
+ }
265
321
  }
322
+ const all: string[];
323
+ type EventNameType = (typeof objChanged.EVENT_NAME) | (typeof objRemoved.EVENT_NAME) | (typeof objVersionArchived.EVENT_NAME) | (typeof objArchivedVersionRemoved.EVENT_NAME);
324
+ type AllTypes = objChanged.Event | objRemoved.Event | objVersionArchived.Event | objArchivedVersionRemoved.Event;
266
325
  }
@@ -16,7 +16,7 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.objRemoved = exports.objChanged = exports.wsEventChannel = exports.archiveRoot = exports.archiveObj = exports.cancelRootTransaction = exports.cancelTransaction = exports.addDiffSectionTo = exports.sanitizedDiff = exports.archivedRootVersion = exports.archivedObjVersion = exports.currentRootObj = exports.currentObj = exports.keyDerivParams = exports.PARAM_SC = exports.sessionParams = exports.closeSession = exports.midLogin = exports.BIN_TYPE = exports.HTTP_HEADER = exports.ERR_SC = void 0;
19
+ exports.events = exports.wsEventChannel = exports.archiveRoot = exports.archiveObj = exports.rootStatus = exports.objStatus = exports.cancelRootTransaction = exports.cancelTransaction = exports.addDiffSectionTo = exports.sanitizedDiff = exports.archivedRootVersion = exports.archivedObjVersion = exports.currentRootObj = exports.currentObj = exports.keyDerivParams = exports.PARAM_SC = exports.sessionParams = exports.closeSession = exports.midLogin = exports.BIN_TYPE = exports.HTTP_HEADER = exports.ERR_SC = void 0;
20
20
  /**
21
21
  * This defines interfaces for 3nstorage owner's requests.
22
22
  */
@@ -76,15 +76,19 @@ var currentObj;
76
76
  (function (currentObj) {
77
77
  currentObj.EXPRESS_URL_END = 'obj/:objId/current';
78
78
  function getReqUrlEnd(objId, opts) {
79
- return `obj/${objId}/current${opts ? `?${querystring_1.stringify(opts)}` : ''}`;
79
+ return `obj/${objId}/current${opts ? `?${(0, querystring_1.stringify)(opts)}` : ''}`;
80
80
  }
81
81
  currentObj.getReqUrlEnd = getReqUrlEnd;
82
+ function delReqUrlEnd(objId, ver) {
83
+ return `obj/${objId}/current${ver ? `?${(0, querystring_1.stringify)({ ver })}` : ''}`;
84
+ }
85
+ currentObj.delReqUrlEnd = delReqUrlEnd;
82
86
  function firstPutReqUrlEnd(objId, opts) {
83
- return `obj/${objId}/current?${querystring_1.stringify(opts)}`;
87
+ return `obj/${objId}/current?${(0, querystring_1.stringify)(opts)}`;
84
88
  }
85
89
  currentObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
86
90
  function secondPutReqUrlEnd(objId, opts) {
87
- return `obj/${objId}/current?${querystring_1.stringify(opts)}`;
91
+ return `obj/${objId}/current?${(0, querystring_1.stringify)(opts)}`;
88
92
  }
89
93
  currentObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
90
94
  currentObj.SC = {
@@ -106,15 +110,15 @@ var currentRootObj;
106
110
  (function (currentRootObj) {
107
111
  currentRootObj.EXPRESS_URL_END = 'root/current';
108
112
  function getReqUrlEnd(opts) {
109
- return `root/current${opts ? `?${querystring_1.stringify(opts)}` : ''}`;
113
+ return `root/current${opts ? `?${(0, querystring_1.stringify)(opts)}` : ''}`;
110
114
  }
111
115
  currentRootObj.getReqUrlEnd = getReqUrlEnd;
112
116
  function firstPutReqUrlEnd(opts) {
113
- return `root/current?${querystring_1.stringify(opts)}`;
117
+ return `root/current?${(0, querystring_1.stringify)(opts)}`;
114
118
  }
115
119
  currentRootObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
116
120
  function secondPutReqUrlEnd(opts) {
117
- return `root/current?${querystring_1.stringify(opts)}`;
121
+ return `root/current?${(0, querystring_1.stringify)(opts)}`;
118
122
  }
119
123
  currentRootObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
120
124
  currentRootObj.SC = currentObj.SC;
@@ -123,32 +127,22 @@ Object.freeze(currentRootObj);
123
127
  var archivedObjVersion;
124
128
  (function (archivedObjVersion) {
125
129
  archivedObjVersion.EXPRESS_URL_END = '/obj/:objId/archived';
126
- function getReqUrlEnd(objId, version, opts) {
127
- if (opts) {
128
- opts.ver = version;
129
- }
130
- const query = (opts ? `?${querystring_1.stringify(opts)}` : '');
131
- return `/obj/${objId}/archived${query}`;
130
+ function getReqUrlEnd(objId, opts) {
131
+ return `/obj/${objId}/archived?${(0, querystring_1.stringify)(opts)}`;
132
132
  }
133
133
  archivedObjVersion.getReqUrlEnd = getReqUrlEnd;
134
134
  archivedObjVersion.SC = {
135
135
  okGet: 200,
136
- okDelete: 200,
137
- missing: 474,
138
- concurrentTransaction: 483,
139
- incompatibleObjState: 484
136
+ unknownObj: 474,
137
+ unknownObjVer: 494
140
138
  };
141
139
  })(archivedObjVersion = exports.archivedObjVersion || (exports.archivedObjVersion = {}));
142
140
  Object.freeze(archivedObjVersion);
143
141
  var archivedRootVersion;
144
142
  (function (archivedRootVersion) {
145
143
  archivedRootVersion.EXPRESS_URL_END = 'root/archived';
146
- function getReqUrlEnd(version, opts) {
147
- if (opts) {
148
- opts.ver = version;
149
- }
150
- const query = (opts ? `?${querystring_1.stringify(opts)}` : '');
151
- return `root/archived${query}`;
144
+ function getReqUrlEnd(opts) {
145
+ return `root/archived?${(0, querystring_1.stringify)(opts)}`;
152
146
  }
153
147
  archivedRootVersion.getReqUrlEnd = getReqUrlEnd;
154
148
  archivedRootVersion.SC = archivedObjVersion.SC;
@@ -230,23 +224,52 @@ var cancelRootTransaction;
230
224
  cancelRootTransaction.SC = cancelTransaction.SC;
231
225
  })(cancelRootTransaction = exports.cancelRootTransaction || (exports.cancelRootTransaction = {}));
232
226
  Object.freeze(cancelRootTransaction);
227
+ var objStatus;
228
+ (function (objStatus) {
229
+ objStatus.EXPRESS_URL_END = 'obj/:objId/status';
230
+ function getReqUrlEnd(objId) {
231
+ return `obj/${objId}/status`;
232
+ }
233
+ objStatus.getReqUrlEnd = getReqUrlEnd;
234
+ objStatus.SC = {
235
+ ok: 200,
236
+ unknownObj: 474,
237
+ };
238
+ })(objStatus = exports.objStatus || (exports.objStatus = {}));
239
+ Object.freeze(objStatus);
240
+ var rootStatus;
241
+ (function (rootStatus) {
242
+ rootStatus.EXPRESS_URL_END = 'root/status';
243
+ function getReqUrlEnd() {
244
+ return 'root/status';
245
+ }
246
+ rootStatus.getReqUrlEnd = getReqUrlEnd;
247
+ rootStatus.SC = objStatus.SC;
248
+ })(rootStatus = exports.rootStatus || (exports.rootStatus = {}));
249
+ Object.freeze(rootStatus);
233
250
  var archiveObj;
234
251
  (function (archiveObj) {
235
252
  archiveObj.EXPRESS_URL_END = 'obj/:objId/archive';
236
- function getReqUrlEnd(objId) {
237
- return `obj/${objId}/archive`;
253
+ function postAndDelReqUrlEnd(objId, version) {
254
+ return `obj/${objId}/archive?ver=${version}`;
238
255
  }
239
- archiveObj.getReqUrlEnd = getReqUrlEnd;
256
+ archiveObj.postAndDelReqUrlEnd = postAndDelReqUrlEnd;
240
257
  archiveObj.SC = {
241
- okGet: 200,
242
- okPut: 201,
243
- missing: 474
258
+ okPost: 200,
259
+ okDelete: 200,
260
+ unknownObj: 474,
261
+ unknownObjVer: 494,
262
+ mismatchedObjVer: 495
244
263
  };
245
264
  })(archiveObj = exports.archiveObj || (exports.archiveObj = {}));
246
265
  Object.freeze(archiveObj);
247
266
  var archiveRoot;
248
267
  (function (archiveRoot) {
249
- archiveRoot.URL_END = 'root/archive';
268
+ archiveRoot.EXPRESS_URL_END = 'root/archive';
269
+ function postAndDelReqUrlEnd(version) {
270
+ return `root/archive?ver=${version}`;
271
+ }
272
+ archiveRoot.postAndDelReqUrlEnd = postAndDelReqUrlEnd;
250
273
  archiveRoot.SC = archiveObj.SC;
251
274
  })(archiveRoot = exports.archiveRoot || (exports.archiveRoot = {}));
252
275
  Object.freeze(archiveRoot);
@@ -259,14 +282,34 @@ var wsEventChannel;
259
282
  Object.freeze(wsEventChannel.SC);
260
283
  })(wsEventChannel = exports.wsEventChannel || (exports.wsEventChannel = {}));
261
284
  Object.freeze(wsEventChannel);
262
- var objChanged;
263
- (function (objChanged) {
264
- objChanged.EVENT_NAME = 'obj-changed';
265
- })(objChanged = exports.objChanged || (exports.objChanged = {}));
266
- Object.freeze(objChanged);
267
- var objRemoved;
268
- (function (objRemoved) {
269
- objRemoved.EVENT_NAME = 'obj-removed';
270
- })(objRemoved = exports.objRemoved || (exports.objRemoved = {}));
271
- Object.freeze(objChanged);
285
+ var events;
286
+ (function (events) {
287
+ let objChanged;
288
+ (function (objChanged) {
289
+ objChanged.EVENT_NAME = 'obj-changed';
290
+ })(objChanged = events.objChanged || (events.objChanged = {}));
291
+ Object.freeze(objChanged);
292
+ let objRemoved;
293
+ (function (objRemoved) {
294
+ objRemoved.EVENT_NAME = 'obj-removed';
295
+ })(objRemoved = events.objRemoved || (events.objRemoved = {}));
296
+ Object.freeze(objRemoved);
297
+ let objVersionArchived;
298
+ (function (objVersionArchived) {
299
+ objVersionArchived.EVENT_NAME = 'obj-ver-archived';
300
+ })(objVersionArchived = events.objVersionArchived || (events.objVersionArchived = {}));
301
+ Object.freeze(objVersionArchived);
302
+ let objArchivedVersionRemoved;
303
+ (function (objArchivedVersionRemoved) {
304
+ objArchivedVersionRemoved.EVENT_NAME = 'obj-ver-removed';
305
+ })(objArchivedVersionRemoved = events.objArchivedVersionRemoved || (events.objArchivedVersionRemoved = {}));
306
+ Object.freeze(objArchivedVersionRemoved);
307
+ events.all = [
308
+ objChanged.EVENT_NAME,
309
+ objRemoved.EVENT_NAME,
310
+ objVersionArchived.EVENT_NAME,
311
+ objArchivedVersionRemoved.EVENT_NAME,
312
+ ];
313
+ })(events = exports.events || (exports.events = {}));
314
+ Object.freeze(events);
272
315
  Object.freeze(exports);
@@ -97,11 +97,11 @@ var msgObj;
97
97
  (function (msgObj) {
98
98
  msgObj.EXPRESS_URL_END = 'msg/obj/:objId';
99
99
  function firstPutReqUrlEnd(objId, opts) {
100
- return `msg/obj/${objId}?${querystring_1.stringify(opts)}`;
100
+ return `msg/obj/${objId}?${(0, querystring_1.stringify)(opts)}`;
101
101
  }
102
102
  msgObj.firstPutReqUrlEnd = firstPutReqUrlEnd;
103
103
  function secondPutReqUrlEnd(objId, opts) {
104
- return `msg/obj/${objId}?${querystring_1.stringify(opts)}`;
104
+ return `msg/obj/${objId}?${(0, querystring_1.stringify)(opts)}`;
105
105
  }
106
106
  msgObj.secondPutReqUrlEnd = secondPutReqUrlEnd;
107
107
  msgObj.SC = {
@@ -114,7 +114,7 @@ var msgObj;
114
114
  (function (msgObj) {
115
115
  msgObj.EXPRESS_URL_END = 'msg/:msgId/obj/:objId';
116
116
  function genUrlEnd(msgId, objId, opts) {
117
- let optStr = (opts ? '?' + querystring_1.stringify(opts) : '');
117
+ let optStr = (opts ? '?' + (0, querystring_1.stringify)(opts) : '');
118
118
  return `msg/${msgId}/obj/${objId}${optStr}`;
119
119
  }
120
120
  msgObj.genUrlEnd = genUrlEnd;
@@ -4,6 +4,7 @@ export interface TimedCache<TKey, TVal> {
4
4
  resetLifeTimeOf(key: TKey): boolean;
5
5
  set(key: TKey, val: TVal): void;
6
6
  delete(key: TKey): void;
7
+ keys(): TKey[];
7
8
  clear(): void;
8
9
  destroy(): void;
9
10
  }
@@ -10,6 +10,7 @@ export declare class TimeWindowCache<TKey, TVal> implements TimedCache<TKey, TVa
10
10
  has(key: TKey): boolean;
11
11
  set(key: TKey, val: TVal): void;
12
12
  delete(key: TKey): void;
13
+ keys(): TKey[];
13
14
  clear(): void;
14
15
  destroy(): void;
15
16
  }
@@ -43,6 +43,7 @@ class TimeWindowCache {
43
43
  }
44
44
  v = this.waiting.get(key);
45
45
  if (v !== undefined) {
46
+ this.waiting.delete(key);
46
47
  this.filling.set(key, v);
47
48
  }
48
49
  return v;
@@ -57,6 +58,16 @@ class TimeWindowCache {
57
58
  this.filling.delete(key);
58
59
  this.waiting.delete(key);
59
60
  }
61
+ keys() {
62
+ const allKeys = [];
63
+ for (const key of this.filling.keys()) {
64
+ allKeys.push(key);
65
+ }
66
+ for (const key of this.waiting.keys()) {
67
+ allKeys.push(key);
68
+ }
69
+ return allKeys;
70
+ }
60
71
  clear() {
61
72
  this.filling.clear();
62
73
  this.waiting.clear();