core-3nweb-client-lib 0.46.1 → 0.47.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 (27) hide show
  1. package/build/lib-client/doh.d.ts +2 -1
  2. package/build/lib-client/doh.js +13 -14
  3. package/build/lib-client/logging/log-to-file.js +0 -1
  4. package/build/lib-client/objs-on-disk/obj-on-disk.js +4 -2
  5. package/build/lib-client/request-utils.d.ts +7 -3
  6. package/build/lib-client/request-utils.js +5 -11
  7. package/build/lib-client/service-checks.d.ts +2 -1
  8. package/build/lib-client/service-checks.js +8 -6
  9. package/build/lib-client/service-locator.d.ts +6 -1
  10. package/build/lib-client/service-locator.js +31 -6
  11. package/build/lib-client/user-with-mid-session.d.ts +1 -1
  12. package/build/lib-client/user-with-mid-session.js +1 -2
  13. package/build/lib-common/ipc/ws-ipc.d.ts +1 -1
  14. package/build/lib-common-on-node/dns-from-node.d.ts +0 -0
  15. package/build/lib-common-on-node/dns-from-node.js +0 -0
  16. package/build/lib-common-on-node/fs-on-node.d.ts +2 -0
  17. package/build/lib-common-on-node/request-from-node.d.ts +2 -0
  18. package/build/lib-common-on-node/request-from-node.js +28 -0
  19. package/build/lib-common-on-node/websocket-from-node.d.ts +3 -0
  20. package/build/{lib-client/ws-utils.js → lib-common-on-node/websocket-from-node.js} +5 -4
  21. package/build/tests/jasmine.js +2 -2
  22. package/build/tests/libs-for-tests/core-runner.js +3 -1
  23. package/build/tests/libs-for-tests/setups.js +3 -1
  24. package/package.json +1 -1
  25. package/build/injected-globals/inject-on-node.d.ts +0 -2
  26. package/build/lib-client/ws-utils.d.ts +0 -3
  27. /package/build/{injected-globals/inject-on-node.js → lib-common-on-node/fs-on-node.js} +0 -0
@@ -1,2 +1,3 @@
1
+ import { RequestFn } from "./request-utils";
1
2
  import { DnsResolver } from "./service-locator";
2
- export declare function dohAt(dohServerUrl: string): DnsResolver;
3
+ export declare function dohAt(request: RequestFn<unknown>, dohServerUrl: string): DnsResolver;
@@ -17,12 +17,10 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.dohAt = dohAt;
20
- const https = require("https");
21
- const request_utils_1 = require("./request-utils");
22
- const dns_1 = require("dns");
23
- function dohAt(dohServerUrl) {
20
+ const service_locator_1 = require("./service-locator");
21
+ function dohAt(request, dohServerUrl) {
24
22
  async function resolveTxt(domain) {
25
- const answer = await sendDohQuestion(dohServerUrl, domain, 'TXT');
23
+ const answer = await sendDohQuestion(request, dohServerUrl, domain, 'TXT');
26
24
  let txt = [];
27
25
  for (const { data: line } of answer) {
28
26
  txt.push([line]);
@@ -31,38 +29,39 @@ function dohAt(dohServerUrl) {
31
29
  }
32
30
  return { resolveTxt };
33
31
  }
34
- async function sendDohQuestion(serverUrl, domain, type) {
32
+ async function sendDohQuestion(request, serverUrl, domain, type) {
35
33
  const opts = {
36
34
  method: 'GET',
37
35
  url: `${serverUrl}?name=${domain}&type=${type}`,
36
+ requestHeaders: {
37
+ accept: 'application/dns-json'
38
+ },
38
39
  responseType: 'json'
39
40
  };
40
- const httpsOpts = (0, request_utils_1.formHttpsReqOpts)(opts);
41
- httpsOpts.headers.accept = 'application/dns-json';
42
- const reply = await (0, request_utils_1.processRequest)(opts => https.request(opts), httpsOpts, opts, undefined)
41
+ const reply = await request(opts)
43
42
  .catch((exc) => {
44
43
  if (exc.type === 'connect') {
45
- throw { code: dns_1.CONNREFUSED, hostname: domain, cause: exc };
44
+ throw { code: service_locator_1.CONNREFUSED, hostname: domain, cause: exc };
46
45
  }
47
46
  else {
48
- throw { code: dns_1.SERVFAIL, hostname: domain, cause: exc };
47
+ throw { code: service_locator_1.SERVFAIL, hostname: domain, cause: exc };
49
48
  }
50
49
  });
51
50
  const { status, data } = reply;
52
51
  if (status !== 200) {
53
52
  throw {
54
- code: dns_1.SERVFAIL, hostname: domain,
53
+ code: service_locator_1.SERVFAIL, hostname: domain,
55
54
  message: `status ${reply.status} from DoH server`
56
55
  };
57
56
  }
58
57
  if (data.Status !== 0) {
59
- throw { code: dns_1.NOTFOUND, hostname: domain };
58
+ throw { code: service_locator_1.NOTFOUND, hostname: domain };
60
59
  }
61
60
  if (data.Answer) {
62
61
  return data.Answer;
63
62
  }
64
63
  else {
65
- throw { code: dns_1.NODATA, hostname: domain };
64
+ throw { code: service_locator_1.NODATA, hostname: domain };
66
65
  }
67
66
  }
68
67
  Object.freeze(exports);
@@ -58,7 +58,6 @@ Log level: error.${msg ? `
58
58
  ${msg}` : ''}
59
59
  ${(0, error_1.stringifyErr)(err)}`;
60
60
  await appendLog(entry, now);
61
- console.error(`[duplicating log message into console] ${entry}`);
62
61
  }
63
62
  catch (err2) {
64
63
  console.error(err);
@@ -26,7 +26,6 @@ const file_writing_proc_1 = require("./file-writing-proc");
26
26
  const operators_1 = require("rxjs/operators");
27
27
  const obj_version_file_1 = require("../../lib-common/objs-on-disk/obj-version-file");
28
28
  const utils_for_observables_1 = require("../../lib-common/utils-for-observables");
29
- const types_1 = require("util/types");
30
29
  const deferred_1 = require("../../lib-common/processes/deferred");
31
30
  class ObjOnDisk {
32
31
  constructor(objId, version, objFile, downloader, readable, getBaseSegsOnDisk, downloadsInProgress = undefined) {
@@ -349,7 +348,7 @@ class Download {
349
348
  const { chunk, chunkBytes, deferred, segments } = this.segsAsapRequest[0];
350
349
  const segment = segments[0];
351
350
  try {
352
- if ((0, types_1.isPromise)(segment)) {
351
+ if (isPromise(segment)) {
353
352
  chunkBytes.push(await segment);
354
353
  segments.shift();
355
354
  }
@@ -561,6 +560,9 @@ class DownloadsRunner {
561
560
  exports.DownloadsRunner = DownloadsRunner;
562
561
  Object.freeze(DownloadsRunner.prototype);
563
562
  Object.freeze(DownloadsRunner);
563
+ function isPromise(object) {
564
+ return !!object.then;
565
+ }
564
566
  function makeExecPool(max) {
565
567
  return { queue: [], max, numOfRunning: 0 };
566
568
  }
@@ -1,5 +1,6 @@
1
- import * as https from 'https';
2
- import { ClientRequest } from 'http';
1
+ import type * as https from 'https';
2
+ import type * as WebSocket from 'ws';
3
+ import type { ClientRequest, OutgoingHttpHeaders } from 'http';
3
4
  export declare const SESSION_ID_HEADER = "X-Session-Id";
4
5
  export declare const CONTENT_TYPE_HEADER = "Content-Type";
5
6
  export interface JSONHttpRequest extends XMLHttpRequest {
@@ -18,6 +19,7 @@ export interface RequestOpts {
18
19
  appPath?: string;
19
20
  responseType?: 'json' | 'arraybuffer' | 'text';
20
21
  sessionId?: string;
22
+ requestHeaders?: OutgoingHttpHeaders;
21
23
  responseHeaders?: string[];
22
24
  timeout?: number;
23
25
  timeoutRetries?: number;
@@ -30,6 +32,7 @@ export type RequestFn<T> = (opts: RequestOpts, contentType?: ContentType, reqBod
30
32
  export declare function processRequest<T>(requester: (opts: https.RequestOptions) => ClientRequest, httpsOpts: https.RequestOptions, opts: RequestOpts, reqBody: Uint8Array | undefined, attempt?: number): Promise<Reply<T>>;
31
33
  export declare function formHttpsReqOpts(opts: RequestOpts, contentType?: ContentType, reqBody?: Uint8Array): https.RequestOptions;
32
34
  export declare function extractIntHeader(rep: Reply<any>, headerName: string): number;
35
+ export type OpenWebSocket = (url: string, sessionId: string) => Promise<Reply<WebSocket>>;
33
36
  export interface NetClient {
34
37
  /**
35
38
  * This makes a 'Content-Type: application/json' request with given json,
@@ -52,5 +55,6 @@ export interface NetClient {
52
55
  */
53
56
  doBodylessRequest<T>(opts: RequestOpts): Promise<Reply<T>>;
54
57
  reset(): void;
58
+ openWebSocket: (url: string, sessionId: string) => Promise<Reply<WebSocket>>;
55
59
  }
56
- export declare function makeNetClient(request?: RequestFn<unknown>, reset?: () => void): NetClient;
60
+ export declare function makeNetClient(request: RequestFn<unknown>, openWebSocket: NetClient['openWebSocket'], reset?: () => void): NetClient;
@@ -22,7 +22,6 @@ exports.extractIntHeader = extractIntHeader;
22
22
  exports.makeNetClient = makeNetClient;
23
23
  const http_1 = require("../lib-common/exceptions/http");
24
24
  const bytes_fifo_buffer_1 = require("../lib-common/byte-streaming/bytes-fifo-buffer");
25
- const https = require("https");
26
25
  const rxjs_1 = require("rxjs");
27
26
  const buffer_utils_1 = require("../lib-common/buffer-utils");
28
27
  const deferred_1 = require("../lib-common/processes/deferred");
@@ -47,6 +46,7 @@ async function processRequest(requester, httpsOpts, opts, reqBody, attempt = 0)
47
46
  }
48
47
  }
49
48
  function formHttpsReqOpts(opts, contentType, reqBody) {
49
+ var _a;
50
50
  if (!opts.url) {
51
51
  throw new Error(`Cannot send net request, cause url is not set in given options.`);
52
52
  }
@@ -60,7 +60,7 @@ function formHttpsReqOpts(opts, contentType, reqBody) {
60
60
  hostname: url.hostname,
61
61
  port: url.port,
62
62
  path: url.pathname + url.search,
63
- headers: {}
63
+ headers: (_a = opts.requestHeaders) !== null && _a !== void 0 ? _a : {}
64
64
  };
65
65
  if (reqBody) {
66
66
  netReqOpts.headers['Content-Length'] = reqBody.length;
@@ -178,14 +178,7 @@ function extractIntHeader(rep, headerName) {
178
178
  }
179
179
  return intHeader;
180
180
  }
181
- function makeNodeRequest() {
182
- const nodeRequest = (opts) => https.request(opts);
183
- return (opts, contentType, reqBody) => {
184
- const httpsOpts = formHttpsReqOpts(opts, contentType, reqBody);
185
- return processRequest(nodeRequest, httpsOpts, opts, reqBody);
186
- };
187
- }
188
- function makeNetClient(request = makeNodeRequest(), reset = () => { }) {
181
+ function makeNetClient(request, openWebSocket, reset = () => { }) {
189
182
  const client = {
190
183
  doBinaryRequest(opts, bytes) {
191
184
  let reqBody;
@@ -208,7 +201,8 @@ function makeNetClient(request = makeNodeRequest(), reset = () => { }) {
208
201
  const reqBody = ((json === undefined) ? new Uint8Array(0) : buffer_utils_1.utf8.pack(JSON.stringify(json)));
209
202
  return request(opts, 'application/json', reqBody);
210
203
  },
211
- reset
204
+ reset,
205
+ openWebSocket
212
206
  };
213
207
  return Object.freeze(client);
214
208
  }
@@ -1,4 +1,5 @@
1
1
  import { NetClient } from "./request-utils";
2
+ import { ServiceLocatorMaker } from "./service-locator";
2
3
  export interface Check {
3
4
  service: 'signup' | 'asmail' | '3nstorage' | 'mailerid';
4
5
  }
@@ -15,4 +16,4 @@ export interface CheckResult extends Check {
15
16
  message: string;
16
17
  err?: any;
17
18
  }
18
- export declare function checkServicesStartingFromSignup(client: NetClient, signupUrl: string, signupToken: string | undefined, progress?: (result: CheckResult | CheckStart) => void): Promise<CheckResult[]>;
19
+ export declare function checkServicesStartingFromSignup(srvLocator: ServiceLocatorMaker, client: NetClient, signupUrl: string, signupToken: string | undefined, progress?: (result: CheckResult | CheckStart) => void): Promise<CheckResult[]>;
@@ -18,10 +18,8 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.checkServicesStartingFromSignup = checkServicesStartingFromSignup;
20
20
  const _3nweb_signup_1 = require("./3nweb-signup");
21
- const doh_1 = require("./doh");
22
21
  const service_locator_1 = require("./service-locator");
23
- const dns_1 = require("dns");
24
- async function checkServicesStartingFromSignup(client, signupUrl, signupToken, progress) {
22
+ async function checkServicesStartingFromSignup(srvLocator, client, signupUrl, signupToken, progress) {
25
23
  const results = [];
26
24
  function recordResult(r) {
27
25
  progress === null || progress === void 0 ? void 0 : progress(r);
@@ -35,7 +33,7 @@ async function checkServicesStartingFromSignup(client, signupUrl, signupToken, p
35
33
  }
36
34
  async function checkService(service, userDomain) {
37
35
  progress === null || progress === void 0 ? void 0 : progress({ start: true, service, userDomain });
38
- const check = await checkUserDomainDNS(service, userDomain);
36
+ const check = await checkUserDomainDNS(srvLocator, service, userDomain);
39
37
  recordResult(check);
40
38
  if (check.isOk) {
41
39
  await checkFstServiceEndpoint(service, check.serviceUrl);
@@ -127,8 +125,12 @@ async function checkSignup(client, signupURL, signupToken) {
127
125
  };
128
126
  }
129
127
  }
130
- const srvLocator = (0, service_locator_1.makeServiceLocator)({ resolveTxt: dns_1.promises.resolveTxt }, (0, doh_1.dohAt)(`https://cloudflare-dns.com/dns-query`), (0, doh_1.dohAt)(`https://dns.google/resolve`));
131
- async function checkUserDomainDNS(service, domain) {
128
+ // const srvLocator = makeServiceLocator(
129
+ // { resolveTxt: dns.resolveTxt },
130
+ // dohAt(`https://cloudflare-dns.com/dns-query`),
131
+ // dohAt(`https://dns.google/resolve`)
132
+ // );
133
+ async function checkUserDomainDNS(srvLocator, service, domain) {
132
134
  try {
133
135
  const serviceUrl = await (srvLocator(service, noop))(`u@${domain}`);
134
136
  return {
@@ -1,5 +1,5 @@
1
1
  import { NetClient } from './request-utils';
2
- import { promises as dnsPromises } from 'dns';
2
+ import type { promises as dnsPromises } from 'dns';
3
3
  import { StorageRootRoute } from '../lib-common/service-api/3nstorage/root-route';
4
4
  import { ASMailRootRoute } from '../lib-common/service-api/asmail/root-route';
5
5
  import { LogError } from './logging/log-to-file';
@@ -33,6 +33,11 @@ export type ServiceLocator = (address: string) => Promise<string>;
33
33
  export interface DnsResolver {
34
34
  resolveTxt: (typeof dnsPromises)['resolveTxt'];
35
35
  }
36
+ export declare const NODATA = "ENODATA";
37
+ export declare const SERVFAIL = "ESERVFAIL";
38
+ export declare const NOTFOUND = "ENOTFOUND";
39
+ export declare const CONNREFUSED = "ECONNREFUSED";
40
+ export declare const TIMEOUT = "ETIMEOUT";
36
41
  export declare function makeServiceLocator(...resolvers: DnsResolver[]): ServiceLocatorMaker;
37
42
  /**
38
43
  * @param resolver
@@ -16,13 +16,14 @@
16
16
  this program. If not, see <http://www.gnu.org/licenses/>.
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
+ exports.TIMEOUT = exports.CONNREFUSED = exports.NOTFOUND = exports.SERVFAIL = exports.NODATA = void 0;
19
20
  exports.asmailInfoAt = asmailInfoAt;
20
21
  exports.mailerIdInfoAt = mailerIdInfoAt;
21
22
  exports.storageInfoAt = storageInfoAt;
22
23
  exports.makeServiceLocator = makeServiceLocator;
23
24
  exports.getMailerIdInfoFor = getMailerIdInfoFor;
24
25
  const jwkeys_1 = require("../lib-common/jwkeys");
25
- const dns_1 = require("dns");
26
+ // import { CONNREFUSED, NODATA, NOTFOUND, SERVFAIL, TIMEOUT } from 'dns';
26
27
  const runtime_1 = require("../lib-common/exceptions/runtime");
27
28
  const http_1 = require("../lib-common/exceptions/http");
28
29
  async function readJSONLocatedAt(client, url) {
@@ -216,6 +217,30 @@ function getRecordAtStartOf(txt) {
216
217
  value: txt
217
218
  };
218
219
  }
220
+ exports.NODATA = "ENODATA";
221
+ // export const FORMERR = "EFORMERR";
222
+ exports.SERVFAIL = "ESERVFAIL";
223
+ exports.NOTFOUND = "ENOTFOUND";
224
+ // export const NOTIMP = "ENOTIMP";
225
+ // export const REFUSED = "EREFUSED";
226
+ // export const BADQUERY = "EBADQUERY";
227
+ // export const BADNAME = "EBADNAME";
228
+ // export const BADFAMILY = "EBADFAMILY";
229
+ // export const BADRESP = "EBADRESP";
230
+ exports.CONNREFUSED = "ECONNREFUSED";
231
+ exports.TIMEOUT = "ETIMEOUT";
232
+ // export const EOF = "EOF";
233
+ // export const FILE = "EFILE";
234
+ // export const NOMEM = "ENOMEM";
235
+ // export const DESTRUCTION = "EDESTRUCTION";
236
+ // export const BADSTR = "EBADSTR";
237
+ // export const BADFLAGS = "EBADFLAGS";
238
+ // export const NONAME = "ENONAME";
239
+ // export const BADHINTS = "EBADHINTS";
240
+ // export const NOTINITIALIZED = "ENOTINITIALIZED";
241
+ // export const LOADIPHLPAPI = "ELOADIPHLPAPI";
242
+ // export const ADDRGETNETWORKPARAMS = "EADDRGETNETWORKPARAMS";
243
+ // export const CANCELLED = "ECANCELLED";
219
244
  function makeServiceLocator(...resolvers) {
220
245
  if (resolvers.length === 0) {
221
246
  throw Error(`no DNS resolvers given`);
@@ -237,17 +262,17 @@ function makeServiceLocator(...resolvers) {
237
262
  catch (err) {
238
263
  await logError(err, `Resolver ${i + 1} fails to get TXT records of ${domain}`);
239
264
  const { code, hostname, message } = err;
240
- if (code === dns_1.NODATA) {
265
+ if (code === exports.NODATA) {
241
266
  throw noServiceRecordExc(address);
242
267
  }
243
- else if ((code === dns_1.SERVFAIL)
244
- || (code === dns_1.CONNREFUSED)
245
- || (code === dns_1.TIMEOUT)) {
268
+ else if ((code === exports.SERVFAIL)
269
+ || (code === exports.CONNREFUSED)
270
+ || (code === exports.TIMEOUT)) {
246
271
  if (!prevConnectionExc) {
247
272
  prevConnectionExc = noConnectionExc({ code, hostname, message });
248
273
  }
249
274
  }
250
- else if ((code === dns_1.NOTFOUND) || hostname) {
275
+ else if ((code === exports.NOTFOUND) || hostname) {
251
276
  throw domainNotFoundExc(address, { code, hostname, message });
252
277
  }
253
278
  else {
@@ -3,7 +3,7 @@
3
3
  * MailerId and uses respectively authenticated session.
4
4
  */
5
5
  import { Reply, RequestOpts, NetClient } from '../lib-client/request-utils';
6
- import * as WebSocket from 'ws';
6
+ import type * as WebSocket from 'ws';
7
7
  import { MailerIdSigner } from '../lib-common/mailerid-sigs/user';
8
8
  import { AwaitableState } from '../lib-common/awaitable-state';
9
9
  export type IGetMailerIdSigner = () => Promise<MailerIdSigner>;
@@ -18,7 +18,6 @@
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  exports.ServiceUser = void 0;
20
20
  const api = require("../lib-common/service-api/mailer-id/login");
21
- const ws_utils_1 = require("./ws-utils");
22
21
  const login_1 = require("./mailer-id/login");
23
22
  const assert_1 = require("../lib-common/assert");
24
23
  const http_1 = require("../lib-common/exceptions/http");
@@ -228,7 +227,7 @@ class ServiceUser {
228
227
  };
229
228
  return this.callEnsuringLogin(() => {
230
229
  this.prepCallOpts(opts, true);
231
- return (0, ws_utils_1.openSocket)(opts.url, opts.sessionId);
230
+ return this.net.openWebSocket(opts.url, opts.sessionId);
232
231
  });
233
232
  }
234
233
  }
@@ -1,6 +1,6 @@
1
1
  import { Observable } from 'rxjs';
2
2
  import { SubscribingClient } from './generic-ipc';
3
- import * as WebSocket from 'ws';
3
+ import type * as WebSocket from 'ws';
4
4
  import type { ConnectException, HTTPException } from '../exceptions/http';
5
5
  export { RequestEnvelope, RequestHandler, EventfulServer, makeEventfulServer, SubscribingClient } from './generic-ipc';
6
6
  export interface WSException extends web3n.RuntimeException {
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+ import { PlatformDeviceFS } from '../injected-globals/platform-devfs';
2
+ export declare function makePlatformDeviceFS(): PlatformDeviceFS;
@@ -0,0 +1,2 @@
1
+ import { RequestFn } from '../lib-client/request-utils';
2
+ export declare function makeRequestFromNode(): RequestFn<unknown>;
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ /*
3
+ Copyright (C) 2026 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.makeRequestFromNode = makeRequestFromNode;
20
+ const https = require("https");
21
+ const request_utils_1 = require("../lib-client/request-utils");
22
+ function makeRequestFromNode() {
23
+ const nodeRequest = (opts) => https.request(opts);
24
+ return (opts, contentType, reqBody) => {
25
+ const httpsOpts = (0, request_utils_1.formHttpsReqOpts)(opts, contentType, reqBody);
26
+ return (0, request_utils_1.processRequest)(nodeRequest, httpsOpts, opts, reqBody);
27
+ };
28
+ }
@@ -0,0 +1,3 @@
1
+ import * as WebSocket from 'ws';
2
+ import { Reply } from '../lib-client/request-utils';
3
+ export declare function openSocketFromNode(url: string, sessionId: string): Promise<Reply<WebSocket>>;
@@ -13,15 +13,16 @@
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
- exports.openSocket = openSocket;
19
+ exports.openSocketFromNode = openSocketFromNode;
19
20
  const WebSocket = require("ws");
20
- const request_utils_1 = require("./request-utils");
21
+ const request_utils_1 = require("../lib-client/request-utils");
21
22
  const deferred_1 = require("../lib-common/processes/deferred");
22
23
  const http_1 = require("../lib-common/exceptions/http");
23
24
  const https_1 = require("https");
24
- function openSocket(url, sessionId) {
25
+ function openSocketFromNode(url, sessionId) {
25
26
  if (!url.startsWith('wss://')) {
26
27
  throw new Error(`Url protocol must be wss`);
27
28
  }
@@ -17,10 +17,10 @@
17
17
  */
18
18
  Object.defineProperty(exports, "__esModule", { value: true });
19
19
  const jasmine = require("jasmine");
20
- const inject_on_node_1 = require("../injected-globals/inject-on-node");
20
+ const fs_on_node_1 = require("../lib-common-on-node/fs-on-node");
21
21
  // injecting global's expected to be on node
22
22
  globalThis.platform = {
23
- device_fs: (0, inject_on_node_1.makePlatformDeviceFS)()
23
+ device_fs: (0, fs_on_node_1.makePlatformDeviceFS)()
24
24
  };
25
25
  const jas = new jasmine({});
26
26
  const specsFromCLI = [];
@@ -29,6 +29,8 @@ const caps_ipc_wrap_1 = require("./caps-ipc-wrap");
29
29
  const service_locator_1 = require("../../lib-client/service-locator");
30
30
  const dns_1 = require("dns");
31
31
  const napi_nacl_1 = require("napi-nacl");
32
+ const request_from_node_1 = require("../../lib-common-on-node/request-from-node");
33
+ const websocket_from_node_1 = require("../../lib-common-on-node/websocket-from-node");
32
34
  exports.testApp = {
33
35
  appDomain: 'test.3nweb.app',
34
36
  capsRequested: {
@@ -80,7 +82,7 @@ class CoreRunner {
80
82
  this.appCaps.close();
81
83
  this.appCaps = undefined;
82
84
  }
83
- this.runningCore = lib_index_1.Core.make({ dataDir: this.dataFolder, signUpUrl: this.signUpUrl }, lib_index_1.makeNetClient, (0, service_locator_1.makeServiceLocator)({
85
+ this.runningCore = lib_index_1.Core.make({ dataDir: this.dataFolder, signUpUrl: this.signUpUrl }, () => (0, lib_index_1.makeNetClient)((0, request_from_node_1.makeRequestFromNode)(), websocket_from_node_1.openSocketFromNode), (0, service_locator_1.makeServiceLocator)({
84
86
  resolveTxt: domain => new Promise((resolve, reject) => (0, dns_1.resolveTxt)(domain, (err, texts) => {
85
87
  if (err) {
86
88
  reject(err);
@@ -28,6 +28,8 @@ const assert_1 = require("../../lib-common/assert");
28
28
  const request_utils_1 = require("../../lib-client/request-utils");
29
29
  const retrieval_1 = require("../../lib-common/service-api/asmail/retrieval");
30
30
  const sleep_1 = require("../../lib-common/processes/sleep");
31
+ const request_from_node_1 = require("../../lib-common-on-node/request-from-node");
32
+ const websocket_from_node_1 = require("../../lib-common-on-node/websocket-from-node");
31
33
  const SERVICE_PORT = 8088;
32
34
  const SIGNUP_URL = `https://localhost:${SERVICE_PORT}/signup/`;
33
35
  function makeSetupObject(domains) {
@@ -260,7 +262,7 @@ function domainFromUserId(userId) {
260
262
  function serviceWithMailerIdLogin() {
261
263
  const testSrv = (new URL(SIGNUP_URL)).host;
262
264
  const serviceUrl = `https://${testSrv}/asmail/retrieval/login/mailerid`;
263
- const net = (0, request_utils_1.makeNetClient)();
265
+ const net = (0, request_utils_1.makeNetClient)((0, request_from_node_1.makeRequestFromNode)(), websocket_from_node_1.openSocketFromNode);
264
266
  async function isSessionValid(sessionId) {
265
267
  const rep = await net.doBodylessRequest({
266
268
  url: `https://${testSrv}/asmail/retrieval/${retrieval_1.listMsgs.genUrlEnd()}`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.46.1",
3
+ "version": "0.47.0",
4
4
  "description": "3NWeb client core library, embeddable into different environments",
5
5
  "main": "build/lib-index.js",
6
6
  "types": "build/lib-index.d.ts",
@@ -1,2 +0,0 @@
1
- import { PlatformDeviceFS } from './platform-devfs';
2
- export declare function makePlatformDeviceFS(): PlatformDeviceFS;
@@ -1,3 +0,0 @@
1
- import * as WebSocket from 'ws';
2
- import { Reply } from './request-utils';
3
- export declare function openSocket(url: string, sessionId: string): Promise<Reply<WebSocket>>;