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
@@ -55,7 +55,7 @@ class ServiceUser {
55
55
  return this.uri;
56
56
  }
57
57
  set serviceURI(uriString) {
58
- const u = url_1.parse(uriString);
58
+ const u = (0, url_1.parse)(uriString);
59
59
  if (u.protocol !== 'https:') {
60
60
  throw new Error("Url protocol must be https.");
61
61
  }
@@ -82,40 +82,40 @@ class ServiceUser {
82
82
  if (rep.status == loginApi.start.SC.ok) {
83
83
  // set sessionid
84
84
  if (!rep.data || (typeof rep.data.sessionId !== 'string')) {
85
- throw request_utils_1.makeException(rep, 'Malformed reply to starting session');
85
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply to starting session');
86
86
  }
87
87
  this.sessionId = rep.data.sessionId;
88
88
  // set server public key
89
89
  if (typeof rep.data.serverPubKey !== 'string') {
90
- throw request_utils_1.makeException(rep, 'Malformed reply: serverPubKey string is missing.');
90
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply: serverPubKey string is missing.');
91
91
  }
92
92
  try {
93
93
  this.serverPubKey = buffer_utils_1.base64.open(rep.data.serverPubKey);
94
94
  if (this.serverPubKey.length !== ecma_nacl_1.box.KEY_LENGTH) {
95
- throw request_utils_1.makeException(rep, 'Malformed reply: server\'s key has a wrong size.');
95
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply: server\'s key has a wrong size.');
96
96
  }
97
97
  }
98
98
  catch (err) {
99
- throw request_utils_1.makeException(rep, `Malformed reply: bad serverPubKey string. Error: ${('string' === typeof err) ? err : err.message}`);
99
+ throw (0, request_utils_1.makeException)(rep, `Malformed reply: bad serverPubKey string. Error: ${('string' === typeof err) ? err : err.message}`);
100
100
  }
101
101
  // get encrypted session key from json body
102
102
  if (typeof rep.data.sessionKey !== 'string') {
103
- throw request_utils_1.makeException(rep, 'Malformed reply: sessionKey string is missing.');
103
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply: sessionKey string is missing.');
104
104
  }
105
105
  try {
106
106
  this.encChallenge = buffer_utils_1.base64.open(rep.data.sessionKey);
107
107
  if (this.encChallenge.length !==
108
108
  (ecma_nacl_1.secret_box.NONCE_LENGTH + ecma_nacl_1.secret_box.KEY_LENGTH)) {
109
- throw request_utils_1.makeException(rep, `Malformed reply: byte chunk with session key has a wrong size.`);
109
+ throw (0, request_utils_1.makeException)(rep, `Malformed reply: byte chunk with session key has a wrong size.`);
110
110
  }
111
111
  }
112
112
  catch (err) {
113
- throw request_utils_1.makeException(rep, `Malformed reply: bad sessionKey string. Error: ${(typeof err === 'string') ? err : err.message}`);
113
+ throw (0, request_utils_1.makeException)(rep, `Malformed reply: bad sessionKey string. Error: ${(typeof err === 'string') ? err : err.message}`);
114
114
  }
115
115
  // get key derivation parameters for a default key
116
116
  if (!keyId) {
117
117
  if (typeof rep.data.keyDerivParams !== 'object') {
118
- throw request_utils_1.makeException(rep, `Malformed reply: keyDerivParams string is missing.`);
118
+ throw (0, request_utils_1.makeException)(rep, `Malformed reply: keyDerivParams string is missing.`);
119
119
  }
120
120
  this.keyDerivationParams = rep.data.keyDerivParams;
121
121
  }
@@ -124,11 +124,11 @@ class ServiceUser {
124
124
  (rep.status === loginApi.start.SC.redirect)) {
125
125
  const rd = rep.data;
126
126
  if (!rd || ('string' !== typeof rd.redirect)) {
127
- throw request_utils_1.makeException(rep, 'Malformed reply');
127
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply');
128
128
  }
129
129
  // refuse second redirect
130
130
  if (this.redirectedFrom !== undefined) {
131
- throw request_utils_1.makeException(rep, `Redirected too many times. First redirect was from ${this.redirectedFrom} to ${this.serviceURI}. Second and forbidden redirect is to ${rd.redirect}`);
131
+ throw (0, request_utils_1.makeException)(rep, `Redirected too many times. First redirect was from ${this.redirectedFrom} to ${this.serviceURI}. Second and forbidden redirect is to ${rd.redirect}`);
132
132
  }
133
133
  // set params
134
134
  this.redirectedFrom = this.serviceURI;
@@ -137,19 +137,19 @@ class ServiceUser {
137
137
  return this.startSession(keyId);
138
138
  }
139
139
  else if (rep.status === loginApi.start.SC.unknownUser) {
140
- const exc = request_utils_1.makeException(rep);
140
+ const exc = (0, request_utils_1.makeException)(rep);
141
141
  exc.unknownUser = true;
142
142
  throw exc;
143
143
  }
144
144
  else {
145
- throw request_utils_1.makeException(rep, 'Unexpected status');
145
+ throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
146
146
  }
147
147
  }
148
148
  openSessionKey(dhsharedKeyCalc) {
149
- assert_1.assert(!!this.encChallenge);
149
+ (0, assert_1.assert)(!!this.encChallenge);
150
150
  const dhsharedKey = dhsharedKeyCalc();
151
- const nonce = buffer_utils_1.makeUint8ArrayCopy(this.encChallenge.subarray(0, ecma_nacl_1.secret_box.NONCE_LENGTH));
152
- const sessionKey = buffer_utils_1.makeUint8ArrayCopy(this.encChallenge.subarray(ecma_nacl_1.secret_box.NONCE_LENGTH));
151
+ const nonce = (0, buffer_utils_1.makeUint8ArrayCopy)(this.encChallenge.subarray(0, ecma_nacl_1.secret_box.NONCE_LENGTH));
152
+ const sessionKey = (0, buffer_utils_1.makeUint8ArrayCopy)(this.encChallenge.subarray(ecma_nacl_1.secret_box.NONCE_LENGTH));
153
153
  // encrypted challenge has session key packaged into WN format, with
154
154
  // poly part cut out. Therefore, usual open method will not do as it
155
155
  // does poly check. We should recall that cipher is a stream with data
@@ -168,15 +168,15 @@ class ServiceUser {
168
168
  this.serverVerificationBytes =
169
169
  this.serverVerificationBytes.subarray(0, ecma_nacl_1.secret_box.POLY_LENGTH);
170
170
  ecma_nacl_1.nonce.advanceOddly(nonce);
171
- this.encryptor = session_encryptor_1.makeSessionEncryptor(sessionKey, nonce);
171
+ this.encryptor = (0, session_encryptor_1.makeSessionEncryptor)(sessionKey, nonce);
172
172
  // encrypt session key for completion of login exchange
173
173
  this.encChallenge = this.encryptor.pack(sessionKey);
174
174
  // cleanup arrays
175
175
  ecma_nacl_1.arrays.wipe(dhsharedKey, nonce, sessionKey);
176
176
  }
177
177
  async completeLoginExchange() {
178
- assert_1.assert(!!this.encChallenge);
179
- assert_1.assert(!!this.serverVerificationBytes);
178
+ (0, assert_1.assert)(!!this.encChallenge);
179
+ (0, assert_1.assert)(!!this.serverVerificationBytes);
180
180
  const rep = await this.net.doBinaryRequest({
181
181
  url: `${this.serviceURI}${this.loginUrlPart}${loginApi.complete.URL_END}`,
182
182
  method: loginApi.complete.method,
@@ -186,22 +186,22 @@ class ServiceUser {
186
186
  this.encChallenge = undefined;
187
187
  if (rep.status === loginApi.complete.SC.ok) {
188
188
  // compare bytes to check, if server can be trusted
189
- if (ecma_nacl_1.compareVectors(rep.data, this.serverVerificationBytes)) {
189
+ if ((0, ecma_nacl_1.compareVectors)(rep.data, this.serverVerificationBytes)) {
190
190
  this.serverVerificationBytes = undefined;
191
191
  }
192
192
  else {
193
- const exc = request_utils_1.makeException(rep);
193
+ const exc = (0, request_utils_1.makeException)(rep);
194
194
  exc.serverNotTrusted = true;
195
195
  throw exc;
196
196
  }
197
197
  }
198
198
  else if (rep.status === loginApi.complete.SC.authFailed) {
199
- const exc = request_utils_1.makeException(rep);
199
+ const exc = (0, request_utils_1.makeException)(rep);
200
200
  exc.cryptoResponseNotAccepted = true;
201
201
  throw exc;
202
202
  }
203
203
  else {
204
- throw request_utils_1.makeException(rep, 'Unexpected status');
204
+ throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
205
205
  }
206
206
  }
207
207
  /**
@@ -216,7 +216,7 @@ class ServiceUser {
216
216
  */
217
217
  async login(keyId) {
218
218
  await this.startSession(keyId);
219
- assert_1.assert(!!this.serverPubKey);
219
+ (0, assert_1.assert)(!!this.serverPubKey);
220
220
  return {
221
221
  keyParams: this.keyDerivationParams,
222
222
  serverPKey: this.serverPubKey,
@@ -245,7 +245,7 @@ class ServiceUser {
245
245
  this.encryptor = undefined;
246
246
  }
247
247
  else {
248
- throw request_utils_1.makeException(rep, 'Unexpected status');
248
+ throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
249
249
  }
250
250
  }
251
251
  }
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.openSocket = void 0;
19
19
  const WebSocket = require("ws");
20
20
  const request_utils_1 = require("./request-utils");
21
- const processes_1 = require("../lib-common/processes");
21
+ const deferred_1 = require("../lib-common/processes/deferred");
22
22
  const http_1 = require("../lib-common/exceptions/http");
23
23
  const https_1 = require("https");
24
24
  function openSocket(url, sessionId) {
@@ -28,8 +28,8 @@ function openSocket(url, sessionId) {
28
28
  const headers = {};
29
29
  headers[request_utils_1.SESSION_ID_HEADER] = sessionId;
30
30
  const ws = new WebSocket(url, { headers, agent: https_1.globalAgent });
31
- const opening = processes_1.defer();
32
- const initOnError = err => opening.reject(http_1.makeConnectionException(url, undefined, `Cannot open websocket connection due to error: ${err.message}`));
31
+ const opening = (0, deferred_1.defer)();
32
+ const initOnError = err => opening.reject((0, http_1.makeConnectionException)(url, undefined, `Cannot open websocket connection due to error: ${err.message}`));
33
33
  const onNonOkReply = (req, res) => {
34
34
  const errReply = {
35
35
  url,
@@ -52,8 +52,8 @@ function makeEncryptor(cryptor, key, nextNonce, delta) {
52
52
  else if ((delta < 1) || (delta > 255)) {
53
53
  throw new Error("Given delta is out of bounds.");
54
54
  }
55
- key = buffer_utils_1.makeUint8ArrayCopy(key);
56
- nextNonce = buffer_utils_1.makeUint8ArrayCopy(nextNonce);
55
+ key = (0, buffer_utils_1.makeUint8ArrayCopy)(key);
56
+ nextNonce = (0, buffer_utils_1.makeUint8ArrayCopy)(nextNonce);
57
57
  let counter = 0;
58
58
  const counterMax = Math.floor(0xfffffffffffff / delta);
59
59
  const encryptor = {
@@ -65,7 +65,7 @@ function makeEncryptor(cryptor, key, nextNonce, delta) {
65
65
  throw new Error(`This encryptor has been used too many times. Further use may lead to duplication of nonces.`);
66
66
  }
67
67
  const c = await cryptor.formatWN.pack(m, nextNonce, key);
68
- xsp_files_1.advanceNonce(nextNonce, delta);
68
+ (0, xsp_files_1.advanceNonce)(nextNonce, delta);
69
69
  counter += 1;
70
70
  return c;
71
71
  },
@@ -101,7 +101,7 @@ function makeDecryptor(cryptor, key) {
101
101
  if (key.length !== 32) {
102
102
  throw new Error(`Key array key should have 32 elements (bytes) in it, but it is ${key.length} elements long.`);
103
103
  }
104
- key = buffer_utils_1.makeUint8ArrayCopy(key);
104
+ key = (0, buffer_utils_1.makeUint8ArrayCopy)(key);
105
105
  const decryptor = {
106
106
  open: (c) => {
107
107
  if (!key) {
@@ -1,22 +1,24 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
3
+ /// <reference types="node" />
2
4
  import * as fs from 'fs';
3
5
  import { Readable, Writable } from 'stream';
4
6
  export { Stats } from 'fs';
5
7
  export { FileException } from './exceptions/file';
6
8
  export declare function readFile(filename: string, options: {
7
- encoding: string;
9
+ encoding: BufferEncoding;
8
10
  flag?: string;
9
11
  }): Promise<string>;
10
12
  export declare function readFile(filename: string, options?: {
11
13
  flag?: string;
12
14
  }): Promise<Buffer>;
13
15
  export declare function writeFile(path: string, data: any, options?: {
14
- encoding?: string;
16
+ encoding?: BufferEncoding;
15
17
  mode?: string;
16
18
  flag?: string;
17
19
  }): Promise<void>;
18
20
  export declare function appendFile(path: string, data: any, options?: {
19
- encoding?: string;
21
+ encoding?: BufferEncoding;
20
22
  mode?: string;
21
23
  flag?: string;
22
24
  }): Promise<void>;
@@ -16,18 +16,19 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.ensureFolderExists = exports.copyTree = exports.copyFile = exports.streamFromFile = exports.rmDirWithContent = exports.read = exports.streamToExistingFile = exports.append = exports.write = exports.getFolderContentSize = exports.getFileSize = exports.existsFileSync = exports.existsFolderSync = exports.existsFolder = exports.createEmptyFile = exports.writeFromBuf = exports.readToBuf = exports.ftruncate = exports.truncate = exports.rename = exports.unlink = exports.rmdir = exports.readdir = exports.fstat = exports.stat = exports.lstat = exports.readlink = exports.symlink = exports.close = exports.open = exports.mkdir = exports.appendFile = exports.writeFile = exports.readFile = void 0;
19
+ exports.ensureFolderExists = exports.copyTree = exports.copyFile = exports.streamFromFile = exports.rmDirWithContent = exports.read = exports.streamToExistingFile = exports.append = exports.write = exports.getFolderContentSize = exports.getFileSize = exports.existsFileSync = exports.existsFolderSync = exports.existsFolder = exports.createEmptyFile = exports.writeFromBuf = exports.readToBuf = exports.ftruncate = exports.truncate = exports.rename = exports.unlink = exports.rmdir = exports.readdir = exports.fstat = exports.stat = exports.lstat = exports.readlink = exports.symlink = exports.close = exports.open = exports.mkdir = exports.appendFile = exports.writeFile = exports.readFile = exports.Stats = void 0;
20
20
  const fs = require("fs");
21
21
  const fs_1 = require("fs");
22
22
  const file_1 = require("./exceptions/file");
23
- const processes_1 = require("./processes");
23
+ const synced_1 = require("./processes/synced");
24
+ const deferred_1 = require("./processes/deferred");
24
25
  const bytes_fifo_buffer_1 = require("./byte-streaming/bytes-fifo-buffer");
25
26
  const buffer_utils_1 = require("./buffer-utils");
26
27
  const path_1 = require("path");
27
28
  var fs_2 = require("fs");
28
29
  Object.defineProperty(exports, "Stats", { enumerable: true, get: function () { return fs_2.Stats; } });
29
30
  function makeFileExceptionFromNodes(nodeExc) {
30
- return file_1.makeFileException(nodeExc.code, nodeExc.path);
31
+ return (0, file_1.makeFileException)(nodeExc.code, nodeExc.path);
31
32
  }
32
33
  function readFile(path, options) {
33
34
  return new Promise((resolve, reject) => {
@@ -306,7 +307,7 @@ async function readToBuf(fd, pos, buf) {
306
307
  while (bytesRead < buf.length) {
307
308
  const bNum = await readOrig(fd, buf, bytesRead, buf.length - bytesRead, pos);
308
309
  if (bNum === 0) {
309
- throw file_1.makeFileException(file_1.Code.endOfFile, '<file descriptor>');
310
+ throw (0, file_1.makeFileException)(file_1.Code.endOfFile, '<file descriptor>');
310
311
  }
311
312
  bytesRead += bNum;
312
313
  pos += bNum;
@@ -378,7 +379,7 @@ async function existsFolder(path) {
378
379
  return true;
379
380
  }
380
381
  else {
381
- throw file_1.makeFileException(file_1.Code.notDirectory, path);
382
+ throw (0, file_1.makeFileException)(file_1.Code.notDirectory, path);
382
383
  }
383
384
  }
384
385
  catch (e) {
@@ -395,11 +396,11 @@ exports.existsFolder = existsFolder;
395
396
  */
396
397
  function existsFolderSync(path) {
397
398
  try {
398
- if (fs_1.statSync(path).isDirectory()) {
399
+ if ((0, fs_1.statSync)(path).isDirectory()) {
399
400
  return true;
400
401
  }
401
402
  else {
402
- throw file_1.makeFileException(file_1.Code.notDirectory, path);
403
+ throw (0, file_1.makeFileException)(file_1.Code.notDirectory, path);
403
404
  }
404
405
  }
405
406
  catch (e) {
@@ -416,11 +417,11 @@ exports.existsFolderSync = existsFolderSync;
416
417
  */
417
418
  function existsFileSync(path) {
418
419
  try {
419
- if (fs_1.statSync(path).isFile()) {
420
+ if ((0, fs_1.statSync)(path).isFile()) {
420
421
  return true;
421
422
  }
422
423
  else {
423
- throw file_1.makeFileException(file_1.Code.notFile, path);
424
+ throw (0, file_1.makeFileException)(file_1.Code.notFile, path);
424
425
  }
425
426
  }
426
427
  catch (e) {
@@ -527,11 +528,11 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
527
528
  if ((typeof bufSize !== 'number') || (bufSize < 1024)) {
528
529
  throw new Error('Illegal buffer size given: ' + bufSize);
529
530
  }
530
- const writeProc = new processes_1.SingleProc();
531
+ const writeProc = new synced_1.SingleProc();
531
532
  let bytesWritten = 0;
532
533
  let bytesRead = 0;
533
534
  const buf = new bytes_fifo_buffer_1.BytesFIFOBuffer();
534
- let deferred = processes_1.defer();
535
+ let deferred = (0, deferred_1.defer)();
535
536
  let doneReading = false;
536
537
  const complete = (err) => {
537
538
  if (!deferred) {
@@ -568,7 +569,7 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
568
569
  if (!bytesToWrite) {
569
570
  return;
570
571
  }
571
- await writeToExistingFile(filePath, pos, buffer_utils_1.toBuffer(bytesToWrite));
572
+ await writeToExistingFile(filePath, pos, (0, buffer_utils_1.toBuffer)(bytesToWrite));
572
573
  pos += bytesToWrite.length;
573
574
  bytesWritten += bytesToWrite.length;
574
575
  if (bytesWritten < len) {
@@ -585,7 +586,7 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
585
586
  if (doneReading) {
586
587
  return;
587
588
  }
588
- complete(file_1.makeFileException(file_1.Code.endOfFile, '<input stream>'));
589
+ complete((0, file_1.makeFileException)(file_1.Code.endOfFile, '<input stream>'));
589
590
  });
590
591
  src.on('error', (err) => {
591
592
  complete(err);
@@ -613,7 +614,7 @@ async function read(fd, pos, buf) {
613
614
  while (bytesRead < buf.length) {
614
615
  const bNum = await readOrig(fd, buf, bytesRead, buf.length - bytesRead, pos);
615
616
  if (bNum === 0) {
616
- throw file_1.makeFileException(file_1.Code.endOfFile, '<file descriptor>');
617
+ throw (0, file_1.makeFileException)(file_1.Code.endOfFile, '<file descriptor>');
617
618
  }
618
619
  bytesRead += bNum;
619
620
  pos += bNum;
@@ -728,8 +729,8 @@ exports.streamFromFile = streamFromFile;
728
729
  */
729
730
  function copyFile(src, dst, overwrite = false, dstMode = '660') {
730
731
  return new Promise((resolve, reject) => {
731
- const srcStream = fs_1.createReadStream(src);
732
- const dstStream = fs_1.createWriteStream(dst, {
732
+ const srcStream = (0, fs_1.createReadStream)(src);
733
+ const dstStream = (0, fs_1.createWriteStream)(dst, {
733
734
  mode: parseInt(dstMode, 8),
734
735
  flags: (overwrite ? 'w' : 'wx')
735
736
  });
@@ -772,8 +773,8 @@ async function copyTree(src, dst, fileOverwrite = false) {
772
773
  const srcFNames = await readdir(src);
773
774
  const cpTasks = [];
774
775
  for (const fName of srcFNames) {
775
- const srcPath = path_1.join(src, fName);
776
- const dstPath = path_1.join(dst, fName);
776
+ const srcPath = (0, path_1.join)(src, fName);
777
+ const dstPath = (0, path_1.join)(dst, fName);
777
778
  const task = stat(srcPath)
778
779
  .then((stats) => {
779
780
  if (stats.isFile()) {
@@ -29,7 +29,7 @@ const sink_utils_1 = require("../obj-streaming/sink-utils");
29
29
  * Default value is 64K.
30
30
  */
31
31
  async function pipe(src, sink, progressCB = undefined, closeSink = true, bufSize = 64 * 1024) {
32
- const contSink = sink_utils_1.makeContinuousSink(sink);
32
+ const contSink = (0, sink_utils_1.makeContinuousSink)(sink);
33
33
  try {
34
34
  let buf = await src.read(bufSize);
35
35
  let bytesPiped = 0;
@@ -17,37 +17,37 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.wrapAndSyncFileSource = exports.wrapAndSyncSource = exports.wrapAndSyncFileSink = void 0;
20
- const processes_1 = require("../processes");
20
+ const synced_1 = require("../processes/synced");
21
21
  function wrapAndSyncFileSink(sink) {
22
- const syncProc = new processes_1.SingleProc();
22
+ const syncProc = new synced_1.SingleProc();
23
23
  const w = {
24
- done: processes_1.makeSyncedFunc(syncProc, sink, sink.done),
25
- getSize: processes_1.makeSyncedFunc(syncProc, sink, sink.getSize),
26
- showLayout: processes_1.makeSyncedFunc(syncProc, sink, sink.showLayout),
27
- splice: processes_1.makeSyncedFunc(syncProc, sink, sink.splice),
28
- truncate: processes_1.makeSyncedFunc(syncProc, sink, sink.truncate)
24
+ done: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.done),
25
+ getSize: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.getSize),
26
+ showLayout: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.showLayout),
27
+ splice: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.splice),
28
+ truncate: (0, synced_1.makeSyncedFunc)(syncProc, sink, sink.truncate)
29
29
  };
30
30
  return w;
31
31
  }
32
32
  exports.wrapAndSyncFileSink = wrapAndSyncFileSink;
33
33
  function wrapAndSyncSource(src) {
34
- const syncProc = new processes_1.SingleProc();
34
+ const syncProc = new synced_1.SingleProc();
35
35
  const w = {
36
- getPosition: processes_1.makeSyncedFunc(syncProc, src, src.getPosition),
37
- getSize: processes_1.makeSyncedFunc(syncProc, src, src.getSize),
38
- read: processes_1.makeSyncedFunc(syncProc, src, src.read),
39
- seek: processes_1.makeSyncedFunc(syncProc, src, src.seek)
36
+ getPosition: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getPosition),
37
+ getSize: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getSize),
38
+ read: (0, synced_1.makeSyncedFunc)(syncProc, src, src.read),
39
+ seek: (0, synced_1.makeSyncedFunc)(syncProc, src, src.seek)
40
40
  };
41
41
  return w;
42
42
  }
43
43
  exports.wrapAndSyncSource = wrapAndSyncSource;
44
44
  function wrapAndSyncFileSource(src) {
45
- const syncProc = new processes_1.SingleProc();
45
+ const syncProc = new synced_1.SingleProc();
46
46
  const w = {
47
- getPosition: processes_1.makeSyncedFunc(syncProc, src, src.getPosition),
48
- getSize: processes_1.makeSyncedFunc(syncProc, src, src.getSize),
49
- read: processes_1.makeSyncedFunc(syncProc, src, src.read),
50
- seek: processes_1.makeSyncedFunc(syncProc, src, src.seek),
47
+ getPosition: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getPosition),
48
+ getSize: (0, synced_1.makeSyncedFunc)(syncProc, src, src.getSize),
49
+ read: (0, synced_1.makeSyncedFunc)(syncProc, src, src.read),
50
+ seek: (0, synced_1.makeSyncedFunc)(syncProc, src, src.seek),
51
51
  };
52
52
  return w;
53
53
  }
@@ -50,7 +50,7 @@ function checkDomainString(d, addrForErrMsg) {
50
50
  }
51
51
  let ascii;
52
52
  try {
53
- ascii = punycode_1.toASCII(d);
53
+ ascii = (0, punycode_1.toASCII)(d);
54
54
  }
55
55
  catch (err) {
56
56
  throw makeParseExc(addrForErrMsg, err);
@@ -2,4 +2,5 @@ export interface ErrorWithCause extends Error {
2
2
  cause: any;
3
3
  }
4
4
  export declare function errWithCause(cause: any, message: string): ErrorWithCause;
5
+ export declare function recursiveErrJSONify(err: web3n.RuntimeException): any;
5
6
  export declare function stringifyErr(err: any): string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2016 - 2017, 2020 3NSoft Inc.
3
+ Copyright (C) 2016 - 2017, 2020, 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
@@ -15,7 +15,7 @@
15
15
  You should have received a copy of the GNU General Public License along with
16
16
  this program. If not, see <http://www.gnu.org/licenses/>. */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.stringifyErr = exports.errWithCause = void 0;
18
+ exports.stringifyErr = exports.recursiveErrJSONify = exports.errWithCause = void 0;
19
19
  function errWithCause(cause, message) {
20
20
  const err = new Error(message);
21
21
  err.cause = cause;
@@ -25,13 +25,13 @@ function errWithCause(cause, message) {
25
25
  return err;
26
26
  }
27
27
  exports.errWithCause = errWithCause;
28
- function recursiveJSONify(err) {
28
+ function recursiveErrJSONify(err) {
29
29
  if (!err || (typeof err !== 'object') || Array.isArray(err)) {
30
30
  return err;
31
31
  }
32
32
  else if (err.runtimeException) {
33
33
  if (err.cause) {
34
- err.cause = recursiveJSONify(err.cause);
34
+ err.cause = recursiveErrJSONify(err.cause);
35
35
  }
36
36
  return err;
37
37
  }
@@ -41,16 +41,17 @@ function recursiveJSONify(err) {
41
41
  stack: err.stack
42
42
  };
43
43
  if (err.cause) {
44
- jsonErr.cause = recursiveJSONify(err.cause);
44
+ jsonErr.cause = recursiveErrJSONify(err.cause);
45
45
  }
46
46
  return jsonErr;
47
47
  }
48
48
  }
49
+ exports.recursiveErrJSONify = recursiveErrJSONify;
49
50
  function stringifyErr(err) {
50
51
  if (!err) {
51
52
  return '';
52
53
  }
53
- let json = recursiveJSONify(err);
54
+ let json = recursiveErrJSONify(err);
54
55
  let errStr;
55
56
  if (!json || (typeof json !== 'object') || err.runtimeException) {
56
57
  try {
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
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/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.makeVersionMismatchExc = exports.makeNoAttrsExc = exports.ensureCorrectFS = exports.maskPathInExc = exports.makeFileException = exports.Code = void 0;
19
20
  exports.Code = {
@@ -32,6 +33,8 @@ exports.Code = {
32
33
  parsingError: 'parsing-error',
33
34
  notImplemented: 'ENOSYS',
34
35
  isEndless: 'is-endless',
36
+ storageClosed: 'storage-closed',
37
+ versionMismatch: 'version-mismatch',
35
38
  };
36
39
  Object.freeze(exports.Code);
37
40
  function makeFileException(code, path, cause) {
@@ -87,6 +90,12 @@ function makeFileException(code, path, cause) {
87
90
  else if (code === exports.Code.isEndless) {
88
91
  err.isEndless = true;
89
92
  }
93
+ else if (code === exports.Code.storageClosed) {
94
+ err.storageClosed = true;
95
+ }
96
+ else if (code === exports.Code.versionMismatch) {
97
+ err.versionMismatch = true;
98
+ }
90
99
  return err;
91
100
  }
92
101
  exports.makeFileException = makeFileException;
@@ -17,7 +17,7 @@
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
18
  exports.SingleObserverWrap = exports.MultiObserverWrap = exports.makeSubscribingClient = exports.makeEventfulServer = exports.makeRequestServer = exports.makeRequestingClient = void 0;
19
19
  const map_of_sets_1 = require("../map-of-sets");
20
- const processes_1 = require("../processes");
20
+ const synced_1 = require("../processes/synced");
21
21
  function toTransferrableError(e) {
22
22
  const err = {
23
23
  message: e.message,
@@ -556,7 +556,7 @@ class IpcEventChannels {
556
556
  * These are all subscribed ipc channels.
557
557
  */
558
558
  this.subscribedIpcChannels = new Set();
559
- this.subscriptionProcs = new processes_1.NamedProcs();
559
+ this.subscriptionProcs = new synced_1.NamedProcs();
560
560
  Object.freeze(this);
561
561
  }
562
562
  subscribeTo(ipcChannel) {
@@ -15,7 +15,7 @@
15
15
  You should have received a copy of the GNU General Public License along with
16
16
  this program. If not, see <http://www.gnu.org/licenses/>. */
17
17
  Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.makeSubscriber = void 0;
18
+ exports.makeSubscriber = exports.makeEventfulServer = void 0;
19
19
  const generic_ipc_1 = require("./generic-ipc");
20
20
  var generic_ipc_2 = require("./generic-ipc");
21
21
  Object.defineProperty(exports, "makeEventfulServer", { enumerable: true, get: function () { return generic_ipc_2.makeEventfulServer; } });
@@ -111,7 +111,7 @@ function onError(ws, observers) {
111
111
  }
112
112
  function makeSubscriber(ws, ipcChannel) {
113
113
  const comm = makeJsonCommPoint(ws);
114
- return generic_ipc_1.makeSubscribingClient(ipcChannel, comm);
114
+ return (0, generic_ipc_1.makeSubscribingClient)(ipcChannel, comm);
115
115
  }
116
116
  exports.makeSubscriber = makeSubscriber;
117
117
  Object.freeze(exports);
@@ -13,7 +13,8 @@
13
13
  See the GNU General Public License for more details.
14
14
 
15
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/>. */
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
17
18
  Object.defineProperty(exports, "__esModule", { value: true });
18
19
  exports.applyChangesToJSON = exports.deepFind = exports.deepEqual = exports.copy = void 0;
19
20
  /**