core-3nweb-client-lib 0.41.11 → 0.41.13

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 (28) hide show
  1. package/build/core/asmail/inbox/inbox-events.js +2 -2
  2. package/build/core/storage/synced/remote-events.js +2 -2
  3. package/build/lib-client/3nstorage/storage-owner.d.ts +2 -1
  4. package/build/lib-client/3nstorage/storage-owner.js +2 -2
  5. package/build/lib-client/asmail/recipient.d.ts +2 -1
  6. package/build/lib-client/asmail/recipient.js +2 -2
  7. package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
  8. package/build/lib-client/cryptor/cryptor.wasm +0 -0
  9. package/build/lib-client/server-events.js +7 -2
  10. package/build/lib-common/ipc/generic-ipc.js +2 -0
  11. package/build/lib-common/ipc/ws-ipc.d.ts +2 -1
  12. package/build/lib-common/ipc/ws-ipc.js +53 -11
  13. package/build/lib-index.d.ts +6 -2
  14. package/build/lib-index.js +16 -7
  15. package/package.json +1 -1
  16. package/test-data-1-1759442588983/util/logs/2025-10-02.log.txt +6 -0
  17. package/test-data-10-1759442625007/util/logs/2025-10-02.log.txt +11 -0
  18. package/test-data-11-1759442625008/util/logs/2025-10-02.log.txt +6 -0
  19. package/test-data-12-1759442628713/util/logs/2025-10-02.log.txt +6 -0
  20. package/test-data-13-1759442629512/util/logs/2025-10-02.log.txt +11 -0
  21. package/test-data-2-1759442588985/util/logs/2025-10-02.log.txt +6 -0
  22. package/test-data-3-1759442593521/util/logs/2025-10-02.log.txt +11 -0
  23. package/test-data-4-1759442599428/util/logs/2025-10-02.log.txt +11 -0
  24. package/test-data-5-1759442608549/util/logs/2025-10-02.log.txt +6 -0
  25. package/test-data-6-1759442610426/util/logs/2025-10-02.log.txt +6 -0
  26. package/test-data-7-1759442612369/util/logs/2025-10-02.log.txt +6 -0
  27. package/test-data-8-1759442620927/util/logs/2025-10-02.log.txt +6 -0
  28. package/test-data-9-1759442621732/util/logs/2025-10-02.log.txt +11 -0
@@ -77,7 +77,8 @@ class ServerEvents {
77
77
  // XXX tap to log more details
78
78
  (0, operators_1.tap)({
79
79
  complete: () => this.logError({}, `ServerEvents.observe stream completes`),
80
- error: err => this.logError(err, `ServerEvents.observe stream has error`)
80
+ error: err => this.logError(err, `ServerEvents.observe stream has error,
81
+ ${(0, error_1.stringifyErr)(err)}`)
81
82
  }), (0, operators_1.catchError)(err => {
82
83
  if (this.shouldRestartAfterErr(err)) {
83
84
  console.error((0, error_1.stringifyErr)(err));
@@ -116,7 +117,11 @@ class ServerEvents {
116
117
  }
117
118
  restartObservation(event) {
118
119
  return (0, rxjs_1.from)((0, sleep_1.sleep)(this.restartWaitSecs * 1000))
119
- .pipe((0, operators_1.mergeMap)(() => this.observe(event)));
120
+ .pipe(
121
+ // XXX tap to log more details
122
+ (0, operators_1.tap)({
123
+ next: () => this.logError({}, `ServerEvents.restartObservation of ${event} events`)
124
+ }), (0, operators_1.mergeMap)(() => this.observe(event)));
120
125
  }
121
126
  }
122
127
  exports.ServerEvents = ServerEvents;
@@ -315,6 +315,7 @@ class EventsSendingSide extends ReplyingSide {
315
315
  throw makeEventException({
316
316
  channel: this.channel,
317
317
  unknownEvent: true,
318
+ event,
318
319
  message: `Events' channel ${event} is not found in handling subscribe`
319
320
  });
320
321
  }
@@ -328,6 +329,7 @@ class EventsSendingSide extends ReplyingSide {
328
329
  throw makeEventException({
329
330
  channel: this.channel,
330
331
  unknownEvent: true,
332
+ event,
331
333
  message: `Events' channel ${event} is not found in handling unsubscribe`
332
334
  });
333
335
  }
@@ -1,3 +1,4 @@
1
+ import { LogError } from '../../lib-client/logging/log-to-file';
1
2
  import { SubscribingClient } from './generic-ipc';
2
3
  import * as WebSocket from 'ws';
3
4
  export { RequestEnvelope, RequestHandler, EventfulServer, makeEventfulServer, SubscribingClient } from './generic-ipc';
@@ -7,4 +8,4 @@ export interface WSException extends web3n.RuntimeException {
7
8
  socketClosed?: true;
8
9
  }
9
10
  export declare function makeWSException(params: Partial<WSException>, flags?: Partial<WSException>): WSException;
10
- export declare function makeSubscriber(ws: WebSocket, ipcChannel: string | undefined): SubscribingClient;
11
+ export declare function makeSubscriber(ws: WebSocket, ipcChannel: string | undefined, log: LogError): SubscribingClient;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2017 3NSoft Inc.
3
+ Copyright (C) 2017, 2025 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -32,12 +32,13 @@ const MAX_TXT_BUFFER = 64 * 1024;
32
32
  * messages.
33
33
  * @param ws
34
34
  */
35
- function makeJsonCommPoint(ws) {
35
+ function makeJsonCommPoint(ws, log) {
36
36
  const observers = new generic_ipc_1.MultiObserverWrap();
37
- ws.on('message', onTxtMessage(ws, observers));
38
- ws.on('close', onClose(observers));
39
- ws.on('error', onError(ws, observers));
40
- ws.on('ping', () => ws.pong());
37
+ const resetTimer = makeSignalsTimeObserver(ws.url, log);
38
+ ws.on('message', onTxtMessage(ws, observers, resetTimer));
39
+ ws.on('close', onClose(observers, resetTimer));
40
+ ws.on('error', onError(ws, observers, resetTimer));
41
+ ws.on('ping', onPing(ws, resetTimer));
41
42
  const commPoint = {
42
43
  subscribe: obs => observers.add(obs),
43
44
  postMessage(env) {
@@ -54,7 +55,7 @@ function makeJsonCommPoint(ws) {
54
55
  * @param ws
55
56
  * @param observers
56
57
  */
57
- function onTxtMessage(ws, observers) {
58
+ function onTxtMessage(ws, observers, resetTimer) {
58
59
  return (data) => {
59
60
  if (typeof data !== 'string') {
60
61
  return;
@@ -72,18 +73,21 @@ function onTxtMessage(ws, observers) {
72
73
  return;
73
74
  }
74
75
  observers.next(env);
76
+ resetTimer();
75
77
  };
76
78
  }
77
79
  /**
78
80
  * This generates an on-close callback for a web socket.
79
81
  * @param observers
80
82
  */
81
- function onClose(observers) {
83
+ function onClose(observers, resetTimer) {
82
84
  return (code, reason) => {
83
85
  if (code === 1000) {
86
+ resetTimer(true);
84
87
  observers.complete();
85
88
  }
86
89
  else {
90
+ resetTimer(true, { code, reason });
87
91
  observers.error(makeWSException({
88
92
  socketClosed: true,
89
93
  cause: { code, reason }
@@ -96,14 +100,52 @@ function onClose(observers) {
96
100
  * @param ws
97
101
  * @param observers
98
102
  */
99
- function onError(ws, observers) {
103
+ function onError(ws, observers, closeTimer) {
100
104
  return (err) => {
105
+ closeTimer(true, err);
101
106
  observers.error(makeWSException({ cause: err }));
102
107
  ws.close();
103
108
  };
104
109
  }
105
- function makeSubscriber(ws, ipcChannel) {
106
- const comm = makeJsonCommPoint(ws);
110
+ function onPing(ws, resetTimer) {
111
+ return () => {
112
+ resetTimer();
113
+ ws.pong();
114
+ };
115
+ }
116
+ function makeSignalsTimeObserver(url, log) {
117
+ const serverPingSettings = 2 * 60 * 1000;
118
+ let lastMoment = Date.now();
119
+ let int = undefined;
120
+ function resetWait(setNew = true) {
121
+ lastMoment = Date.now();
122
+ if (int) {
123
+ clearInterval(int);
124
+ int = undefined;
125
+ }
126
+ if (setNew) {
127
+ int = setInterval(() => {
128
+ log(`Ping/data from ${url} is not observed in last ${Math.floor((Date.now() - lastMoment) / 1000)} seconds`);
129
+ }, serverPingSettings * 1.5).unref();
130
+ }
131
+ }
132
+ return (done, err) => {
133
+ if (done) {
134
+ if (err) {
135
+ log(`WebSocket to ${url} closed with error`, err);
136
+ }
137
+ else {
138
+ log(`WebSocket to ${url} closed`);
139
+ }
140
+ resetWait(false);
141
+ }
142
+ else {
143
+ resetWait();
144
+ }
145
+ };
146
+ }
147
+ function makeSubscriber(ws, ipcChannel, log) {
148
+ const comm = makeJsonCommPoint(ws, log);
107
149
  return (0, generic_ipc_1.makeSubscribingClient)(ipcChannel, comm);
108
150
  }
109
151
  Object.freeze(exports);
@@ -1,9 +1,13 @@
1
1
  /// <reference path="api-defs/web3n.d.ts" />
2
2
  export * from "./core";
3
+ export { SignUp, CreatedUser } from './core/startup/sign-up';
4
+ export { IdManager } from './core/id-manager';
5
+ export { Storages, FactoryOfFSs, reverseDomain, PerAppStorage } from './core/storage';
6
+ export { SignIn, GenerateKey, CompleteInitWithoutCache } from './core/startup/sign-in';
7
+ export { ASMail } from './core/asmail';
3
8
  export { makeServiceLocator, ServiceLocatorMaker } from "./lib-client/service-locator";
4
9
  export { makeNetClient } from "./lib-client/request-utils";
5
- export { FactoryOfFSs, PerAppStorage, reverseDomain } from "./core/storage";
10
+ export { appDirs } from './core/app-files';
6
11
  export { sysFolders } from "./core/storage/system-folders";
7
12
  export { DeviceFS } from './lib-client/local-files/device-fs';
8
- export { appDirs } from './core/app-files';
9
13
  export { makeLogger } from './lib-client/logging/log-to-file';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  /*
3
- Copyright (C) 2020 - 2022 3NSoft Inc.
3
+ Copyright (C) 2020 - 2022, 2025 3NSoft Inc.
4
4
 
5
5
  This program is free software: you can redistribute it and/or modify it under
6
6
  the terms of the GNU General Public License as published by the Free Software
@@ -30,21 +30,30 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
30
30
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
31
31
  };
32
32
  Object.defineProperty(exports, "__esModule", { value: true });
33
- exports.makeLogger = exports.appDirs = exports.DeviceFS = exports.sysFolders = exports.reverseDomain = exports.PerAppStorage = exports.makeNetClient = exports.makeServiceLocator = void 0;
33
+ exports.makeLogger = exports.DeviceFS = exports.sysFolders = exports.appDirs = exports.makeNetClient = exports.makeServiceLocator = exports.ASMail = exports.SignIn = exports.PerAppStorage = exports.reverseDomain = exports.Storages = exports.IdManager = exports.SignUp = void 0;
34
34
  __exportStar(require("./core"), exports);
35
+ var sign_up_1 = require("./core/startup/sign-up");
36
+ Object.defineProperty(exports, "SignUp", { enumerable: true, get: function () { return sign_up_1.SignUp; } });
37
+ var id_manager_1 = require("./core/id-manager");
38
+ Object.defineProperty(exports, "IdManager", { enumerable: true, get: function () { return id_manager_1.IdManager; } });
39
+ var storage_1 = require("./core/storage");
40
+ Object.defineProperty(exports, "Storages", { enumerable: true, get: function () { return storage_1.Storages; } });
41
+ Object.defineProperty(exports, "reverseDomain", { enumerable: true, get: function () { return storage_1.reverseDomain; } });
42
+ Object.defineProperty(exports, "PerAppStorage", { enumerable: true, get: function () { return storage_1.PerAppStorage; } });
43
+ var sign_in_1 = require("./core/startup/sign-in");
44
+ Object.defineProperty(exports, "SignIn", { enumerable: true, get: function () { return sign_in_1.SignIn; } });
45
+ var asmail_1 = require("./core/asmail");
46
+ Object.defineProperty(exports, "ASMail", { enumerable: true, get: function () { return asmail_1.ASMail; } });
35
47
  var service_locator_1 = require("./lib-client/service-locator");
36
48
  Object.defineProperty(exports, "makeServiceLocator", { enumerable: true, get: function () { return service_locator_1.makeServiceLocator; } });
37
49
  var request_utils_1 = require("./lib-client/request-utils");
38
50
  Object.defineProperty(exports, "makeNetClient", { enumerable: true, get: function () { return request_utils_1.makeNetClient; } });
39
- var storage_1 = require("./core/storage");
40
- Object.defineProperty(exports, "PerAppStorage", { enumerable: true, get: function () { return storage_1.PerAppStorage; } });
41
- Object.defineProperty(exports, "reverseDomain", { enumerable: true, get: function () { return storage_1.reverseDomain; } });
51
+ var app_files_1 = require("./core/app-files");
52
+ Object.defineProperty(exports, "appDirs", { enumerable: true, get: function () { return app_files_1.appDirs; } });
42
53
  var system_folders_1 = require("./core/storage/system-folders");
43
54
  Object.defineProperty(exports, "sysFolders", { enumerable: true, get: function () { return system_folders_1.sysFolders; } });
44
55
  var device_fs_1 = require("./lib-client/local-files/device-fs");
45
56
  Object.defineProperty(exports, "DeviceFS", { enumerable: true, get: function () { return device_fs_1.DeviceFS; } });
46
- var app_files_1 = require("./core/app-files");
47
- Object.defineProperty(exports, "appDirs", { enumerable: true, get: function () { return app_files_1.appDirs; } });
48
57
  var log_to_file_1 = require("./lib-client/logging/log-to-file");
49
58
  Object.defineProperty(exports, "makeLogger", { enumerable: true, get: function () { return log_to_file_1.makeLogger; } });
50
59
  Object.freeze(exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "core-3nweb-client-lib",
3
- "version": "0.41.11",
3
+ "version": "0.41.13",
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",
@@ -0,0 +1,6 @@
1
+
2
+ Thu Oct 02 2025 18:03:26 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,11 @@
1
+
2
+ Thu Oct 02 2025 18:03:48 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/asmail/retrieval/events closed with error
7
+ Thu Oct 02 2025 18:03:48 GMT-0400 (Eastern Daylight Saving Time) ==================================
8
+ Core version 0.41.13
9
+ Log level: error.
10
+ [object Object]
11
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,6 @@
1
+
2
+ Thu Oct 02 2025 18:03:48 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,6 @@
1
+
2
+ Thu Oct 02 2025 18:03:51 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,11 @@
1
+
2
+ Thu Oct 02 2025 18:03:51 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
7
+ Thu Oct 02 2025 18:03:51 GMT-0400 (Eastern Daylight Saving Time) ==================================
8
+ Core version 0.41.13
9
+ Log level: error.
10
+ [object Object]
11
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,6 @@
1
+
2
+ Thu Oct 02 2025 18:03:28 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,11 @@
1
+
2
+ Thu Oct 02 2025 18:03:19 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
7
+ Thu Oct 02 2025 18:03:19 GMT-0400 (Eastern Daylight Saving Time) ==================================
8
+ Core version 0.41.13
9
+ Log level: error.
10
+ [object Object]
11
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,11 @@
1
+
2
+ Thu Oct 02 2025 18:03:24 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
7
+ Thu Oct 02 2025 18:03:24 GMT-0400 (Eastern Daylight Saving Time) ==================================
8
+ Core version 0.41.13
9
+ Log level: error.
10
+ [object Object]
11
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,6 @@
1
+
2
+ Thu Oct 02 2025 18:03:30 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,6 @@
1
+
2
+ Thu Oct 02 2025 18:03:32 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,6 @@
1
+
2
+ Thu Oct 02 2025 18:03:40 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,6 @@
1
+
2
+ Thu Oct 02 2025 18:03:44 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
@@ -0,0 +1,11 @@
1
+
2
+ Thu Oct 02 2025 18:03:44 GMT-0400 (Eastern Daylight Saving Time) ==================================
3
+ Core version 0.41.13
4
+ Log level: error.
5
+ [object Object]
6
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error
7
+ Thu Oct 02 2025 18:03:44 GMT-0400 (Eastern Daylight Saving Time) ==================================
8
+ Core version 0.41.13
9
+ Log level: error.
10
+ [object Object]
11
+ WebSocket to wss://localhost:8088/3nstorage/owner/events closed with error