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
@@ -0,0 +1,18 @@
1
+ declare type WritableFS = web3n.files.WritableFS;
2
+ declare type FSItem = web3n.files.FSItem;
3
+ export declare const sysFolders: {
4
+ appData: string;
5
+ apps: string;
6
+ packages: string;
7
+ sharedLibs: string;
8
+ userFiles: string;
9
+ };
10
+ /**
11
+ * This function creates system folder structure in a given root.
12
+ * Folder objects are uploaded, if it is a synced root.
13
+ * @param root
14
+ */
15
+ export declare function initSysFolders(root: WritableFS): Promise<void>;
16
+ export declare function userFilesOnDevice(): Promise<WritableFS>;
17
+ export declare function sysFilesOnDevice(): Promise<FSItem>;
18
+ export {};
@@ -0,0 +1,77 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2022 3NSoft Inc.
4
+
5
+ This program is free software: you can redistribute it and/or modify it under
6
+ the terms of the GNU General Public License as published by the Free Software
7
+ Foundation, either version 3 of the License, or (at your option) any later
8
+ version.
9
+
10
+ This program is distributed in the hope that it will be useful, but
11
+ WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
+ See the GNU General Public License for more details.
14
+
15
+ You should have received a copy of the GNU General Public License along with
16
+ this program. If not, see <http://www.gnu.org/licenses/>.
17
+ */
18
+ Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.sysFilesOnDevice = exports.userFilesOnDevice = exports.initSysFolders = exports.sysFolders = void 0;
20
+ const fs_collection_1 = require("../../../lib-client/fs-collection");
21
+ const lib_index_1 = require("../../../lib-index");
22
+ exports.sysFolders = {
23
+ appData: 'Apps Data',
24
+ apps: 'Apps Code',
25
+ packages: 'App&Lib Packs',
26
+ sharedLibs: 'Shared Libs',
27
+ userFiles: 'User Files'
28
+ };
29
+ Object.freeze(exports.sysFolders);
30
+ /**
31
+ * This function creates system folder structure in a given root.
32
+ * Folder objects are uploaded, if it is a synced root.
33
+ * @param root
34
+ */
35
+ async function initSysFolders(root) {
36
+ var _a, _b;
37
+ for (const sysFolder of Object.values(exports.sysFolders)) {
38
+ await root.makeFolder(sysFolder);
39
+ if ((_a = root.v) === null || _a === void 0 ? void 0 : _a.sync) {
40
+ // XXX must add work with not-online condition
41
+ await root.v.sync.upload(sysFolder);
42
+ }
43
+ }
44
+ if ((_b = root.v) === null || _b === void 0 ? void 0 : _b.sync) {
45
+ // XXX must add work with not-online condition
46
+ await root.v.sync.upload('.');
47
+ }
48
+ }
49
+ exports.initSysFolders = initSysFolders;
50
+ async function userFilesOnDevice() {
51
+ if (process.platform === 'win32') {
52
+ return lib_index_1.DeviceFS.makeWritable(process.env.USERPROFILE);
53
+ }
54
+ else {
55
+ return lib_index_1.DeviceFS.makeWritable(process.env.HOME);
56
+ }
57
+ }
58
+ exports.userFilesOnDevice = userFilesOnDevice;
59
+ async function sysFilesOnDevice() {
60
+ const c = (0, fs_collection_1.makeFSCollection)();
61
+ if (process.platform === 'win32') {
62
+ const sysDrive = process.env.SystemDrive;
63
+ await c.set(sysDrive, {
64
+ isFolder: true,
65
+ item: await lib_index_1.DeviceFS.makeWritable(sysDrive)
66
+ });
67
+ }
68
+ else {
69
+ await c.set('', {
70
+ isFolder: true,
71
+ item: await lib_index_1.DeviceFS.makeWritable('/')
72
+ });
73
+ }
74
+ return { isCollection: true, item: c };
75
+ }
76
+ exports.sysFilesOnDevice = sysFilesOnDevice;
77
+ Object.freeze(exports);
@@ -30,7 +30,7 @@ function exposeW3N(coreSide, w3n, extraCAPs) {
30
30
  mailerid: mailerid_1.exposeMailerIdCAP,
31
31
  storage: storage_cap_1.exposeStorageCAP,
32
32
  };
33
- generic_1.exposeCAPs(coreSide, w3n, commonCAPsExposures, extraCAPs);
33
+ (0, generic_1.exposeCAPs)(coreSide, w3n, commonCAPsExposures, extraCAPs);
34
34
  }
35
35
  exports.exposeW3N = exposeW3N;
36
36
  // This is not used, but it ensures that some require runs, providing function
@@ -43,7 +43,7 @@ function makeW3Nclient(clientSide, extraCAPs) {
43
43
  mailerid: mailerid_1.makeMailerIdCaller,
44
44
  storage: storage_cap_1.makeStorageCaller,
45
45
  };
46
- return generic_1.makeClientSide(clientSide, mainCAPs, extraCAPs);
46
+ return (0, generic_1.makeClientSide)(clientSide, mainCAPs, extraCAPs);
47
47
  }
48
48
  exports.makeW3Nclient = makeW3Nclient;
49
49
  function promiseW3Nclient(clientSide, extraCAPs) {
@@ -53,7 +53,7 @@ function promiseW3Nclient(clientSide, extraCAPs) {
53
53
  mailerid: mailerid_1.makeMailerIdCaller,
54
54
  storage: storage_cap_1.promiseStorageCaller,
55
55
  };
56
- return generic_1.promiseClientSide(clientSide, mainCAPs, extraCAPs);
56
+ return (0, generic_1.promiseClientSide)(clientSide, mainCAPs, extraCAPs);
57
57
  }
58
58
  exports.promiseW3Nclient = promiseW3Nclient;
59
59
  Object.freeze(exports);
@@ -31,8 +31,8 @@ exports.exposeCAPs = exposeCAPs;
31
31
  function addCAPsInExposure(expW3N, coreSide, w3n, capExposures) {
32
32
  for (const capName in capExposures) {
33
33
  const expose = capExposures[capName];
34
- assert_1.assert(typeof expose === 'function');
35
- assert_1.assert(!expW3N[capName], `Capability ${capName} is already exposed, and we specifically have no shadowing.`);
34
+ (0, assert_1.assert)(typeof expose === 'function');
35
+ (0, assert_1.assert)(!expW3N[capName], `Capability ${capName} is already exposed, and we specifically have no shadowing.`);
36
36
  const cap = w3n[capName];
37
37
  if (cap) {
38
38
  expW3N[capName] = expose(cap, coreSide);
@@ -40,7 +40,7 @@ function addCAPsInExposure(expW3N, coreSide, w3n, capExposures) {
40
40
  }
41
41
  }
42
42
  function makeClientSide(clientSide, mainCAPs, extraCAPs) {
43
- assert_1.assert(!!clientSide.listObj);
43
+ (0, assert_1.assert)(!!clientSide.listObj);
44
44
  const objPath = [connector_1.W3N_NAME];
45
45
  const lstOfCAPs = clientSide.listObj(objPath);
46
46
  const w3n = {};
@@ -48,12 +48,12 @@ function makeClientSide(clientSide, mainCAPs, extraCAPs) {
48
48
  const capObjPath = objPath.concat(cap);
49
49
  if (mainCAPs[cap]) {
50
50
  const makeCap = mainCAPs[cap];
51
- assert_1.assert(typeof makeCap === 'function');
51
+ (0, assert_1.assert)(typeof makeCap === 'function');
52
52
  w3n[cap] = makeCap(clientSide, capObjPath);
53
53
  }
54
54
  else if (extraCAPs) {
55
55
  const makeCap = extraCAPs[cap];
56
- assert_1.assert(typeof makeCap === 'function');
56
+ (0, assert_1.assert)(typeof makeCap === 'function');
57
57
  w3n[cap] = makeCap(clientSide, capObjPath);
58
58
  }
59
59
  }
@@ -61,7 +61,7 @@ function makeClientSide(clientSide, mainCAPs, extraCAPs) {
61
61
  }
62
62
  exports.makeClientSide = makeClientSide;
63
63
  async function promiseClientSide(clientSide, mainCAPs, extraCAPs) {
64
- assert_1.assert(!!clientSide.listObjAsync);
64
+ (0, assert_1.assert)(!!clientSide.listObjAsync);
65
65
  const objPath = [connector_1.W3N_NAME];
66
66
  const lstOfCAPs = (await clientSide.listObjAsync(objPath));
67
67
  const w3n = {};
@@ -69,12 +69,12 @@ async function promiseClientSide(clientSide, mainCAPs, extraCAPs) {
69
69
  const capObjPath = objPath.concat(cap);
70
70
  if (mainCAPs[cap]) {
71
71
  const makeCap = mainCAPs[cap];
72
- assert_1.assert(typeof makeCap === 'function');
72
+ (0, assert_1.assert)(typeof makeCap === 'function');
73
73
  w3n[cap] = await makeCap(clientSide, capObjPath);
74
74
  }
75
75
  else if (extraCAPs) {
76
76
  const makeCap = extraCAPs[cap];
77
- assert_1.assert(typeof makeCap === 'function');
77
+ (0, assert_1.assert)(typeof makeCap === 'function');
78
78
  w3n[cap] = await makeCap(clientSide, capObjPath);
79
79
  }
80
80
  }
@@ -25,7 +25,7 @@ function exposeStartupW3N(coreSide, w3n, extraCAPs) {
25
25
  signIn: startup_cap_1.wrapSignInCAP,
26
26
  signUp: startup_cap_1.wrapSignUpCAP,
27
27
  };
28
- generic_1.exposeCAPs(coreSide, w3n, startupCAPsExposures, extraCAPs);
28
+ (0, generic_1.exposeCAPs)(coreSide, w3n, startupCAPsExposures, extraCAPs);
29
29
  }
30
30
  exports.exposeStartupW3N = exposeStartupW3N;
31
31
  // This is not used, but it ensures that some require runs, providing function
@@ -36,7 +36,7 @@ function makeStartupW3Nclient(clientSide, extraCAPs) {
36
36
  signIn: startup_cap_1.makeSignInCaller,
37
37
  signUp: startup_cap_1.makeSignUpCaller,
38
38
  };
39
- return generic_1.makeClientSide(clientSide, mainCAPs, extraCAPs);
39
+ return (0, generic_1.makeClientSide)(clientSide, mainCAPs, extraCAPs);
40
40
  }
41
41
  exports.makeStartupW3Nclient = makeStartupW3Nclient;
42
42
  Object.freeze(exports);
package/build/cryptors.js CHANGED
@@ -17,13 +17,17 @@
17
17
  */
18
18
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
19
19
  if (k2 === undefined) k2 = k;
20
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
20
+ var desc = Object.getOwnPropertyDescriptor(m, k);
21
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
22
+ desc = { enumerable: true, get: function() { return m[k]; } };
23
+ }
24
+ Object.defineProperty(o, k2, desc);
21
25
  }) : (function(o, m, k, k2) {
22
26
  if (k2 === undefined) k2 = k;
23
27
  o[k2] = m[k];
24
28
  }));
25
29
  var __exportStar = (this && this.__exportStar) || function(m, exports) {
26
- for (var p in m) if (p !== "default" && !exports.hasOwnProperty(p)) __createBinding(exports, m, p);
30
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
27
31
  };
28
32
  Object.defineProperty(exports, "__esModule", { value: true });
29
33
  __exportStar(require("./lib-client/cryptor/cryptor"), exports);
@@ -24,6 +24,7 @@ const connector_1 = require("./connector");
24
24
  const rxjs_1 = require("rxjs");
25
25
  const operators_1 = require("rxjs/operators");
26
26
  const fs_1 = require("./fs");
27
+ const utils_for_observables_1 = require("../lib-common/utils-for-observables");
27
28
  function exposeASMailCAP(cap, expServices) {
28
29
  const out = cap.delivery;
29
30
  const box = cap.inbox;
@@ -50,6 +51,7 @@ exports.exposeASMailCAP = exposeASMailCAP;
50
51
  function makeASMailCaller(caller, objPath) {
51
52
  const delivPath = objPath.concat('delivery');
52
53
  const inboxPath = objPath.concat('inbox');
54
+ const connectPath = objPath.concat('connect');
53
55
  return {
54
56
  getUserId: getUserId.makeCaller(caller, objPath),
55
57
  delivery: {
@@ -66,7 +68,7 @@ function makeASMailCaller(caller, objPath) {
66
68
  listMsgs: inboxListMsgs.makeCaller(caller, inboxPath),
67
69
  removeMsg: removeMsg.makeCaller(caller, inboxPath),
68
70
  subscribe: inboxSubscribe.makeCaller(caller, inboxPath)
69
- }
71
+ },
70
72
  };
71
73
  }
72
74
  exports.makeASMailCaller = makeASMailCaller;
@@ -75,7 +77,7 @@ var getUserId;
75
77
  function wrapService(fn) {
76
78
  return () => {
77
79
  const promise = fn()
78
- .then(userId => protobuf_msg_1.encodeToUtf8(userId));
80
+ .then(userId => (0, protobuf_msg_1.encodeToUtf8)(userId));
79
81
  return { promise };
80
82
  };
81
83
  }
@@ -85,9 +87,9 @@ var getUserId;
85
87
  return () => caller.startPromiseCall(path, undefined)
86
88
  .then(buf => {
87
89
  if (!buf) {
88
- throw connector_1.makeIPCException({ missingBodyBytes: true });
90
+ throw (0, connector_1.makeIPCException)({ missingBodyBytes: true });
89
91
  }
90
- return protobuf_msg_1.decodeFromUtf8(buf);
92
+ return (0, protobuf_msg_1.decodeFromUtf8)(buf);
91
93
  });
92
94
  }
93
95
  getUserId.makeCaller = makeCaller;
@@ -98,16 +100,16 @@ var inboxListMsgs;
98
100
  const requestType = protobuf_type_1.ProtoType.for(asmail_proto_1.asmail.ListMsgsRequestBody);
99
101
  const replyType = protobuf_type_1.ProtoType.for(asmail_proto_1.asmail.ListMsgsInboxReplyBody);
100
102
  function unpackMsgInfos(buf) {
101
- const msgs = protobuf_msg_1.fixArray(replyType.unpack(buf).infos);
103
+ const msgs = (0, protobuf_msg_1.fixArray)(replyType.unpack(buf).infos);
102
104
  for (const msg of msgs) {
103
- msg.deliveryTS = protobuf_msg_1.fixInt(msg.deliveryTS);
105
+ msg.deliveryTS = (0, protobuf_msg_1.fixInt)(msg.deliveryTS);
104
106
  }
105
107
  return msgs;
106
108
  }
107
109
  function wrapService(fn) {
108
110
  return (reqBody) => {
109
111
  const { fromTS } = requestType.unpack(reqBody);
110
- const promise = fn(protobuf_msg_1.valOfOptInt(fromTS))
112
+ const promise = fn((0, protobuf_msg_1.valOfOptInt)(fromTS))
111
113
  .then(infos => replyType.pack({ infos }));
112
114
  return { promise };
113
115
  };
@@ -116,7 +118,7 @@ var inboxListMsgs;
116
118
  function makeCaller(caller, objPath) {
117
119
  const path = objPath.concat('listMsgs');
118
120
  return fromTS => {
119
- const req = (fromTS ? { fromTS: protobuf_msg_1.toVal(fromTS) } : {});
121
+ const req = (fromTS ? { fromTS: (0, protobuf_msg_1.toVal)(fromTS) } : {});
120
122
  return caller
121
123
  .startPromiseCall(path, requestType.pack(req))
122
124
  .then(unpackMsgInfos);
@@ -174,14 +176,14 @@ function packIncomingMessage(m, expServices) {
174
176
  deliveryTS: m.deliveryTS,
175
177
  sender: m.sender,
176
178
  establishedSenderKeyChain: m.establishedSenderKeyChain,
177
- subject: protobuf_msg_1.toOptVal(m.subject),
178
- plainTxtBody: protobuf_msg_1.toOptVal(m.plainTxtBody),
179
- htmlTxtBody: protobuf_msg_1.toOptVal(m.htmlTxtBody),
180
- jsonBody: protobuf_msg_1.toOptJson(m.jsonBody),
179
+ subject: (0, protobuf_msg_1.toOptVal)(m.subject),
180
+ plainTxtBody: (0, protobuf_msg_1.toOptVal)(m.plainTxtBody),
181
+ htmlTxtBody: (0, protobuf_msg_1.toOptVal)(m.htmlTxtBody),
182
+ jsonBody: (0, protobuf_msg_1.toOptJson)(m.jsonBody),
181
183
  carbonCopy: m.carbonCopy,
182
184
  recipients: m.recipients,
183
185
  attachments: (m.attachments ?
184
- fs_1.exposeFSService(m.attachments, expServices) : undefined)
186
+ (0, fs_1.exposeFSService)(m.attachments, expServices) : undefined)
185
187
  };
186
188
  return incomingMessageType.pack(ipcMsg);
187
189
  }
@@ -190,17 +192,17 @@ function unpackIncomingMessage(buf, caller) {
190
192
  const msg = {
191
193
  msgType: ipcMsg.msgType,
192
194
  msgId: ipcMsg.msgId,
193
- deliveryTS: protobuf_msg_1.fixInt(ipcMsg.deliveryTS),
195
+ deliveryTS: (0, protobuf_msg_1.fixInt)(ipcMsg.deliveryTS),
194
196
  sender: ipcMsg.sender,
195
197
  establishedSenderKeyChain: ipcMsg.establishedSenderKeyChain,
196
- subject: protobuf_msg_1.valOfOpt(ipcMsg.subject),
197
- plainTxtBody: protobuf_msg_1.valOfOpt(ipcMsg.plainTxtBody),
198
- htmlTxtBody: protobuf_msg_1.valOfOpt(ipcMsg.htmlTxtBody),
199
- jsonBody: protobuf_msg_1.valOfOptJson(ipcMsg.jsonBody),
198
+ subject: (0, protobuf_msg_1.valOfOpt)(ipcMsg.subject),
199
+ plainTxtBody: (0, protobuf_msg_1.valOfOpt)(ipcMsg.plainTxtBody),
200
+ htmlTxtBody: (0, protobuf_msg_1.valOfOpt)(ipcMsg.htmlTxtBody),
201
+ jsonBody: (0, protobuf_msg_1.valOfOptJson)(ipcMsg.jsonBody),
200
202
  carbonCopy: ipcMsg.carbonCopy,
201
203
  recipients: ipcMsg.recipients,
202
204
  attachments: (ipcMsg.attachments ?
203
- fs_1.makeFSCaller(caller, ipcMsg.attachments) : undefined)
205
+ (0, fs_1.makeFSCaller)(caller, ipcMsg.attachments) : undefined)
204
206
  };
205
207
  return msg;
206
208
  }
@@ -211,7 +213,7 @@ var inboxSubscribe;
211
213
  return buf => {
212
214
  const { event } = requestType.unpack(buf);
213
215
  const s = new rxjs_1.Subject();
214
- const obs = s.asObservable().pipe(operators_1.map(msg => packIncomingMessage(msg, expServices)));
216
+ const obs = s.asObservable().pipe((0, operators_1.map)(msg => packIncomingMessage(msg, expServices)));
215
217
  const onCancel = fn(event, s);
216
218
  return { obs, onCancel };
217
219
  };
@@ -222,15 +224,9 @@ var inboxSubscribe;
222
224
  return (event, obs) => {
223
225
  const s = new rxjs_1.Subject();
224
226
  const unsub = caller.startObservableCall(path, requestType.pack({ event }), s);
225
- s.subscribe({
226
- next: buf => {
227
- if (obs.next) {
228
- obs.next(unpackIncomingMessage(buf, caller));
229
- }
230
- },
231
- complete: obs.complete,
232
- error: obs.error
233
- });
227
+ s.asObservable()
228
+ .pipe((0, operators_1.map)(buf => unpackIncomingMessage(buf, caller)))
229
+ .subscribe((0, utils_for_observables_1.toRxObserver)(obs));
234
230
  return unsub;
235
231
  };
236
232
  }
@@ -264,13 +260,13 @@ var addMsg;
264
260
  function packMsg(m, caller) {
265
261
  const ipcMsg = {
266
262
  msgType: m.msgType,
267
- htmlTxtBody: protobuf_msg_1.toOptVal(m.htmlTxtBody),
268
- jsonBody: protobuf_msg_1.toOptJson(m.jsonBody),
269
- msgId: protobuf_msg_1.toOptVal(m.msgType),
270
- plainTxtBody: protobuf_msg_1.toOptVal(m.plainTxtBody),
263
+ htmlTxtBody: (0, protobuf_msg_1.toOptVal)(m.htmlTxtBody),
264
+ jsonBody: (0, protobuf_msg_1.toOptJson)(m.jsonBody),
265
+ msgId: (0, protobuf_msg_1.toOptVal)(m.msgType),
266
+ plainTxtBody: (0, protobuf_msg_1.toOptVal)(m.plainTxtBody),
271
267
  recipients: m.recipients,
272
268
  carbonCopy: m.carbonCopy,
273
- subject: protobuf_msg_1.toOptVal(m.subject)
269
+ subject: (0, protobuf_msg_1.toOptVal)(m.subject)
274
270
  };
275
271
  if (m.attachments) {
276
272
  const attachments = {};
@@ -303,13 +299,13 @@ var addMsg;
303
299
  function unpackMsg(ipcMsg, expServices) {
304
300
  const msg = {
305
301
  msgType: ipcMsg.msgType,
306
- htmlTxtBody: protobuf_msg_1.valOfOpt(ipcMsg.htmlTxtBody),
307
- jsonBody: protobuf_msg_1.valOfOptJson(ipcMsg.jsonBody),
308
- msgId: protobuf_msg_1.valOfOpt(ipcMsg.msgId),
309
- plainTxtBody: protobuf_msg_1.valOfOpt(ipcMsg.plainTxtBody),
302
+ htmlTxtBody: (0, protobuf_msg_1.valOfOpt)(ipcMsg.htmlTxtBody),
303
+ jsonBody: (0, protobuf_msg_1.valOfOptJson)(ipcMsg.jsonBody),
304
+ msgId: (0, protobuf_msg_1.valOfOpt)(ipcMsg.msgId),
305
+ plainTxtBody: (0, protobuf_msg_1.valOfOpt)(ipcMsg.plainTxtBody),
310
306
  recipients: ipcMsg.recipients,
311
307
  carbonCopy: ipcMsg.carbonCopy,
312
- subject: protobuf_msg_1.valOfOpt(ipcMsg.subject)
308
+ subject: (0, protobuf_msg_1.valOfOpt)(ipcMsg.subject)
313
309
  };
314
310
  if (ipcMsg.attachments) {
315
311
  const attachments = {};
@@ -336,9 +332,9 @@ var addMsg;
336
332
  function wrapService(fn, expServices) {
337
333
  return (reqBody) => {
338
334
  const { id, recipients, msg, localMeta, sendImmediately } = requestType.unpack(reqBody);
339
- const promise = fn(protobuf_msg_1.fixArray(recipients), unpackMsg(msg, expServices), id, {
340
- localMeta: protobuf_msg_1.valOfOptAny(localMeta),
341
- sendImmediately: protobuf_msg_1.valOfOpt(sendImmediately)
335
+ const promise = fn((0, protobuf_msg_1.fixArray)(recipients), unpackMsg(msg, expServices), id, {
336
+ localMeta: (0, protobuf_msg_1.valOfOptAny)(localMeta),
337
+ sendImmediately: (0, protobuf_msg_1.valOfOpt)(sendImmediately)
342
338
  });
343
339
  return { promise };
344
340
  };
@@ -349,8 +345,8 @@ var addMsg;
349
345
  return async (recipients, msg, id, opts) => {
350
346
  const req = { id, msg: packMsg(msg, caller), recipients };
351
347
  if (opts) {
352
- req.sendImmediately = protobuf_msg_1.toOptVal(opts.sendImmediately);
353
- req.localMeta = protobuf_msg_1.toOptAny(opts.localMeta);
348
+ req.sendImmediately = (0, protobuf_msg_1.toOptVal)(opts.sendImmediately);
349
+ req.localMeta = (0, protobuf_msg_1.toOptAny)(opts.localMeta);
354
350
  }
355
351
  await caller.startPromiseCall(path, requestType.pack(req));
356
352
  };
@@ -377,7 +373,7 @@ var delivListMsgs;
377
373
  return () => caller
378
374
  .startPromiseCall(path, undefined)
379
375
  .then(buf => {
380
- const msgs = protobuf_msg_1.fixArray(replyType.unpack(buf).msgs);
376
+ const msgs = (0, protobuf_msg_1.fixArray)(replyType.unpack(buf).msgs);
381
377
  return msgs.map(({ id, info }) => ({ id, info: unpackDeliveryProgress(info) }));
382
378
  });
383
379
  }
@@ -387,10 +383,10 @@ Object.freeze(delivListMsgs);
387
383
  const deliveryProgressMsgType = protobuf_type_1.ProtoType.for(asmail_proto_1.asmail.DeliveryProgressMsg);
388
384
  function packDeliveryProgress(p) {
389
385
  const m = {
390
- notConnected: protobuf_msg_1.toOptVal(p.notConnected),
386
+ notConnected: (0, protobuf_msg_1.toOptVal)(p.notConnected),
391
387
  allDone: p.allDone,
392
388
  msgSize: p.msgSize,
393
- localMeta: protobuf_msg_1.toOptAny(p.localMeta),
389
+ localMeta: (0, protobuf_msg_1.toOptAny)(p.localMeta),
394
390
  recipients: []
395
391
  };
396
392
  for (const [address, info] of Object.entries(p.recipients)) {
@@ -398,9 +394,9 @@ function packDeliveryProgress(p) {
398
394
  address,
399
395
  info: {
400
396
  done: info.done,
401
- idOnDelivery: protobuf_msg_1.toOptVal(info.idOnDelivery),
397
+ idOnDelivery: (0, protobuf_msg_1.toOptVal)(info.idOnDelivery),
402
398
  bytesSent: info.bytesSent,
403
- err: (info.err ? protobuf_msg_1.errToMsg(info.err) : undefined)
399
+ err: (info.err ? (0, protobuf_msg_1.errToMsg)(info.err) : undefined)
404
400
  }
405
401
  });
406
402
  }
@@ -409,17 +405,17 @@ function packDeliveryProgress(p) {
409
405
  function unpackDeliveryProgress(m) {
410
406
  const p = {
411
407
  allDone: m.allDone,
412
- msgSize: protobuf_msg_1.fixInt(m.msgSize),
413
- notConnected: protobuf_msg_1.valOfOpt(m.notConnected),
414
- localMeta: protobuf_msg_1.valOfOptAny(m.localMeta),
408
+ msgSize: (0, protobuf_msg_1.fixInt)(m.msgSize),
409
+ notConnected: (0, protobuf_msg_1.valOfOpt)(m.notConnected),
410
+ localMeta: (0, protobuf_msg_1.valOfOptAny)(m.localMeta),
415
411
  recipients: {}
416
412
  };
417
- for (const { address, info } of protobuf_msg_1.fixArray(m.recipients)) {
413
+ for (const { address, info } of (0, protobuf_msg_1.fixArray)(m.recipients)) {
418
414
  p.recipients[address] = {
419
415
  done: info.done,
420
- idOnDelivery: protobuf_msg_1.valOfOpt(info.idOnDelivery),
421
- bytesSent: protobuf_msg_1.fixInt(info.bytesSent),
422
- err: (info.err ? protobuf_msg_1.errFromMsg(info.err) : undefined)
416
+ idOnDelivery: (0, protobuf_msg_1.valOfOpt)(info.idOnDelivery),
417
+ bytesSent: (0, protobuf_msg_1.fixInt)(info.bytesSent),
418
+ err: (info.err ? (0, protobuf_msg_1.errFromMsg)(info.err) : undefined)
423
419
  };
424
420
  }
425
421
  return p;
@@ -461,7 +457,7 @@ var rmMsg;
461
457
  function wrapService(fn) {
462
458
  return (reqBody) => {
463
459
  const { id, cancelSending } = requestType.unpack(reqBody);
464
- const promise = fn(id, protobuf_msg_1.valOfOpt(cancelSending));
460
+ const promise = fn(id, (0, protobuf_msg_1.valOfOpt)(cancelSending));
465
461
  return { promise };
466
462
  };
467
463
  }
@@ -470,7 +466,7 @@ var rmMsg;
470
466
  const path = objPath.concat('rmMsg');
471
467
  return (id, cancelSending) => caller
472
468
  .startPromiseCall(path, requestType.pack({
473
- id, cancelSending: protobuf_msg_1.toOptVal(cancelSending)
469
+ id, cancelSending: (0, protobuf_msg_1.toOptVal)(cancelSending)
474
470
  }));
475
471
  }
476
472
  rmMsg.makeCaller = makeCaller;
@@ -482,7 +478,7 @@ var observeAllDeliveries;
482
478
  function wrapService(fn) {
483
479
  return () => {
484
480
  const s = new rxjs_1.Subject();
485
- const obs = s.asObservable().pipe(operators_1.map(({ id, progress }) => notifType.pack({
481
+ const obs = s.asObservable().pipe((0, operators_1.map)(({ id, progress }) => notifType.pack({
486
482
  id,
487
483
  progress: packDeliveryProgress(progress)
488
484
  })));
@@ -496,19 +492,14 @@ var observeAllDeliveries;
496
492
  return obs => {
497
493
  const s = new rxjs_1.Subject();
498
494
  const unsub = caller.startObservableCall(path, undefined, s);
499
- s.subscribe({
500
- next: buf => {
501
- if (obs.next) {
502
- const { id, progress } = notifType.unpack(buf);
503
- obs.next({
504
- id,
505
- progress: unpackDeliveryProgress(progress)
506
- });
507
- }
508
- },
509
- complete: obs.complete,
510
- error: obs.error
511
- });
495
+ s.asObservable()
496
+ .pipe((0, operators_1.map)(buf => {
497
+ const { id, progress } = notifType.unpack(buf);
498
+ return {
499
+ id, progress: unpackDeliveryProgress(progress)
500
+ };
501
+ }))
502
+ .subscribe((0, utils_for_observables_1.toRxObserver)(obs));
512
503
  return unsub;
513
504
  };
514
505
  }
@@ -522,7 +513,7 @@ var observeDelivery;
522
513
  return buf => {
523
514
  const { id } = requestType.unpack(buf);
524
515
  const s = new rxjs_1.Subject();
525
- const obs = s.asObservable().pipe(operators_1.map(p => deliveryProgressMsgType.pack(packDeliveryProgress(p))));
516
+ const obs = s.asObservable().pipe((0, operators_1.map)(p => deliveryProgressMsgType.pack(packDeliveryProgress(p))));
526
517
  const onCancel = fn(id, s);
527
518
  return { obs, onCancel };
528
519
  };
@@ -533,16 +524,9 @@ var observeDelivery;
533
524
  return (id, obs) => {
534
525
  const s = new rxjs_1.Subject();
535
526
  const unsub = caller.startObservableCall(path, requestType.pack({ id }), s);
536
- s.subscribe({
537
- next: buf => {
538
- if (obs.next) {
539
- const msg = deliveryProgressMsgType.unpack(buf);
540
- obs.next(unpackDeliveryProgress(msg));
541
- }
542
- },
543
- complete: obs.complete,
544
- error: obs.error
545
- });
527
+ s.asObservable()
528
+ .pipe((0, operators_1.map)(buf => unpackDeliveryProgress(deliveryProgressMsgType.unpack(buf))))
529
+ .subscribe((0, utils_for_observables_1.toRxObserver)(obs));
546
530
  return unsub;
547
531
  };
548
532
  }