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
@@ -80,14 +80,14 @@ class ObjFolders {
80
80
  numOfSplits: this.numOfSplits,
81
81
  generations: this.generations
82
82
  });
83
- assert_1.assert(Number.isInteger(this.numOfSplits) && (this.numOfSplits > 0) &&
83
+ (0, assert_1.assert)(Number.isInteger(this.numOfSplits) && (this.numOfSplits > 0) &&
84
84
  Number.isInteger(this.charsInSplit) && (this.charsInSplit > 0));
85
- this.accessFolder = path_1.join(this.path, ACCESS_DIR);
85
+ this.accessFolder = (0, path_1.join)(this.path, ACCESS_DIR);
86
86
  if (this.generations) {
87
87
  if (!canMove) {
88
88
  throw new Error(`Missing a can-move predicate when generations are present`);
89
89
  }
90
- this.generationsFolder = path_1.join(this.path, GENERATIONS_DIR);
90
+ this.generationsFolder = (0, path_1.join)(this.path, GENERATIONS_DIR);
91
91
  this.rotationsProc = new RotationsProc(this.accessFolder, this.generationsFolder, this.generations, this.syncProcs, canMove, this.saveCfg, this.logError);
92
92
  this.rotationsProc.scheduleStart(10 * 60);
93
93
  }
@@ -100,8 +100,8 @@ class ObjFolders {
100
100
  await writeCfgTo(path, cfg);
101
101
  }
102
102
  checkCfg(cfg);
103
- await fs.mkdir(path_1.join(path, ACCESS_DIR)).catch(alreadyExistsOrReThrow);
104
- await fs.mkdir(path_1.join(path, GENERATIONS_DIR)).catch(alreadyExistsOrReThrow);
103
+ await fs.mkdir((0, path_1.join)(path, ACCESS_DIR)).catch(alreadyExistsOrReThrow);
104
+ await fs.mkdir((0, path_1.join)(path, GENERATIONS_DIR)).catch(alreadyExistsOrReThrow);
105
105
  return new ObjFolders(path, cfg.numOfSplits, cfg.charsInSplit, logError, cfg.generations, canMove);
106
106
  }
107
107
  static async makeSimple(path, logError) {
@@ -111,7 +111,7 @@ class ObjFolders {
111
111
  await writeCfgTo(path, cfg);
112
112
  }
113
113
  checkCfg(cfg);
114
- await fs.mkdir(path_1.join(path, ACCESS_DIR)).catch(alreadyExistsOrReThrow);
114
+ await fs.mkdir((0, path_1.join)(path, ACCESS_DIR)).catch(alreadyExistsOrReThrow);
115
115
  return new ObjFolders(path, cfg.numOfSplits, cfg.charsInSplit, logError);
116
116
  }
117
117
  idToPathSections(objId) {
@@ -127,10 +127,10 @@ class ObjFolders {
127
127
  return path;
128
128
  }
129
129
  genBucketPath(bucketIndex) {
130
- return path_1.join(this.generationsFolder, `${bucketIndex}`);
130
+ return (0, path_1.join)(this.generationsFolder, `${bucketIndex}`);
131
131
  }
132
132
  async findObjFolder(pathSections) {
133
- const folder = path_1.join(this.accessFolder, ...pathSections);
133
+ const folder = (0, path_1.join)(this.accessFolder, ...pathSections);
134
134
  if (await folderExists(folder)) {
135
135
  return { folder };
136
136
  }
@@ -138,7 +138,7 @@ class ObjFolders {
138
138
  return;
139
139
  }
140
140
  for (let i = 0; i < this.generations.length; i += 1) {
141
- const folder = path_1.join(this.genBucketPath(i), ...pathSections);
141
+ const folder = (0, path_1.join)(this.genBucketPath(i), ...pathSections);
142
142
  if (await folderExists(folder)) {
143
143
  return { folder, genBacket: i };
144
144
  }
@@ -146,7 +146,7 @@ class ObjFolders {
146
146
  }
147
147
  getFolderAccessFor(objId, createIfMissing = false) {
148
148
  if (!objId) {
149
- const folder = path_1.join(this.accessFolder, ROOT_OBJ_DIR);
149
+ const folder = (0, path_1.join)(this.accessFolder, ROOT_OBJ_DIR);
150
150
  return this.syncProcs.startOrChain(ROOT_OBJ_DIR, async () => {
151
151
  if (await folderExists(folder)) {
152
152
  return folder;
@@ -176,7 +176,7 @@ class ObjFolders {
176
176
  });
177
177
  }
178
178
  removeFolderOf(objId) {
179
- assert_1.assert(!!objId, `Root object can't be removed.`);
179
+ (0, assert_1.assert)(!!objId, `Root object can't be removed.`);
180
180
  const pathSections = this.idToPathSections(objId);
181
181
  return this.syncProcs.startOrChain(pathSections[0], async () => {
182
182
  const found = await this.findObjFolder(pathSections);
@@ -191,10 +191,10 @@ class ObjFolders {
191
191
  async listRecent() {
192
192
  const lst = (await allTreePaths(this.accessFolder, this.numOfSplits, this.logError))
193
193
  .map(pathSections => ({
194
- path: path_1.join(this.accessFolder, ...pathSections),
194
+ path: (0, path_1.join)(this.accessFolder, ...pathSections),
195
195
  objId: pathSections.join('')
196
196
  }));
197
- const rootObjPath = path_1.join(this.accessFolder, ROOT_OBJ_DIR);
197
+ const rootObjPath = (0, path_1.join)(this.accessFolder, ROOT_OBJ_DIR);
198
198
  if (await fs.existsFolder(rootObjPath)) {
199
199
  lst.unshift({ objId: null, path: rootObjPath });
200
200
  }
@@ -219,7 +219,7 @@ class RotationsProc {
219
219
  this.setNextCacheRotation(secs);
220
220
  }
221
221
  genBacketPath(backetIndex) {
222
- return path_1.join(this.generationsFolder, `${backetIndex}`);
222
+ return (0, path_1.join)(this.generationsFolder, `${backetIndex}`);
223
223
  }
224
224
  setNextCacheRotation(secs) {
225
225
  setTimeout(async () => {
@@ -251,7 +251,7 @@ class RotationsProc {
251
251
  for (let i = 0; i < objPathSections.length; i += 1) {
252
252
  const sections = objPathSections[i];
253
253
  const objId = sections.join('');
254
- const objFolderPath = path_1.join(srcBacket, ...sections);
254
+ const objFolderPath = (0, path_1.join)(srcBacket, ...sections);
255
255
  await this.syncProcs.startOrChain(sections[0], async () => {
256
256
  if (!(await this.canMove(objId, objFolderPath))) {
257
257
  return;
@@ -266,7 +266,7 @@ class RotationsProc {
266
266
  const objPathSections = await allTreePaths(srcBacket, this.numOfSplits, this.logError);
267
267
  for (let i = 0; i < objPathSections.length; i += 1) {
268
268
  const sections = objPathSections[i];
269
- const srcObjPath = path_1.join(srcBacket, ...sections);
269
+ const srcObjPath = (0, path_1.join)(srcBacket, ...sections);
270
270
  await this.syncProcs.startOrChain(sections[0], async () => {
271
271
  if (!(await folderExists(srcObjPath))) {
272
272
  return;
@@ -287,7 +287,7 @@ Object.freeze(RotationsProc);
287
287
  * @param pathSections
288
288
  */
289
289
  async function makeTreeExclusively(base, pathSections) {
290
- assert_1.assert(pathSections.length > 0);
290
+ (0, assert_1.assert)(pathSections.length > 0);
291
291
  const treePaths = treePathsFor(base, pathSections);
292
292
  const intermediateFolders = treePaths.slice(0, treePaths.length - 1);
293
293
  await makeFoldersNonexclusively(intermediateFolders);
@@ -306,7 +306,7 @@ async function makeTreeExclusively(base, pathSections) {
306
306
  * @param pathSections
307
307
  */
308
308
  async function deleteTree(base, pathSections) {
309
- assert_1.assert(pathSections.length > 0);
309
+ (0, assert_1.assert)(pathSections.length > 0);
310
310
  const treePaths = treePathsFor(base, pathSections);
311
311
  const intermediateFolders = treePaths.slice(0, treePaths.length - 1);
312
312
  const leafFolder = treePaths[treePaths.length - 1];
@@ -387,7 +387,7 @@ function treePathsFor(base, pathSections) {
387
387
  const paths = [];
388
388
  let path = base;
389
389
  for (let i = 0; i < pathSections.length; i += 1) {
390
- path = path_1.join(path, pathSections[i]);
390
+ path = (0, path_1.join)(path, pathSections[i]);
391
391
  paths.push(path);
392
392
  }
393
393
  return paths;
@@ -430,14 +430,14 @@ async function readJSONFile(path) {
430
430
  return JSON.parse(jsonStr);
431
431
  }
432
432
  catch (err) {
433
- throw error_1.errWithCause(err, `Can't parse json file ${path}`);
433
+ throw (0, error_1.errWithCause)(err, `Can't parse json file ${path}`);
434
434
  }
435
435
  }
436
436
  async function readCfgFrom(path) {
437
- const cfg = await readJSONFile(path_1.join(path, CONFIG_FILE));
438
- const accessDir = path_1.join(path, ACCESS_DIR);
437
+ const cfg = await readJSONFile((0, path_1.join)(path, CONFIG_FILE));
438
+ const accessDir = (0, path_1.join)(path, ACCESS_DIR);
439
439
  const accessDirFound = await folderExists(accessDir);
440
- const gensDir = path_1.join(path, GENERATIONS_DIR);
440
+ const gensDir = (0, path_1.join)(path, GENERATIONS_DIR);
441
441
  const gensDirFound = await folderExists(gensDir);
442
442
  if (cfg === undefined) {
443
443
  if (accessDirFound || (gensDirFound)) {
@@ -455,24 +455,24 @@ async function readCfgFrom(path) {
455
455
  }
456
456
  async function writeCfgTo(path, cfg) {
457
457
  try {
458
- await fs.writeFile(path_1.join(path, CONFIG_FILE), JSON.stringify(cfg), { encoding: 'utf8' });
458
+ await fs.writeFile((0, path_1.join)(path, CONFIG_FILE), JSON.stringify(cfg), { encoding: 'utf8' });
459
459
  }
460
460
  catch (err) {
461
461
  if (!err.notFound) {
462
462
  throw err;
463
463
  }
464
464
  await fs.ensureFolderExists(path);
465
- await fs.writeFile(path_1.join(path, CONFIG_FILE), JSON.stringify(cfg), { encoding: 'utf8' });
465
+ await fs.writeFile((0, path_1.join)(path, CONFIG_FILE), JSON.stringify(cfg), { encoding: 'utf8' });
466
466
  }
467
467
  }
468
468
  function checkCfg(cfg, needGens = false) {
469
- assert_1.assert(Number.isInteger(cfg.numOfSplits) && (cfg.numOfSplits > 0), `Invalid numOfSplits in object folders' configuration: ${cfg.numOfSplits}`);
470
- assert_1.assert(Number.isInteger(cfg.charsInSplit) && (cfg.charsInSplit > 0), `Invalid charsInSplit in object folders' configuration: ${cfg.charsInSplit}`);
471
- assert_1.assert(cfg.numOfSplits * cfg.charsInSplit < Math.floor(xsp_files_1.NONCE_LENGTH / 3 * 4), `Invalid splits configuration, expecting too many letters in object id`);
469
+ (0, assert_1.assert)(Number.isInteger(cfg.numOfSplits) && (cfg.numOfSplits > 0), `Invalid numOfSplits in object folders' configuration: ${cfg.numOfSplits}`);
470
+ (0, assert_1.assert)(Number.isInteger(cfg.charsInSplit) && (cfg.charsInSplit > 0), `Invalid charsInSplit in object folders' configuration: ${cfg.charsInSplit}`);
471
+ (0, assert_1.assert)(cfg.numOfSplits * cfg.charsInSplit < Math.floor(xsp_files_1.NONCE_LENGTH / 3 * 4), `Invalid splits configuration, expecting too many letters in object id`);
472
472
  if (needGens) {
473
473
  const gens = cfg.generations;
474
- assert_1.assert(Array.isArray(gens), `Invalid generations in object folders' configuration: ${gens}`);
475
- assert_1.assert(gens.length > 0, `Config must have at least one generation`);
474
+ (0, assert_1.assert)(Array.isArray(gens), `Invalid generations in object folders' configuration: ${gens}`);
475
+ (0, assert_1.assert)(gens.length > 0, `Config must have at least one generation`);
476
476
  }
477
477
  }
478
478
  async function allTreePaths(path, numOfSplits, logError) {
@@ -495,7 +495,7 @@ async function allTreePaths(path, numOfSplits, logError) {
495
495
  if (f === ROOT_OBJ_DIR) {
496
496
  continue;
497
497
  }
498
- const treePaths = await allTreePaths(path_1.join(path, f), numOfSplits - 1, logError);
498
+ const treePaths = await allTreePaths((0, path_1.join)(path, f), numOfSplits - 1, logError);
499
499
  for (let j = 0; j < treePaths.length; j += 1) {
500
500
  const branch = treePaths[j];
501
501
  branch.unshift(f);
@@ -2,7 +2,8 @@ import { ObjId } from '../3nstorage/xsp-fs/common';
2
2
  import { ObjSource, Subscribe, Layout } from 'xsp-files';
3
3
  import { FileWrite } from './file-writing-proc';
4
4
  import { Observable } from 'rxjs';
5
- import { NotOnDiskFiniteChunk } from '../../lib-common/objs-on-disk/file-layout';
5
+ import { NotOnDiskFiniteChunk, FiniteChunk } from '../../lib-common/objs-on-disk/file-layout';
6
+ import { DiffInfo } from '../../lib-common/service-api/3nstorage/owner';
6
7
  export declare type GetBaseSegsOnDisk = (version: number, ofs: number, len: number) => Promise<(Uint8Array | NotOnDiskFiniteChunk)[]>;
7
8
  export declare class ObjOnDisk {
8
9
  readonly objId: ObjId;
@@ -11,6 +12,7 @@ export declare class ObjOnDisk {
11
12
  private readonly downloader;
12
13
  private readable;
13
14
  private readonly getBaseSegsOnDisk;
15
+ private proxiedHeader;
14
16
  private constructor();
15
17
  static forExistingFile(objId: ObjId, version: number, path: string, downloader?: ObjDownloader, getBase?: GetBaseSegsOnDisk): Promise<ObjOnDisk>;
16
18
  static createFileForExistingVersion(objId: ObjId, version: number, path: string, downloader: ObjDownloader, getBase?: GetBaseSegsOnDisk, initDownload?: InitDownloadParts): Promise<ObjOnDisk>;
@@ -18,7 +20,11 @@ export declare class ObjOnDisk {
18
20
  obj: ObjOnDisk;
19
21
  write$: Observable<FileWrite[]>;
20
22
  }>;
21
- moveFile(newPath: string): Promise<void>;
23
+ moveFileAndProxyThis(newPath: string, objVersionChange: {
24
+ version: number;
25
+ newHeader: Uint8Array;
26
+ originalHeader: Uint8Array;
27
+ } | undefined): Promise<ObjOnDisk>;
22
28
  removeFile(): Promise<void>;
23
29
  private readHeader;
24
30
  private readSegs;
@@ -27,6 +33,11 @@ export declare class ObjOnDisk {
27
33
  private downloadAndSaveSegsChunk;
28
34
  getSrc(): ObjSource;
29
35
  getBaseVersion(): number | undefined;
36
+ absorbImmediateBaseVersion(baseVer: number, path: string): Promise<void>;
37
+ diffFromBase(): {
38
+ diff: DiffInfo;
39
+ newSegsPackOrder: FiniteChunk[];
40
+ };
30
41
  }
31
42
  export interface ObjDownloader {
32
43
  getLayoutWithHeaderAndFirstSegs(objId: ObjId, version: number): Promise<InitDownloadParts>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2018 - 2020 3NSoft Inc.
3
+ Copyright (C) 2018 - 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
@@ -32,6 +32,7 @@ class ObjOnDisk {
32
32
  this.downloader = downloader;
33
33
  this.readable = readable;
34
34
  this.getBaseSegsOnDisk = getBaseSegsOnDisk;
35
+ this.proxiedHeader = undefined;
35
36
  Object.seal(this);
36
37
  }
37
38
  static async forExistingFile(objId, version, path, downloader, getBase) {
@@ -61,20 +62,28 @@ class ObjOnDisk {
61
62
  const objFile = await obj_file_1.ObjVersionFile.createNew(path);
62
63
  const obj = new ObjOnDisk(objId, version, objFile, downloader, false, getBase);
63
64
  const write$ = file_writing_proc_1.FileWritingProc.makeFor(objFile, encSub)
64
- .pipe(operators_1.tap({
65
+ .pipe((0, operators_1.tap)({
65
66
  complete: () => {
66
67
  obj.readable = true;
67
68
  }
68
- }), utils_for_observables_1.flatTap(undefined, () => objFile.removeFile()), utils_for_observables_1.allowOnlySingleStart());
69
+ }), (0, utils_for_observables_1.flatTap)(undefined, () => objFile.removeFile()), (0, utils_for_observables_1.allowOnlySingleStart)());
69
70
  return { obj, write$ };
70
71
  }
71
- async moveFile(newPath) {
72
- await this.objFile.moveFile(newPath);
72
+ async moveFileAndProxyThis(newPath, objVersionChange) {
73
+ const newObjOnDisk = new ObjOnDisk(this.objId, (objVersionChange ? objVersionChange.version : this.version), this.objFile, this.downloader, this.readable, this.getBaseSegsOnDisk);
74
+ if (objVersionChange) {
75
+ this.proxiedHeader = objVersionChange.originalHeader;
76
+ }
77
+ await this.objFile.moveFile(newPath, objVersionChange === null || objVersionChange === void 0 ? void 0 : objVersionChange.newHeader);
78
+ return newObjOnDisk;
73
79
  }
74
80
  async removeFile() {
75
81
  await this.objFile.removeFile();
76
82
  }
77
83
  async readHeader() {
84
+ if (this.proxiedHeader) {
85
+ return this.proxiedHeader;
86
+ }
78
87
  let h = await this.objFile.readHeader();
79
88
  if (h) {
80
89
  return h;
@@ -99,7 +108,7 @@ class ObjOnDisk {
99
108
  bytes.push(chunkBytes);
100
109
  }
101
110
  }
102
- return buffer_utils_1.joinByteArrs(bytes);
111
+ return (0, buffer_utils_1.joinByteArrs)(bytes);
103
112
  }
104
113
  async readSegsOnlyFromDisk(offset, len) {
105
114
  const segsLocations = this.objFile.segsLocations(offset, len);
@@ -166,7 +175,7 @@ class ObjOnDisk {
166
175
  if (!this.readable) {
167
176
  throw new Error(`Version ${this.version} of obj ${this.objId} is not readable, yet`);
168
177
  }
169
- const segSrc = wrapping_1.wrapAndSyncSource(new ByteSourceFromObjOnDisk((ofs, len) => this.readSegs(ofs, len), () => this.objFile.getTotalSegsLen()));
178
+ const segSrc = (0, wrapping_1.wrapAndSyncSource)(new ByteSourceFromObjOnDisk((ofs, len) => this.readSegs(ofs, len), () => this.objFile.getTotalSegsLen()));
170
179
  const objSrc = {
171
180
  readHeader: () => this.readHeader(),
172
181
  segSrc,
@@ -177,6 +186,12 @@ class ObjOnDisk {
177
186
  getBaseVersion() {
178
187
  return this.objFile.getBaseVersion();
179
188
  }
189
+ absorbImmediateBaseVersion(baseVer, path) {
190
+ return this.objFile.absorbImmediateBaseVersion(baseVer, path);
191
+ }
192
+ diffFromBase() {
193
+ return this.objFile.diffFromBase();
194
+ }
180
195
  }
181
196
  exports.ObjOnDisk = ObjOnDisk;
182
197
  Object.freeze(ObjOnDisk.prototype);
@@ -189,7 +204,7 @@ class ByteSourceFromObjOnDisk {
189
204
  Object.seal(this);
190
205
  }
191
206
  async read(len) {
192
- assert_1.assert((Number.isInteger(len) && (len >= 0)) || (len === undefined), 'Illegal length parameter given: ' + len);
207
+ (0, assert_1.assert)((Number.isInteger(len) && (len >= 0)) || (len === undefined), 'Illegal length parameter given: ' + len);
193
208
  const start = this.segsPointer;
194
209
  if (len === undefined) {
195
210
  const segsLen = this.totalSegsLen();
@@ -211,7 +226,7 @@ class ByteSourceFromObjOnDisk {
211
226
  { size, isEndless: false } : { size: 0, isEndless: true });
212
227
  }
213
228
  async seek(offset) {
214
- assert_1.assert(Number.isInteger(offset) && (offset >= 0), 'Illegal offset is given to seek: ' + offset);
229
+ (0, assert_1.assert)(Number.isInteger(offset) && (offset >= 0), 'Illegal offset is given to seek: ' + offset);
215
230
  const segsLen = this.totalSegsLen();
216
231
  if (segsLen === undefined) {
217
232
  this.segsPointer = offset;
@@ -1,4 +1,5 @@
1
1
  /// <reference types="node" />
2
+ /// <reference types="node" />
2
3
  import { HTTPException } from '../lib-common/exceptions/http';
3
4
  import * as https from 'https';
4
5
  import { ClientRequest } from 'http';
@@ -30,7 +30,7 @@ async function processRequest(requester, httpsOpts, opts, reqBody, attempt = 0)
30
30
  try {
31
31
  const req = requester(httpsOpts);
32
32
  const resPromise = attachRequestReaders(req, opts);
33
- req.end(reqBody ? buffer_utils_1.toBuffer(reqBody) : undefined);
33
+ req.end(reqBody ? (0, buffer_utils_1.toBuffer)(reqBody) : undefined);
34
34
  const { res, resBody } = await resPromise;
35
35
  const rep = formReply(res, resBody, opts);
36
36
  return rep;
@@ -51,7 +51,7 @@ function formHttpsReqOpts(opts, contentType, reqBody) {
51
51
  if (reqBody && (opts.method !== 'POST') && (opts.method !== 'PUT')) {
52
52
  throw new Error(`Cannot have body in ${opts.method} request.`);
53
53
  }
54
- const url = url_1.parse(opts.url);
54
+ const url = (0, url_1.parse)(opts.url);
55
55
  const netReqOpts = {
56
56
  protocol: url.protocol,
57
57
  method: opts.method,
@@ -78,14 +78,14 @@ function attachRequestReaders(clReq, opts) {
78
78
  // note that we attach reading of body to response as close as possible to
79
79
  // its appearance, so as not to miss any incoming data, which may happen if
80
80
  // next tick occurs in between.
81
- const response$ = rxjs_1.fromEvent(clReq, 'response', (res) => ({ res, resBodyPromise: readAllBytesFrom(res) }))
82
- .pipe(operators_1.take(1));
83
- const err$ = rxjs_1.fromEvent(clReq, 'error')
84
- .pipe(operators_1.map(e => {
85
- throw http_1.makeConnectionException(opts.url, opts.method, 'Cannot connect', e);
86
- }), operators_1.takeUntil(response$));
87
- return rxjs_1.merge(response$, err$)
88
- .pipe(operators_1.mergeMap(async (resAndBodyProm) => {
81
+ const response$ = (0, rxjs_1.fromEvent)(clReq, 'response', (res) => ({ res, resBodyPromise: readAllBytesFrom(res) }))
82
+ .pipe((0, operators_1.take)(1));
83
+ const err$ = (0, rxjs_1.fromEvent)(clReq, 'error')
84
+ .pipe((0, operators_1.map)(e => {
85
+ throw (0, http_1.makeConnectionException)(opts.url, opts.method, 'Cannot connect', e);
86
+ }), (0, operators_1.takeUntil)(response$));
87
+ return (0, rxjs_1.merge)(response$, err$)
88
+ .pipe((0, operators_1.mergeMap)(async (resAndBodyProm) => {
89
89
  const { res, resBodyPromise } = resAndBodyProm;
90
90
  const resBody = await resBodyPromise;
91
91
  return { res, resBody };
@@ -109,7 +109,7 @@ function isTimeoutErr(err, opts, currentAttempt) {
109
109
  }
110
110
  async function readAllBytesFrom(stream) {
111
111
  const buf = new bytes_fifo_buffer_1.BytesFIFOBuffer();
112
- const deferred = deferred_1.defer();
112
+ const deferred = (0, deferred_1.defer)();
113
113
  stream.on('error', e => deferred.reject(e));
114
114
  stream.on('data', chunk => buf.push(chunk));
115
115
  stream.on('end', () => deferred.resolve(buf.getBytes(undefined)));
@@ -131,7 +131,7 @@ function formReply(res, resBody, reqOpts) {
131
131
  }
132
132
  catch (err) {
133
133
  if (resContentType === 'application/json') {
134
- throw http_1.makeHTTPException(reqOpts.url, reqOpts.method, status, `Cannot parse received bytes`, err);
134
+ throw (0, http_1.makeHTTPException)(reqOpts.url, reqOpts.method, status, `Cannot parse received bytes`, err);
135
135
  }
136
136
  }
137
137
  }
@@ -171,7 +171,7 @@ function makeHeaders(headers) {
171
171
  * @return http exception based on given reply, with an optional message
172
172
  */
173
173
  function makeException(rep, errMsg) {
174
- return http_1.makeHTTPException(rep.url, rep.method, rep.status, errMsg);
174
+ return (0, http_1.makeHTTPException)(rep.url, rep.method, rep.status, errMsg);
175
175
  }
176
176
  exports.makeException = makeException;
177
177
  function extractIntHeader(rep, headerName) {
@@ -1,6 +1,6 @@
1
1
  import { SubscribingClient } from '../lib-common/ipc/generic-ipc';
2
2
  import { Observable } from 'rxjs';
3
- export declare class ServerEvents {
3
+ export declare class ServerEvents<N extends string, T> {
4
4
  private subscribeToServer;
5
5
  private restartWaitSecs;
6
6
  private server;
@@ -8,9 +8,9 @@ export declare class ServerEvents {
8
8
  constructor(subscribeToServer: () => Promise<SubscribingClient>, restartWaitSecs: number);
9
9
  /**
10
10
  * This method creates an observable of server's events.
11
- * @param serverEvent is an event on server, to which to subscribe.
11
+ * @param event is an event on server, to which to subscribe.
12
12
  */
13
- observe<T>(event: string): Observable<T>;
13
+ observe(event: N): Observable<T>;
14
14
  private setServer;
15
15
  private shouldRestartAfterErr;
16
16
  private restartObservation;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2017, 2019 3NSoft Inc.
3
+ Copyright (C) 2017, 2019, 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
@@ -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.ServerEvents = void 0;
19
20
  const rxjs_1 = require("rxjs");
@@ -31,7 +32,7 @@ class ServerEvents {
31
32
  }
32
33
  /**
33
34
  * This method creates an observable of server's events.
34
- * @param serverEvent is an event on server, to which to subscribe.
35
+ * @param event is an event on server, to which to subscribe.
35
36
  */
36
37
  observe(event) {
37
38
  const event$ = new rxjs_1.Observable(observer => {
@@ -70,13 +71,13 @@ class ServerEvents {
70
71
  }
71
72
  };
72
73
  })
73
- .pipe(operators_1.catchError(err => {
74
+ .pipe((0, operators_1.catchError)(err => {
74
75
  if (this.shouldRestartAfterErr(err)) {
75
- console.error(error_1.stringifyErr(err));
76
+ console.error((0, error_1.stringifyErr)(err));
76
77
  return this.restartObservation(event);
77
78
  }
78
79
  else {
79
- return rxjs_1.throwError(err);
80
+ return (0, rxjs_1.throwError)(err);
80
81
  }
81
82
  }));
82
83
  return event$;
@@ -107,8 +108,8 @@ class ServerEvents {
107
108
  }
108
109
  }
109
110
  restartObservation(event) {
110
- return rxjs_1.from(sleep_1.sleep(this.restartWaitSecs * 1000))
111
- .pipe(operators_1.mergeMap(() => this.observe(event)));
111
+ return (0, rxjs_1.from)((0, sleep_1.sleep)(this.restartWaitSecs * 1000))
112
+ .pipe((0, operators_1.mergeMap)(() => this.observe(event)));
112
113
  }
113
114
  }
114
115
  exports.ServerEvents = ServerEvents;
@@ -21,7 +21,7 @@ const jwkeys_1 = require("../lib-common/jwkeys");
21
21
  const url_1 = require("url");
22
22
  const request_utils_1 = require("./request-utils");
23
23
  async function readJSONLocatedAt(client, url) {
24
- if (url_1.parse(url).protocol !== 'https:') {
24
+ if ((0, url_1.parse)(url).protocol !== 'https:') {
25
25
  throw new Error("Url protocol must be https.");
26
26
  }
27
27
  const rep = await client.doBodylessRequest({
@@ -31,20 +31,20 @@ async function readJSONLocatedAt(client, url) {
31
31
  });
32
32
  if (rep.status === 200) {
33
33
  if (!rep.data) {
34
- throw request_utils_1.makeException(rep, 'Malformed reply');
34
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply');
35
35
  }
36
36
  return rep;
37
37
  }
38
38
  else {
39
- throw request_utils_1.makeException(rep, 'Unexpected status');
39
+ throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
40
40
  }
41
41
  }
42
42
  function transformPathToCompleteUri(url, path, rep) {
43
- const uInit = url_1.parse(url);
43
+ const uInit = (0, url_1.parse)(url);
44
44
  const protoAndHost = `${uInit.protocol}//${uInit.host}`;
45
- const uPath = url_1.parse(path);
45
+ const uPath = (0, url_1.parse)(path);
46
46
  if (!uPath.path || !uPath.href || !uPath.href.startsWith(uPath.path)) {
47
- throw request_utils_1.makeException(rep, `Malformed path parameter ${path}`);
47
+ throw (0, request_utils_1.makeException)(rep, `Malformed path parameter ${path}`);
48
48
  }
49
49
  if (uPath.href.startsWith('/')) {
50
50
  return `${protoAndHost}${uPath.href}`;
@@ -88,15 +88,15 @@ async function mailerIdInfoAt(client, url) {
88
88
  transform.provisioning = transformPathToCompleteUri(url, json.provisioning, rep);
89
89
  }
90
90
  else {
91
- throw request_utils_1.makeException(rep, 'Malformed reply');
91
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply');
92
92
  }
93
93
  if (('object' === typeof json["current-cert"]) &&
94
- jwkeys_1.isLikeSignedKeyCert(json["current-cert"])) {
94
+ (0, jwkeys_1.isLikeSignedKeyCert)(json["current-cert"])) {
95
95
  transform.currentCert = json["current-cert"];
96
96
  transform.previousCerts = json["previous-certs"];
97
97
  }
98
98
  else {
99
- throw request_utils_1.makeException(rep, 'Malformed reply');
99
+ throw (0, request_utils_1.makeException)(rep, 'Malformed reply');
100
100
  }
101
101
  Object.freeze(transform);
102
102
  return transform;
@@ -223,7 +223,7 @@ exports.makeServiceLocator = makeServiceLocator;
223
223
  */
224
224
  async function getMailerIdInfoFor(resolver, client, address) {
225
225
  const serviceURL = await resolver(address);
226
- const rootAddr = url_1.parse(serviceURL).hostname;
226
+ const rootAddr = (0, url_1.parse)(serviceURL).hostname;
227
227
  const info = await mailerIdInfoAt(client, serviceURL);
228
228
  return {
229
229
  info: info,
@@ -8,7 +8,7 @@ import * as WebSocket from 'ws';
8
8
  export declare type IGetMailerIdSigner = () => Promise<mid.MailerIdSigner>;
9
9
  export declare abstract class ServiceUser {
10
10
  readonly userId: string;
11
- private readonly getSigner;
11
+ private getSigner;
12
12
  private getInitServiceURI;
13
13
  protected readonly net: NetClient;
14
14
  private uri;
@@ -28,6 +28,7 @@ export declare abstract class ServiceUser {
28
28
  }, getSigner: IGetMailerIdSigner | undefined, getInitServiceURI: () => Promise<string>, net: NetClient);
29
29
  private get isUriSet();
30
30
  private throwOnBadServiceURI;
31
+ protected setGetterOfSigner(getSigner: IGetMailerIdSigner): void;
31
32
  /**
32
33
  * This initializes service uri, if it hasn't been set, yet.
33
34
  * Else, this function does nothing.
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2015, 2017, 2020 3NSoft Inc.
3
+ Copyright (C) 2015, 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
@@ -49,7 +49,7 @@ class ServiceUser {
49
49
  return this.uri;
50
50
  }
51
51
  set serviceURI(uriString) {
52
- const u = url_1.parse(uriString);
52
+ const u = (0, url_1.parse)(uriString);
53
53
  if (u.protocol !== 'https:') {
54
54
  throw new Error("Url protocol must be https.");
55
55
  }
@@ -72,6 +72,12 @@ class ServiceUser {
72
72
  throw new Error(`Service uri is not a string: ${this.serviceURI}`);
73
73
  }
74
74
  }
75
+ setGetterOfSigner(getSigner) {
76
+ if (this.getSigner) {
77
+ throw new Error(`getSigner is already set`);
78
+ }
79
+ this.getSigner = getSigner;
80
+ }
75
81
  /**
76
82
  * This initializes service uri, if it hasn't been set, yet.
77
83
  * Else, this function does nothing.
@@ -86,7 +92,7 @@ class ServiceUser {
86
92
  async startSession() {
87
93
  this.throwOnBadServiceURI();
88
94
  // make first call
89
- const fstReply = await login_1.startMidSession(this.userId, this.net, this.loginUrl);
95
+ const fstReply = await (0, login_1.startMidSession)(this.userId, this.net, this.loginUrl);
90
96
  if (fstReply.sessionId) {
91
97
  return fstReply.sessionId;
92
98
  }
@@ -94,10 +100,10 @@ class ServiceUser {
94
100
  throw new Error(`Service ${this.serviceURI} redirects on MailerId login, while redirect is not allowed`);
95
101
  }
96
102
  // following redirect
97
- assert_1.assert(!!fstReply.redirect);
103
+ (0, assert_1.assert)(!!fstReply.redirect);
98
104
  this.redirectedFrom = this.serviceURI;
99
105
  this.serviceURI = fstReply.redirect;
100
- const sndReply = await login_1.startMidSession(this.userId, this.net, this.loginUrl);
106
+ const sndReply = await (0, login_1.startMidSession)(this.userId, this.net, this.loginUrl);
101
107
  if (sndReply.sessionId) {
102
108
  return sndReply.sessionId;
103
109
  }
@@ -107,7 +113,7 @@ class ServiceUser {
107
113
  }
108
114
  async authenticateSession(sessionId, midSigner) {
109
115
  this.throwOnBadServiceURI();
110
- await login_1.authenticateMidSession(sessionId, midSigner, this.net, this.loginUrl);
116
+ await (0, login_1.authenticateMidSession)(sessionId, midSigner, this.net, this.loginUrl);
111
117
  }
112
118
  /**
113
119
  * This starts and authorizes a new session.
@@ -156,7 +162,7 @@ class ServiceUser {
156
162
  this.sessionId = undefined;
157
163
  }
158
164
  else {
159
- throw request_utils_1.makeException(rep, 'Unexpected status');
165
+ throw (0, request_utils_1.makeException)(rep, 'Unexpected status');
160
166
  }
161
167
  }
162
168
  async callEnsuringLogin(func) {
@@ -215,7 +221,7 @@ class ServiceUser {
215
221
  };
216
222
  return this.callEnsuringLogin(() => {
217
223
  this.prepCallOpts(opts, true);
218
- return ws_utils_1.openSocket(opts.url, opts.sessionId);
224
+ return (0, ws_utils_1.openSocket)(opts.url, opts.sessionId);
219
225
  });
220
226
  }
221
227
  }