core-3nweb-client-lib 0.30.2 → 0.30.4

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 (222) hide show
  1. package/build/api-defs/asmail.d.ts +9 -6
  2. package/build/core/app-files.d.ts +4 -4
  3. package/build/core/app-files.js +2 -2
  4. package/build/core/asmail/asmail-cap-ipc.d.ts +1 -1
  5. package/build/core/asmail/asmail-cap-ipc.js +2 -3
  6. package/build/core/asmail/config/common.d.ts +2 -2
  7. package/build/core/asmail/config/index.d.ts +1 -1
  8. package/build/core/asmail/config/invitations-anon.d.ts +1 -1
  9. package/build/core/asmail/config/invitations-anon.js +1 -2
  10. package/build/core/asmail/config/published-intro-key.d.ts +2 -2
  11. package/build/core/asmail/config/published-intro-key.js +1 -2
  12. package/build/core/asmail/delivery/common.d.ts +6 -6
  13. package/build/core/asmail/delivery/common.js +3 -3
  14. package/build/core/asmail/delivery/index.d.ts +4 -4
  15. package/build/core/asmail/delivery/msg.d.ts +4 -4
  16. package/build/core/asmail/delivery/msg.js +3 -3
  17. package/build/core/asmail/inbox/attachments/fs.d.ts +1 -1
  18. package/build/core/asmail/inbox/attachments/fs.js +1 -2
  19. package/build/core/asmail/inbox/inbox-events.d.ts +4 -3
  20. package/build/core/asmail/inbox/inbox-events.js +1 -1
  21. package/build/core/asmail/inbox/index.d.ts +2 -2
  22. package/build/core/asmail/inbox/index.js +7 -4
  23. package/build/core/asmail/inbox/msg-indexing/index.d.ts +2 -2
  24. package/build/core/asmail/inbox/msg-indexing/logs-n-entries.d.ts +3 -3
  25. package/build/core/asmail/inbox/msg-indexing/logs-n-entries.js +2 -2
  26. package/build/core/asmail/inbox/msg-indexing/sql-indexing.d.ts +1 -1
  27. package/build/core/asmail/inbox/msg-indexing/sql-indexing.js +1 -2
  28. package/build/core/asmail/inbox/msg-on-disk.d.ts +2 -2
  29. package/build/core/asmail/inbox/msg-on-disk.js +3 -3
  30. package/build/core/asmail/index.d.ts +3 -3
  31. package/build/core/asmail/key-verification.js +2 -3
  32. package/build/core/asmail/keyring/common.d.ts +1 -1
  33. package/build/core/asmail/keyring/common.js +7 -7
  34. package/build/core/asmail/keyring/correspondent-keys.d.ts +1 -1
  35. package/build/core/asmail/keyring/correspondent-keys.js +5 -5
  36. package/build/core/asmail/keyring/index.d.ts +3 -3
  37. package/build/core/asmail/keyring/index.js +2 -2
  38. package/build/core/asmail/keyring/keyring-storage.d.ts +1 -1
  39. package/build/core/asmail/keyring/keyring-storage.js +1 -2
  40. package/build/core/asmail/msg/attachments-container.d.ts +3 -3
  41. package/build/core/asmail/msg/attachments-container.js +7 -8
  42. package/build/core/asmail/msg/opener.js +2 -2
  43. package/build/core/asmail/msg/packer.d.ts +2 -2
  44. package/build/core/asmail/sending-params/index.d.ts +3 -3
  45. package/build/core/asmail/sending-params/own-params.d.ts +3 -3
  46. package/build/core/asmail/sending-params/params-from-others.d.ts +3 -3
  47. package/build/core/id-manager/index.d.ts +4 -4
  48. package/build/core/id-manager/key-storage.d.ts +1 -1
  49. package/build/core/id-manager/mailerid-cap-ipc.d.ts +1 -1
  50. package/build/core/id-manager/mailerid-cap-ipc.js +2 -3
  51. package/build/core/index.d.ts +3 -3
  52. package/build/core/startup/sign-in.d.ts +6 -6
  53. package/build/core/startup/sign-in.js +2 -2
  54. package/build/core/startup/sign-up.d.ts +1 -1
  55. package/build/core/startup/sign-up.js +6 -6
  56. package/build/core/startup/startup-cap.d.ts +2 -2
  57. package/build/core/startup/startup-cap.js +4 -5
  58. package/build/core/storage/common/obj-info-file.js +12 -13
  59. package/build/core/storage/common/utils.js +2 -3
  60. package/build/core/storage/index.d.ts +5 -5
  61. package/build/core/storage/index.js +2 -2
  62. package/build/core/storage/local/storage.d.ts +3 -3
  63. package/build/core/storage/storage-cap-ipc.d.ts +1 -1
  64. package/build/core/storage/storage-cap-ipc.js +3 -4
  65. package/build/core/storage/synced/obj-files.d.ts +1 -1
  66. package/build/core/storage/synced/obj-status.d.ts +2 -2
  67. package/build/core/storage/synced/obj-status.js +2 -2
  68. package/build/core/storage/synced/storage.d.ts +4 -4
  69. package/build/core/storage/synced/upload-header-file.js +3 -3
  70. package/build/core/storage/synced/upsyncer.d.ts +1 -1
  71. package/build/core/storage/system-folders/apps-data.d.ts +1 -1
  72. package/build/core/storage/system-folders/index.d.ts +2 -2
  73. package/build/core/storage/system-folders/index.js +4 -4
  74. package/build/core-ipc/bytes.d.ts +2 -2
  75. package/build/core-ipc/bytes.js +4 -5
  76. package/build/core-ipc/common-caps.d.ts +1 -1
  77. package/build/core-ipc/common-caps.js +3 -4
  78. package/build/core-ipc/file.d.ts +13 -14
  79. package/build/core-ipc/file.js +31 -31
  80. package/build/core-ipc/fs.d.ts +3 -3
  81. package/build/core-ipc/fs.js +6 -6
  82. package/build/core-ipc/generic.d.ts +4 -4
  83. package/build/core-ipc/generic.js +3 -4
  84. package/build/core-ipc/log-cap.d.ts +1 -1
  85. package/build/core-ipc/log-cap.js +2 -3
  86. package/build/core-ipc/startup-caps.d.ts +1 -1
  87. package/build/core-ipc/startup-caps.js +2 -3
  88. package/build/ipc-via-protobuf/connector.d.ts +6 -7
  89. package/build/ipc-via-protobuf/connector.js +3 -3
  90. package/build/ipc-via-protobuf/protobuf-msg.d.ts +1 -2
  91. package/build/ipc-via-protobuf/protobuf-msg.js +20 -20
  92. package/build/lib-client/3nstorage/exceptions.d.ts +1 -1
  93. package/build/lib-client/3nstorage/exceptions.js +9 -10
  94. package/build/lib-client/3nstorage/service.d.ts +2 -2
  95. package/build/lib-client/3nstorage/util/file-based-json.d.ts +3 -3
  96. package/build/lib-client/3nstorage/util/for-arrays.js +1 -2
  97. package/build/lib-client/3nstorage/xsp-fs/attrs.d.ts +1 -2
  98. package/build/lib-client/3nstorage/xsp-fs/common.d.ts +12 -12
  99. package/build/lib-client/3nstorage/xsp-fs/common.js +5 -5
  100. package/build/lib-client/3nstorage/xsp-fs/file-node.d.ts +4 -4
  101. package/build/lib-client/3nstorage/xsp-fs/file.d.ts +15 -15
  102. package/build/lib-client/3nstorage/xsp-fs/folder-node-serialization.js +2 -3
  103. package/build/lib-client/3nstorage/xsp-fs/folder-node.d.ts +7 -7
  104. package/build/lib-client/3nstorage/xsp-fs/fs.d.ts +27 -27
  105. package/build/lib-client/3nstorage/xsp-fs/link-node.d.ts +2 -2
  106. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.d.ts +7 -7
  107. package/build/lib-client/3nstorage/xsp-fs/node-in-fs.js +11 -11
  108. package/build/lib-client/3nstorage/xsp-fs/node-persistence.d.ts +2 -2
  109. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v1.js +1 -2
  110. package/build/lib-client/3nstorage/xsp-fs/xsp-payload-v2.js +3 -4
  111. package/build/lib-client/3nweb-signup.js +4 -5
  112. package/build/lib-client/asmail/recipient.d.ts +1 -1
  113. package/build/lib-client/asmail/recipient.js +4 -4
  114. package/build/lib-client/asmail/sender.d.ts +3 -3
  115. package/build/lib-client/asmail/sender.js +9 -9
  116. package/build/lib-client/cryptor/cryptor-in-worker.d.ts +2 -2
  117. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  118. package/build/lib-client/cryptor/cryptor.d.ts +2 -2
  119. package/build/lib-client/cryptor/cryptor.js +3 -3
  120. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  121. package/build/lib-client/cryptor/in-proc-js.js +1 -2
  122. package/build/lib-client/cryptor/in-proc-wasm.js +1 -2
  123. package/build/lib-client/cryptor/serialization-for-wasm.d.ts +1 -2
  124. package/build/lib-client/cryptor/serialization-for-wasm.js +6 -7
  125. package/build/lib-client/cryptor/wasm-mp1-modules.js +1 -2
  126. package/build/lib-client/cryptor-work-labels.js +1 -1
  127. package/build/lib-client/fs-utils/files-select.d.ts +3 -3
  128. package/build/lib-client/fs-utils/files-select.js +1 -2
  129. package/build/lib-client/fs-utils/files.d.ts +7 -7
  130. package/build/lib-client/fs-utils/files.js +7 -8
  131. package/build/lib-client/fs-utils/fs-collection.d.ts +1 -1
  132. package/build/lib-client/fs-utils/fs-collection.js +2 -3
  133. package/build/lib-client/fs-utils/fs-sync-utils.d.ts +5 -5
  134. package/build/lib-client/fs-utils/fs-sync-utils.js +4 -5
  135. package/build/lib-client/fs-utils/fs-view.d.ts +4 -4
  136. package/build/lib-client/fs-utils/fs-view.js +1 -2
  137. package/build/lib-client/key-derivation.js +3 -4
  138. package/build/lib-client/local-files/dev-file-sink.d.ts +2 -3
  139. package/build/lib-client/local-files/dev-file-src.d.ts +0 -1
  140. package/build/lib-client/local-files/device-fs.d.ts +18 -18
  141. package/build/lib-client/logging/log-to-file.d.ts +5 -5
  142. package/build/lib-client/logging/log-to-file.js +2 -2
  143. package/build/lib-client/mailer-id/login.js +2 -3
  144. package/build/lib-client/objs-on-disk/file-writing-proc.d.ts +1 -1
  145. package/build/lib-client/objs-on-disk/obj-folders.d.ts +1 -1
  146. package/build/lib-client/objs-on-disk/obj-folders.js +9 -5
  147. package/build/lib-client/objs-on-disk/obj-on-disk.d.ts +1 -1
  148. package/build/lib-client/protobuf-type.d.ts +0 -1
  149. package/build/lib-client/request-utils.d.ts +2 -4
  150. package/build/lib-client/request-utils.js +6 -6
  151. package/build/lib-client/service-locator.d.ts +3 -4
  152. package/build/lib-client/service-locator.js +5 -6
  153. package/build/lib-client/user-with-mid-session.d.ts +1 -1
  154. package/build/lib-client/user-with-mid-session.js +17 -17
  155. package/build/lib-client/user-with-pkl-session.js +16 -16
  156. package/build/lib-client/ws-utils.js +1 -2
  157. package/build/lib-common/assert.js +1 -2
  158. package/build/lib-common/async-cryptor-wrap.js +4 -5
  159. package/build/lib-common/async-fs-node.d.ts +0 -3
  160. package/build/lib-common/async-fs-node.js +35 -35
  161. package/build/lib-common/async-iter.js +2 -3
  162. package/build/lib-common/big-endian.d.ts +0 -1
  163. package/build/lib-common/big-endian.js +10 -11
  164. package/build/lib-common/binding.js +1 -2
  165. package/build/lib-common/buffer-utils.d.ts +0 -1
  166. package/build/lib-common/buffer-utils.js +9 -9
  167. package/build/lib-common/byte-streaming/bytes-fifo-buffer.js +5 -5
  168. package/build/lib-common/byte-streaming/pipe.d.ts +2 -2
  169. package/build/lib-common/byte-streaming/pipe.js +1 -2
  170. package/build/lib-common/byte-streaming/wrapping.d.ts +2 -2
  171. package/build/lib-common/byte-streaming/wrapping.js +3 -4
  172. package/build/lib-common/bytes-equal.js +1 -2
  173. package/build/lib-common/canonical-address.js +3 -4
  174. package/build/lib-common/exceptions/error.js +3 -4
  175. package/build/lib-common/exceptions/file.d.ts +2 -2
  176. package/build/lib-common/exceptions/file.js +7 -7
  177. package/build/lib-common/exceptions/http.js +2 -3
  178. package/build/lib-common/exceptions/runtime.js +1 -2
  179. package/build/lib-common/ipc/generic-ipc.d.ts +3 -3
  180. package/build/lib-common/ipc/generic-ipc.js +11 -11
  181. package/build/lib-common/ipc/ws-ipc.js +2 -2
  182. package/build/lib-common/json-utils.js +4 -5
  183. package/build/lib-common/jwkeys.d.ts +1 -1
  184. package/build/lib-common/jwkeys.js +13 -13
  185. package/build/lib-common/mid-sigs-NaCl-Ed.d.ts +3 -3
  186. package/build/lib-common/mid-sigs-NaCl-Ed.js +5 -5
  187. package/build/lib-common/obj-streaming/sink-utils.d.ts +2 -2
  188. package/build/lib-common/obj-streaming/sink-utils.js +2 -3
  189. package/build/lib-common/obj-streaming/wrapping.js +1 -2
  190. package/build/lib-common/objs-on-disk/file-layout.d.ts +4 -5
  191. package/build/lib-common/objs-on-disk/obj-file.d.ts +0 -1
  192. package/build/lib-common/objs-on-disk/utils.d.ts +3 -5
  193. package/build/lib-common/objs-on-disk/utils.js +5 -6
  194. package/build/lib-common/objs-on-disk/v1-obj-file-format.d.ts +0 -1
  195. package/build/lib-common/objs-on-disk/v1-obj-file-format.js +1 -1
  196. package/build/lib-common/processes/deferred.js +1 -2
  197. package/build/lib-common/processes/sleep.js +1 -2
  198. package/build/lib-common/processes/synced.d.ts +1 -1
  199. package/build/lib-common/processes/synced.js +2 -2
  200. package/build/lib-common/processes/timeout.js +1 -2
  201. package/build/lib-common/random-node.js +10 -11
  202. package/build/lib-common/service-api/3nstorage/owner.js +19 -19
  203. package/build/lib-common/service-api/asmail/config.js +3 -3
  204. package/build/lib-common/service-api/asmail/delivery.js +8 -8
  205. package/build/lib-common/service-api/asmail/retrieval.js +11 -11
  206. package/build/lib-common/service-api/mailer-id/login.js +2 -2
  207. package/build/lib-common/service-api/mailer-id/provisioning.js +2 -2
  208. package/build/lib-common/service-api/pub-key-login.js +2 -2
  209. package/build/lib-common/service-api/web-socket-base.d.ts +1 -1
  210. package/build/lib-common/service-api/web-socket-base.js +3 -3
  211. package/build/lib-common/session-encryptor.js +1 -2
  212. package/build/lib-common/timed-cache.js +1 -2
  213. package/build/lib-common/user-admin-api/signup.js +4 -4
  214. package/build/lib-common/utils-for-observables.js +5 -5
  215. package/build/lib-sqlite-on-3nstorage/deferred.js +1 -2
  216. package/build/lib-sqlite-on-3nstorage/index.d.ts +5 -5
  217. package/build/lib-sqlite-on-3nstorage/index.js +2 -2
  218. package/build/lib-sqlite-on-3nstorage/synced.d.ts +1 -1
  219. package/build/lib-sqlite-on-3nstorage/synced.js +2 -2
  220. package/build/raw-3nweb-clients.d.ts +7 -7
  221. package/build/raw-3nweb-clients.js +2 -2
  222. package/package.json +2 -2
@@ -15,7 +15,12 @@
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.makeNetClient = exports.extractIntHeader = exports.makeException = exports.formHttpsReqOpts = exports.processRequest = exports.CONTENT_TYPE_HEADER = exports.SESSION_ID_HEADER = void 0;
18
+ exports.CONTENT_TYPE_HEADER = exports.SESSION_ID_HEADER = void 0;
19
+ exports.processRequest = processRequest;
20
+ exports.formHttpsReqOpts = formHttpsReqOpts;
21
+ exports.makeException = makeException;
22
+ exports.extractIntHeader = extractIntHeader;
23
+ exports.makeNetClient = makeNetClient;
19
24
  const http_1 = require("../lib-common/exceptions/http");
20
25
  const bytes_fifo_buffer_1 = require("../lib-common/byte-streaming/bytes-fifo-buffer");
21
26
  const https = require("https");
@@ -43,7 +48,6 @@ async function processRequest(requester, httpsOpts, opts, reqBody, attempt = 0)
43
48
  throw err;
44
49
  }
45
50
  }
46
- exports.processRequest = processRequest;
47
51
  function formHttpsReqOpts(opts, contentType, reqBody) {
48
52
  if (!opts.url) {
49
53
  throw new Error(`Cannot send net request, cause url is not set in given options.`);
@@ -71,7 +75,6 @@ function formHttpsReqOpts(opts, contentType, reqBody) {
71
75
  }
72
76
  return netReqOpts;
73
77
  }
74
- exports.formHttpsReqOpts = formHttpsReqOpts;
75
78
  async function attachRequestReaders(clReq, opts) {
76
79
  // XXX do something for timeouts, that doesn't break good long connections
77
80
  // const timeout = (opts.timeout ? opts.timeout : DEFAULT_TIMEOUT);
@@ -173,7 +176,6 @@ function makeHeaders(headers) {
173
176
  function makeException(rep, errMsg) {
174
177
  return (0, http_1.makeHTTPException)(rep.url, rep.method, rep.status, errMsg);
175
178
  }
176
- exports.makeException = makeException;
177
179
  function extractIntHeader(rep, headerName) {
178
180
  const intHeader = parseInt(rep.headers.get(headerName));
179
181
  if (isNaN(intHeader)) {
@@ -181,7 +183,6 @@ function extractIntHeader(rep, headerName) {
181
183
  }
182
184
  return intHeader;
183
185
  }
184
- exports.extractIntHeader = extractIntHeader;
185
186
  function makeNodeRequest() {
186
187
  const nodeRequest = (opts) => https.request(opts);
187
188
  return (opts, contentType, reqBody) => {
@@ -215,5 +216,4 @@ function makeNetClient(request = makeNodeRequest()) {
215
216
  };
216
217
  return Object.freeze(client);
217
218
  }
218
- exports.makeNetClient = makeNetClient;
219
219
  Object.freeze(exports);
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  import { SignedLoad } from '../lib-common/jwkeys';
3
2
  import { NetClient } from './request-utils';
4
3
  import { promises as dnsPromises } from 'dns';
@@ -35,9 +34,9 @@ export interface StorageRoutes {
35
34
  * @param url
36
35
  */
37
36
  export declare function storageInfoAt(client: NetClient, url: string): Promise<StorageRoutes>;
38
- export declare type ServiceTypeDNSLabel = 'mailerid' | 'asmail' | '3nstorage';
39
- export declare type ServiceLocatorMaker = (serviceLabel: ServiceTypeDNSLabel) => ServiceLocator;
40
- export declare type ServiceLocator = (address: string) => Promise<string>;
37
+ export type ServiceTypeDNSLabel = 'mailerid' | 'asmail' | '3nstorage';
38
+ export type ServiceLocatorMaker = (serviceLabel: ServiceTypeDNSLabel) => ServiceLocator;
39
+ export type ServiceLocator = (address: string) => Promise<string>;
41
40
  export declare function makeServiceLocator(resolver: {
42
41
  resolveTxt: (typeof dnsPromises)['resolveTxt'];
43
42
  }): ServiceLocatorMaker;
@@ -16,7 +16,11 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
- exports.getMailerIdInfoFor = exports.makeServiceLocator = exports.storageInfoAt = exports.mailerIdInfoAt = exports.asmailInfoAt = void 0;
19
+ exports.asmailInfoAt = asmailInfoAt;
20
+ exports.mailerIdInfoAt = mailerIdInfoAt;
21
+ exports.storageInfoAt = storageInfoAt;
22
+ exports.makeServiceLocator = makeServiceLocator;
23
+ exports.getMailerIdInfoFor = getMailerIdInfoFor;
20
24
  const jwkeys_1 = require("../lib-common/jwkeys");
21
25
  const url_1 = require("url");
22
26
  const request_utils_1 = require("./request-utils");
@@ -74,7 +78,6 @@ async function asmailInfoAt(client, url) {
74
78
  Object.freeze(transform);
75
79
  return transform;
76
80
  }
77
- exports.asmailInfoAt = asmailInfoAt;
78
81
  /**
79
82
  * This returns a promise, resolvable to MailerIdRoutes object.
80
83
  * @param client
@@ -101,7 +104,6 @@ async function mailerIdInfoAt(client, url) {
101
104
  Object.freeze(transform);
102
105
  return transform;
103
106
  }
104
- exports.mailerIdInfoAt = mailerIdInfoAt;
105
107
  /**
106
108
  * This returns a promise, resolvable to StorageRoutes object.
107
109
  * @param client
@@ -122,7 +124,6 @@ async function storageInfoAt(client, url) {
122
124
  }
123
125
  return transform;
124
126
  }
125
- exports.storageInfoAt = storageInfoAt;
126
127
  /**
127
128
  * @param address
128
129
  * @return domain string, extracted from a given address
@@ -253,7 +254,6 @@ function makeServiceLocator(resolver) {
253
254
  }
254
255
  };
255
256
  }
256
- exports.makeServiceLocator = makeServiceLocator;
257
257
  /**
258
258
  * @param resolver
259
259
  * @param address
@@ -268,5 +268,4 @@ async function getMailerIdInfoFor(resolver, client, address) {
268
268
  domain: rootAddr
269
269
  };
270
270
  }
271
- exports.getMailerIdInfoFor = getMailerIdInfoFor;
272
271
  Object.freeze(exports);
@@ -5,7 +5,7 @@
5
5
  import { Reply, RequestOpts, NetClient } from '../lib-client/request-utils';
6
6
  import { user as mid } from '../lib-common/mid-sigs-NaCl-Ed';
7
7
  import * as WebSocket from 'ws';
8
- export declare type IGetMailerIdSigner = () => Promise<mid.MailerIdSigner>;
8
+ export type IGetMailerIdSigner = () => Promise<mid.MailerIdSigner>;
9
9
  export declare abstract class ServiceUser {
10
10
  readonly userId: string;
11
11
  private getSigner;
@@ -28,23 +28,6 @@ const url_1 = require("url");
28
28
  const login_1 = require("./mailer-id/login");
29
29
  const assert_1 = require("../lib-common/assert");
30
30
  class ServiceUser {
31
- constructor(userId, opts, getSigner, getInitServiceURI, net) {
32
- this.userId = userId;
33
- this.getSigner = getSigner;
34
- this.getInitServiceURI = getInitServiceURI;
35
- this.net = net;
36
- this.uri = undefined;
37
- this.redirectedFrom = undefined;
38
- this.sessionId = undefined;
39
- this.loginProc = undefined;
40
- this.loginUrlPart = opts.login;
41
- if ((this.loginUrlPart.length > 0)
42
- && (this.loginUrlPart[this.loginUrlPart.length - 1] !== '/')) {
43
- this.loginUrlPart += '/';
44
- }
45
- this.logoutUrlEnd = opts.logout;
46
- this.canBeRedirected = !!opts.canBeRedirected;
47
- }
48
31
  get serviceURI() {
49
32
  return this.uri;
50
33
  }
@@ -64,6 +47,23 @@ class ServiceUser {
64
47
  get loginUrl() {
65
48
  return `${this.serviceURI}${this.loginUrlPart}`;
66
49
  }
50
+ constructor(userId, opts, getSigner, getInitServiceURI, net) {
51
+ this.userId = userId;
52
+ this.getSigner = getSigner;
53
+ this.getInitServiceURI = getInitServiceURI;
54
+ this.net = net;
55
+ this.uri = undefined;
56
+ this.redirectedFrom = undefined;
57
+ this.sessionId = undefined;
58
+ this.loginProc = undefined;
59
+ this.loginUrlPart = opts.login;
60
+ if ((this.loginUrlPart.length > 0)
61
+ && (this.loginUrlPart[this.loginUrlPart.length - 1] !== '/')) {
62
+ this.loginUrlPart += '/';
63
+ }
64
+ this.logoutUrlEnd = opts.logout;
65
+ this.canBeRedirected = !!opts.canBeRedirected;
66
+ }
67
67
  get isUriSet() {
68
68
  return (typeof this.serviceURI === 'string');
69
69
  }
@@ -29,6 +29,22 @@ const loginApi = require("../lib-common/service-api/pub-key-login");
29
29
  const url_1 = require("url");
30
30
  const assert_1 = require("../lib-common/assert");
31
31
  class ServiceUser {
32
+ get serviceURI() {
33
+ return this.uri;
34
+ }
35
+ set serviceURI(uriString) {
36
+ const u = (0, url_1.parse)(uriString);
37
+ if (u.protocol !== 'https:') {
38
+ throw new Error("Url protocol must be https.");
39
+ }
40
+ if (!u.host) {
41
+ throw new Error("Host name is missing.");
42
+ }
43
+ this.uri = `${u.protocol}//${u.host}${u.pathname}`;
44
+ if (!this.uri.endsWith('/')) {
45
+ this.uri += '/';
46
+ }
47
+ }
32
48
  constructor(userId, opts, net) {
33
49
  this.userId = userId;
34
50
  this.net = net;
@@ -51,22 +67,6 @@ class ServiceUser {
51
67
  this.logoutUrlEnd = opts.logout;
52
68
  this.canBeRedirected = !!opts.canBeRedirected;
53
69
  }
54
- get serviceURI() {
55
- return this.uri;
56
- }
57
- set serviceURI(uriString) {
58
- const u = (0, url_1.parse)(uriString);
59
- if (u.protocol !== 'https:') {
60
- throw new Error("Url protocol must be https.");
61
- }
62
- if (!u.host) {
63
- throw new Error("Host name is missing.");
64
- }
65
- this.uri = `${u.protocol}//${u.host}${u.pathname}`;
66
- if (!this.uri.endsWith('/')) {
67
- this.uri += '/';
68
- }
69
- }
70
70
  async startSession(keyId) {
71
71
  const reqData = {
72
72
  userId: this.userId,
@@ -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.openSocket = void 0;
18
+ exports.openSocket = openSocket;
19
19
  const WebSocket = require("ws");
20
20
  const request_utils_1 = require("./request-utils");
21
21
  const deferred_1 = require("../lib-common/processes/deferred");
@@ -54,5 +54,4 @@ function openSocket(url, sessionId) {
54
54
  });
55
55
  return opening.promise;
56
56
  }
57
- exports.openSocket = openSocket;
58
57
  Object.freeze(exports);
@@ -15,11 +15,10 @@
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.assert = void 0;
18
+ exports.assert = assert;
19
19
  function assert(ok, errMsg) {
20
20
  if (!ok) {
21
21
  throw new Error(errMsg);
22
22
  }
23
23
  }
24
- exports.assert = assert;
25
24
  Object.freeze(exports);
@@ -15,7 +15,10 @@
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.makeEncryptorWithKeyPair = exports.makeDecryptorForKeyPair = exports.makeDecryptor = exports.makeEncryptor = void 0;
18
+ exports.makeEncryptor = makeEncryptor;
19
+ exports.makeDecryptor = makeDecryptor;
20
+ exports.makeDecryptorForKeyPair = makeDecryptorForKeyPair;
21
+ exports.makeEncryptorWithKeyPair = makeEncryptorWithKeyPair;
19
22
  const xsp_files_1 = require("xsp-files");
20
23
  const ecma_nacl_1 = require("ecma-nacl");
21
24
  const buffer_utils_1 = require("./buffer-utils");
@@ -85,7 +88,6 @@ function makeEncryptor(cryptor, workLabel, key, nextNonce, delta) {
85
88
  };
86
89
  return Object.freeze(encryptor);
87
90
  }
88
- exports.makeEncryptor = makeEncryptor;
89
91
  /**
90
92
  * @param cryptor
91
93
  * @param workLabel
@@ -119,19 +121,16 @@ function makeDecryptor(cryptor, workLabel, key) {
119
121
  };
120
122
  return Object.freeze(decryptor);
121
123
  }
122
- exports.makeDecryptor = makeDecryptor;
123
124
  function makeDecryptorForKeyPair(cryptor, workLabel, pkey, skey) {
124
125
  const dhSharedKey = ecma_nacl_1.box.calc_dhshared_key(pkey, skey);
125
126
  const decryptor = makeDecryptor(cryptor, workLabel, dhSharedKey);
126
127
  dhSharedKey.fill(0);
127
128
  return decryptor;
128
129
  }
129
- exports.makeDecryptorForKeyPair = makeDecryptorForKeyPair;
130
130
  function makeEncryptorWithKeyPair(cryptor, workLabel, pkey, skey, nextNonce, delta) {
131
131
  const dhSharedKey = ecma_nacl_1.box.calc_dhshared_key(pkey, skey);
132
132
  const decryptor = makeEncryptor(cryptor, workLabel, dhSharedKey, nextNonce, delta);
133
133
  dhSharedKey.fill(0);
134
134
  return decryptor;
135
135
  }
136
- exports.makeEncryptorWithKeyPair = makeEncryptorWithKeyPair;
137
136
  Object.freeze(exports);
@@ -1,6 +1,3 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- /// <reference types="node" />
4
1
  import * as fs from 'fs';
5
2
  import { Readable, Writable } from 'stream';
6
3
  export { Stats } from 'fs';
@@ -16,7 +16,41 @@
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 = exports.Stats = void 0;
19
+ exports.Stats = void 0;
20
+ exports.readFile = readFile;
21
+ exports.writeFile = writeFile;
22
+ exports.appendFile = appendFile;
23
+ exports.mkdir = mkdir;
24
+ exports.open = open;
25
+ exports.close = close;
26
+ exports.symlink = symlink;
27
+ exports.readlink = readlink;
28
+ exports.lstat = lstat;
29
+ exports.stat = stat;
30
+ exports.fstat = fstat;
31
+ exports.readdir = readdir;
32
+ exports.rmdir = rmdir;
33
+ exports.unlink = unlink;
34
+ exports.rename = rename;
35
+ exports.truncate = truncate;
36
+ exports.ftruncate = ftruncate;
37
+ exports.readToBuf = readToBuf;
38
+ exports.writeFromBuf = writeFromBuf;
39
+ exports.createEmptyFile = createEmptyFile;
40
+ exports.existsFolder = existsFolder;
41
+ exports.existsFolderSync = existsFolderSync;
42
+ exports.existsFileSync = existsFileSync;
43
+ exports.getFileSize = getFileSize;
44
+ exports.getFolderContentSize = getFolderContentSize;
45
+ exports.write = write;
46
+ exports.append = append;
47
+ exports.streamToExistingFile = streamToExistingFile;
48
+ exports.read = read;
49
+ exports.rmDirWithContent = rmDirWithContent;
50
+ exports.streamFromFile = streamFromFile;
51
+ exports.copyFile = copyFile;
52
+ exports.copyTree = copyTree;
53
+ exports.ensureFolderExists = ensureFolderExists;
20
54
  const fs = require("fs");
21
55
  const fs_1 = require("fs");
22
56
  const file_1 = require("./exceptions/file");
@@ -48,7 +82,6 @@ function readFile(path, options) {
48
82
  }
49
83
  });
50
84
  }
51
- exports.readFile = readFile;
52
85
  function writeFile(path, data, options = {}) {
53
86
  return new Promise((resolve, reject) => {
54
87
  fs.writeFile(path, data, options, err => {
@@ -61,7 +94,6 @@ function writeFile(path, data, options = {}) {
61
94
  });
62
95
  });
63
96
  }
64
- exports.writeFile = writeFile;
65
97
  function appendFile(path, data, options = {}) {
66
98
  return new Promise((resolve, reject) => {
67
99
  fs.appendFile(path, data, options, err => {
@@ -74,7 +106,6 @@ function appendFile(path, data, options = {}) {
74
106
  });
75
107
  });
76
108
  }
77
- exports.appendFile = appendFile;
78
109
  function mkdir(path, options) {
79
110
  return new Promise((resolve, reject) => {
80
111
  fs.mkdir(path, options, (err) => {
@@ -87,7 +118,6 @@ function mkdir(path, options) {
87
118
  });
88
119
  });
89
120
  }
90
- exports.mkdir = mkdir;
91
121
  function open(path, flags) {
92
122
  return new Promise((resolve, reject) => {
93
123
  fs.open(path, flags, (err, df) => {
@@ -100,7 +130,6 @@ function open(path, flags) {
100
130
  });
101
131
  });
102
132
  }
103
- exports.open = open;
104
133
  function writeOrig(fd, buffer, offset, length, position) {
105
134
  return new Promise((resolve, reject) => {
106
135
  const cb = (err, written) => {
@@ -143,7 +172,6 @@ function close(fd) {
143
172
  });
144
173
  });
145
174
  }
146
- exports.close = close;
147
175
  function symlink(target, path, type) {
148
176
  return new Promise((resolve, reject) => {
149
177
  fs.symlink(target, path, type, (err) => {
@@ -156,7 +184,6 @@ function symlink(target, path, type) {
156
184
  });
157
185
  });
158
186
  }
159
- exports.symlink = symlink;
160
187
  function readlink(path) {
161
188
  return new Promise((resolve, reject) => {
162
189
  fs.readlink(path, (err, targetPath) => {
@@ -169,7 +196,6 @@ function readlink(path) {
169
196
  });
170
197
  });
171
198
  }
172
- exports.readlink = readlink;
173
199
  function lstat(path) {
174
200
  return new Promise((resolve, reject) => {
175
201
  fs.lstat(path, (err, stat) => {
@@ -182,7 +208,6 @@ function lstat(path) {
182
208
  });
183
209
  });
184
210
  }
185
- exports.lstat = lstat;
186
211
  function stat(path) {
187
212
  return new Promise((resolve, reject) => {
188
213
  fs.stat(path, (err, stat) => {
@@ -195,7 +220,6 @@ function stat(path) {
195
220
  });
196
221
  });
197
222
  }
198
- exports.stat = stat;
199
223
  function fstat(fd) {
200
224
  return new Promise((resolve, reject) => {
201
225
  // from some moment, typing of fs.fstat is broken
@@ -209,7 +233,6 @@ function fstat(fd) {
209
233
  });
210
234
  });
211
235
  }
212
- exports.fstat = fstat;
213
236
  function readdir(path) {
214
237
  return new Promise((resolve, reject) => {
215
238
  fs.readdir(path, (err, list) => {
@@ -222,7 +245,6 @@ function readdir(path) {
222
245
  });
223
246
  });
224
247
  }
225
- exports.readdir = readdir;
226
248
  function rmdir(path) {
227
249
  return new Promise((resolve, reject) => {
228
250
  fs.rmdir(path, (err) => {
@@ -235,7 +257,6 @@ function rmdir(path) {
235
257
  });
236
258
  });
237
259
  }
238
- exports.rmdir = rmdir;
239
260
  function unlink(path) {
240
261
  return new Promise((resolve, reject) => {
241
262
  fs.unlink(path, (err) => {
@@ -248,7 +269,6 @@ function unlink(path) {
248
269
  });
249
270
  });
250
271
  }
251
- exports.unlink = unlink;
252
272
  function rename(oldPath, newPath) {
253
273
  return new Promise((resolve, reject) => {
254
274
  fs.rename(oldPath, newPath, (err) => {
@@ -261,7 +281,6 @@ function rename(oldPath, newPath) {
261
281
  });
262
282
  });
263
283
  }
264
- exports.rename = rename;
265
284
  function truncate(path, size) {
266
285
  return new Promise((resolve, reject) => {
267
286
  fs.truncate(path, size, (err) => {
@@ -274,7 +293,6 @@ function truncate(path, size) {
274
293
  });
275
294
  });
276
295
  }
277
- exports.truncate = truncate;
278
296
  function ftruncate(fd, size) {
279
297
  return new Promise((resolve, reject) => {
280
298
  fs.ftruncate(fd, size, (err) => {
@@ -287,7 +305,6 @@ function ftruncate(fd, size) {
287
305
  });
288
306
  });
289
307
  }
290
- exports.ftruncate = ftruncate;
291
308
  /**
292
309
  * @param fd is an open file descriptor
293
310
  * @param pos is a position in the file, from which reading should start
@@ -313,7 +330,6 @@ async function readToBuf(fd, pos, buf) {
313
330
  pos += bNum;
314
331
  }
315
332
  }
316
- exports.readToBuf = readToBuf;
317
333
  /**
318
334
  * @param fd is an open file descriptor
319
335
  * @param pos is a position in the file, from which writing should start
@@ -331,7 +347,6 @@ async function writeFromBuf(fd, pos, buf) {
331
347
  pos += bNum;
332
348
  }
333
349
  }
334
- exports.writeFromBuf = writeFromBuf;
335
350
  const SINGLE_BYTE_BUF = Buffer.alloc(1);
336
351
  SINGLE_BYTE_BUF[0] = 0;
337
352
  /**
@@ -366,7 +381,6 @@ async function createEmptyFile(filePath, fileSize, keepFileOpen) {
366
381
  throw exc;
367
382
  }
368
383
  }
369
- exports.createEmptyFile = createEmptyFile;
370
384
  /**
371
385
  * @param path
372
386
  * @return a promise, resolvable to true, if given path represents directory,
@@ -389,7 +403,6 @@ async function existsFolder(path) {
389
403
  throw e;
390
404
  }
391
405
  }
392
- exports.existsFolder = existsFolder;
393
406
  /**
394
407
  * @param path
395
408
  * @return true, if given path represents directory, or false, if it does not.
@@ -410,7 +423,6 @@ function existsFolderSync(path) {
410
423
  throw e;
411
424
  }
412
425
  }
413
- exports.existsFolderSync = existsFolderSync;
414
426
  /**
415
427
  * @param path
416
428
  * @return true, if given path represents file, or false, if it does not.
@@ -431,7 +443,6 @@ function existsFileSync(path) {
431
443
  throw e;
432
444
  }
433
445
  }
434
- exports.existsFileSync = existsFileSync;
435
446
  /**
436
447
  * @param filePath
437
448
  * @return a promise, resolvable to file's size.
@@ -440,7 +451,6 @@ async function getFileSize(filePath) {
440
451
  const st = await stat(filePath);
441
452
  return st.size;
442
453
  }
443
- exports.getFileSize = getFileSize;
444
454
  /**
445
455
  * This returns a promise of total size of given folder's content.
446
456
  * Sizes of linked objects are not included.
@@ -461,7 +471,6 @@ async function getFolderContentSize(folderPath) {
461
471
  }
462
472
  return size;
463
473
  }
464
- exports.getFolderContentSize = getFolderContentSize;
465
474
  /**
466
475
  * @param fd is an open file descriptor
467
476
  * @param pos is a position in the file, from which writing should start
@@ -479,7 +488,6 @@ async function write(fd, pos, buf) {
479
488
  pos += bNum;
480
489
  }
481
490
  }
482
- exports.write = write;
483
491
  /**
484
492
  * @param fd is an open file descriptor in append mode.
485
493
  * @param buf is a buffer, from which all bytes should be written into the file.
@@ -492,7 +500,6 @@ async function append(fd, buf) {
492
500
  bytesWritten += bNum;
493
501
  }
494
502
  }
495
- exports.append = append;
496
503
  /**
497
504
  * @param filePath is a path to an existing file
498
505
  * @param pos is a position in the file, from which writing should start
@@ -594,7 +601,6 @@ async function streamToExistingFile(filePath, pos, len, src, bufSize) {
594
601
  src.resume(); // noop, if stream wasn't paused
595
602
  return deferred.promise;
596
603
  }
597
- exports.streamToExistingFile = streamToExistingFile;
598
604
  /**
599
605
  * @param fd is an open file descriptor
600
606
  * @param pos is a position in the file, from which reading should start
@@ -620,7 +626,6 @@ async function read(fd, pos, buf) {
620
626
  pos += bNum;
621
627
  }
622
628
  }
623
- exports.read = read;
624
629
  /**
625
630
  * @param filePath is a file's path, from which to read
626
631
  * @param pos is a position in the file, from which reading should start
@@ -669,7 +674,6 @@ async function rmDirWithContent(folder) {
669
674
  await Promise.all(rmTasks);
670
675
  await rmdir(folder);
671
676
  }
672
- exports.rmDirWithContent = rmDirWithContent;
673
677
  /**
674
678
  * @param w is a writable stream
675
679
  * @param buf is buffer of bytes that should be sunk into given stream
@@ -719,7 +723,6 @@ async function streamFromFile(filePath, pos, len, sink, bufSize) {
719
723
  byteCount += buf.length;
720
724
  }
721
725
  }
722
- exports.streamFromFile = streamFromFile;
723
726
  /**
724
727
  * This pipes source file into destination file.
725
728
  * @param src
@@ -749,7 +752,6 @@ function copyFile(src, dst, overwrite = false, dstMode = '660') {
749
752
  dstStream.on('error', onErr);
750
753
  });
751
754
  }
752
- exports.copyFile = copyFile;
753
755
  /**
754
756
  * This copies tree of files from source to destination folders.
755
757
  * Target folders may exist in a destination tree.
@@ -788,7 +790,6 @@ async function copyTree(src, dst, fileOverwrite = false) {
788
790
  }
789
791
  await Promise.all(cpTasks);
790
792
  }
791
- exports.copyTree = copyTree;
792
793
  /**
793
794
  * This function checks that given folder exists. If folder is not present,
794
795
  * it is created, recreating whole folder tree, if needed.
@@ -808,5 +809,4 @@ async function ensureFolderExists(path) {
808
809
  });
809
810
  });
810
811
  }
811
- exports.ensureFolderExists = ensureFolderExists;
812
812
  Object.freeze(exports);
@@ -15,7 +15,8 @@
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.asyncFind = exports.asyncIteration = void 0;
18
+ exports.asyncIteration = asyncIteration;
19
+ exports.asyncFind = asyncFind;
19
20
  async function asyncIteration(iter, func) {
20
21
  let item;
21
22
  do {
@@ -26,7 +27,6 @@ async function asyncIteration(iter, func) {
26
27
  await func(item.value);
27
28
  } while (true);
28
29
  }
29
- exports.asyncIteration = asyncIteration;
30
30
  async function asyncFind(iter, predicate) {
31
31
  let item;
32
32
  do {
@@ -40,5 +40,4 @@ async function asyncFind(iter, predicate) {
40
40
  }
41
41
  } while (true);
42
42
  }
43
- exports.asyncFind = asyncFind;
44
43
  Object.freeze(exports);
@@ -1,4 +1,3 @@
1
- /// <reference types="node" />
2
1
  /**
3
2
  * @param u is an unsigned integer up to 16-bits to be stored big-endian way in
4
3
  * 2 bytes.