core-3nweb-client-lib 0.41.8 → 0.41.11
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.
- package/build/api-defs/keys.d.ts +1 -1
- package/build/api-defs/mailerid.d.ts +1 -1
- package/build/core/asmail/inbox/inbox-events.d.ts +5 -0
- package/build/core/asmail/inbox/inbox-events.js +12 -2
- package/build/core/storage/synced/remote-events.js +1 -1
- package/build/lib-client/cryptor/cryptor-wasm.js +1 -1
- package/build/lib-client/cryptor/cryptor.wasm +0 -0
- package/build/lib-client/cryptor/worker-js.js +0 -10
- package/build/lib-client/mailer-id/provisioner.js +15 -7
- package/build/lib-client/server-events.d.ts +4 -2
- package/build/lib-client/server-events.js +9 -3
- package/build/lib-client/service-locator.d.ts +7 -15
- package/build/lib-client/service-locator.js +6 -6
- package/build/lib-client/ws-utils.js +2 -2
- package/build/lib-common/buffer-utils.d.ts +1 -1
- package/build/lib-common/ipc/generic-ipc.js +30 -25
- package/build/lib-common/ipc/ws-ipc.d.ts +1 -0
- package/build/lib-common/ipc/ws-ipc.js +9 -17
- package/build/lib-common/objs-on-disk/v1-obj-file-format.d.ts +1 -1
- package/build/lib-common/service-api/3nstorage/root-route.d.ts +5 -0
- package/build/lib-common/service-api/3nstorage/root-route.js +18 -0
- package/build/lib-common/service-api/asmail/root-route.d.ts +5 -0
- package/build/lib-common/service-api/asmail/root-route.js +18 -0
- package/build/lib-common/service-api/mailer-id/root-route.d.ts +7 -0
- package/build/lib-common/service-api/mailer-id/root-route.js +18 -0
- package/build/protos/asmail.proto.js +387 -129
- package/build/protos/bytes.proto.js +54 -18
- package/build/protos/common.proto.js +27 -9
- package/build/protos/cryptor.proto.js +21 -7
- package/build/protos/file.proto.js +144 -48
- package/build/protos/fs.proto.js +321 -107
- package/build/protos/ipc.proto.js +33 -11
- package/build/protos/json-ipc.proto.js +39 -13
- package/build/protos/storage.proto.js +39 -13
- package/package.json +2 -2
|
Binary file
|
|
@@ -19,16 +19,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
19
19
|
const worker_threads_1 = require("worker_threads");
|
|
20
20
|
const ecma_nacl_1 = require("ecma-nacl");
|
|
21
21
|
const error_1 = require("../../lib-common/exceptions/error");
|
|
22
|
-
function transfer(...arrs) {
|
|
23
|
-
const transferLst = [];
|
|
24
|
-
for (const arr of arrs) {
|
|
25
|
-
const buffer = arr.buffer;
|
|
26
|
-
if (!transferLst.includes(buffer)) {
|
|
27
|
-
transferLst.push(buffer);
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
return transferLst;
|
|
31
|
-
}
|
|
32
22
|
if (!worker_threads_1.parentPort) {
|
|
33
23
|
throw new Error(`Missing expected parentPort. Is this called within WebWorker process?`);
|
|
34
24
|
}
|
|
@@ -58,10 +58,10 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
|
|
|
58
58
|
Object.seal(this);
|
|
59
59
|
}
|
|
60
60
|
async setUrlAndDomain() {
|
|
61
|
-
const
|
|
61
|
+
const { currentCert, provisioning } = await (0, service_locator_1.mailerIdInfoAt)(this.net, this.entryURI);
|
|
62
62
|
this.midDomain = (0, url_1.parse)(this.serviceURI).hostname;
|
|
63
|
-
this.serviceURI =
|
|
64
|
-
this.rootCert =
|
|
63
|
+
this.serviceURI = provisioning;
|
|
64
|
+
this.rootCert = currentCert;
|
|
65
65
|
}
|
|
66
66
|
/**
|
|
67
67
|
* @param pkey is a public key, that needs to be certified.
|
|
@@ -73,10 +73,7 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
|
|
|
73
73
|
*/
|
|
74
74
|
async getCertificates(pkey, duration) {
|
|
75
75
|
(0, assert_1.assert)(!!this.encryptor);
|
|
76
|
-
const plainReqData = {
|
|
77
|
-
pkey: pkey,
|
|
78
|
-
duration: duration
|
|
79
|
-
};
|
|
76
|
+
const plainReqData = { pkey, duration };
|
|
80
77
|
const rep = await this.net.doBinaryRequest({
|
|
81
78
|
url: this.serviceURI + api.certify.URL_END,
|
|
82
79
|
method: api.certify.method,
|
|
@@ -95,6 +92,17 @@ class MailerIdProvisioner extends user_with_pkl_session_1.ServiceUser {
|
|
|
95
92
|
if (!certs.userCert || !certs.provCert) {
|
|
96
93
|
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: Certificates are missing.');
|
|
97
94
|
}
|
|
95
|
+
if (certs.provCert.kid !== this.rootCert.kid) {
|
|
96
|
+
const { currentCert, previousCerts } = await (0, service_locator_1.mailerIdInfoAt)(this.net, this.entryURI);
|
|
97
|
+
const rootCert = ((currentCert.kid === certs.provCert.kid) ?
|
|
98
|
+
currentCert : previousCerts.find(cert => (cert.kid === certs.provCert.kid)));
|
|
99
|
+
if (rootCert) {
|
|
100
|
+
this.rootCert = rootCert;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: referenced root MailerId certificate id is unknown.');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
98
106
|
const pkeyAndId = (0, relying_party_1.verifyChainAndGetUserKey)({ user: certs.userCert, prov: certs.provCert, root: this.rootCert }, this.midDomain, (0, jwkeys_1.getKeyCert)(certs.userCert).issuedAt + 1);
|
|
99
107
|
if (pkeyAndId.address !== (0, canonical_address_1.toCanonicalAddress)(this.userId)) {
|
|
100
108
|
throw (0, request_utils_1.makeException)(rep, 'Malformed reply: Certificate is for a wrong address.');
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { SubscribingClient } from '../lib-common/ipc/generic-ipc';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
+
import { LogError } from './logging/log-to-file';
|
|
3
4
|
export declare class ServerEvents<N extends string, T> {
|
|
4
|
-
private subscribeToServer;
|
|
5
|
+
private readonly subscribeToServer;
|
|
5
6
|
private restartWaitSecs;
|
|
7
|
+
private readonly logError;
|
|
6
8
|
private server;
|
|
7
9
|
private openningServer;
|
|
8
|
-
constructor(subscribeToServer: () => Promise<SubscribingClient>, restartWaitSecs: number);
|
|
10
|
+
constructor(subscribeToServer: () => Promise<SubscribingClient>, restartWaitSecs: number, logError: LogError);
|
|
9
11
|
/**
|
|
10
12
|
* This method creates an observable of server's events.
|
|
11
13
|
* @param event is an event on server, to which to subscribe.
|
|
@@ -23,9 +23,10 @@ const sleep_1 = require("../lib-common/processes/sleep");
|
|
|
23
23
|
const operators_1 = require("rxjs/operators");
|
|
24
24
|
const error_1 = require("../lib-common/exceptions/error");
|
|
25
25
|
class ServerEvents {
|
|
26
|
-
constructor(subscribeToServer, restartWaitSecs) {
|
|
26
|
+
constructor(subscribeToServer, restartWaitSecs, logError) {
|
|
27
27
|
this.subscribeToServer = subscribeToServer;
|
|
28
28
|
this.restartWaitSecs = restartWaitSecs;
|
|
29
|
+
this.logError = logError;
|
|
29
30
|
this.server = undefined;
|
|
30
31
|
this.openningServer = new synced_1.SingleProc();
|
|
31
32
|
Object.seal(this);
|
|
@@ -72,13 +73,18 @@ class ServerEvents {
|
|
|
72
73
|
}
|
|
73
74
|
};
|
|
74
75
|
})
|
|
75
|
-
.pipe(
|
|
76
|
+
.pipe(
|
|
77
|
+
// XXX tap to log more details
|
|
78
|
+
(0, operators_1.tap)({
|
|
79
|
+
complete: () => this.logError({}, `ServerEvents.observe stream completes`),
|
|
80
|
+
error: err => this.logError(err, `ServerEvents.observe stream has error`)
|
|
81
|
+
}), (0, operators_1.catchError)(err => {
|
|
76
82
|
if (this.shouldRestartAfterErr(err)) {
|
|
77
83
|
console.error((0, error_1.stringifyErr)(err));
|
|
78
84
|
return this.restartObservation(event);
|
|
79
85
|
}
|
|
80
86
|
else {
|
|
81
|
-
return (0, rxjs_1.throwError)(err);
|
|
87
|
+
return (0, rxjs_1.throwError)(() => err);
|
|
82
88
|
}
|
|
83
89
|
}));
|
|
84
90
|
return event$;
|
|
@@ -1,39 +1,31 @@
|
|
|
1
1
|
import { NetClient } from './request-utils';
|
|
2
2
|
import { promises as dnsPromises } from 'dns';
|
|
3
|
+
import { StorageRootRoute } from '../lib-common/service-api/3nstorage/root-route';
|
|
4
|
+
import { ASMailRootRoute } from '../lib-common/service-api/asmail/root-route';
|
|
3
5
|
type SignedLoad = web3n.keys.SignedLoad;
|
|
4
|
-
export interface ASMailRoutes {
|
|
5
|
-
delivery?: string;
|
|
6
|
-
retrieval?: string;
|
|
7
|
-
config?: string;
|
|
8
|
-
}
|
|
9
6
|
/**
|
|
10
|
-
* This returns a promise, resolvable to
|
|
7
|
+
* This returns a promise, resolvable to ASMailRootRoute object.
|
|
11
8
|
* @param client
|
|
12
9
|
* @param url
|
|
13
10
|
*/
|
|
14
|
-
export declare function asmailInfoAt(client: NetClient, url: string): Promise<
|
|
11
|
+
export declare function asmailInfoAt(client: NetClient, url: string): Promise<ASMailRootRoute>;
|
|
15
12
|
export interface MailerIdServiceInfo {
|
|
16
13
|
provisioning: string;
|
|
17
14
|
currentCert: SignedLoad;
|
|
18
15
|
previousCerts: SignedLoad[];
|
|
19
16
|
}
|
|
20
17
|
/**
|
|
21
|
-
* This returns a promise, resolvable to
|
|
18
|
+
* This returns a promise, resolvable to MailerIdRootRoute object.
|
|
22
19
|
* @param client
|
|
23
20
|
* @param url
|
|
24
21
|
*/
|
|
25
22
|
export declare function mailerIdInfoAt(client: NetClient, url: string): Promise<MailerIdServiceInfo>;
|
|
26
|
-
export interface StorageRoutes {
|
|
27
|
-
owner?: string;
|
|
28
|
-
shared?: string;
|
|
29
|
-
config?: string;
|
|
30
|
-
}
|
|
31
23
|
/**
|
|
32
|
-
* This returns a promise, resolvable to
|
|
24
|
+
* This returns a promise, resolvable to StorageRootRoute object.
|
|
33
25
|
* @param client
|
|
34
26
|
* @param url
|
|
35
27
|
*/
|
|
36
|
-
export declare function storageInfoAt(client: NetClient, url: string): Promise<
|
|
28
|
+
export declare function storageInfoAt(client: NetClient, url: string): Promise<StorageRootRoute>;
|
|
37
29
|
export type ServiceTypeDNSLabel = 'mailerid' | 'asmail' | '3nstorage';
|
|
38
30
|
export type ServiceLocatorMaker = (serviceLabel: ServiceTypeDNSLabel) => ServiceLocator;
|
|
39
31
|
export type ServiceLocator = (address: string) => Promise<string>;
|
|
@@ -59,7 +59,7 @@ function transformPathToCompleteUri(url, path, rep) {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
/**
|
|
62
|
-
* This returns a promise, resolvable to
|
|
62
|
+
* This returns a promise, resolvable to ASMailRootRoute object.
|
|
63
63
|
* @param client
|
|
64
64
|
* @param url
|
|
65
65
|
*/
|
|
@@ -80,7 +80,7 @@ async function asmailInfoAt(client, url) {
|
|
|
80
80
|
return transform;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
* This returns a promise, resolvable to
|
|
83
|
+
* This returns a promise, resolvable to MailerIdRootRoute object.
|
|
84
84
|
* @param client
|
|
85
85
|
* @param url
|
|
86
86
|
*/
|
|
@@ -94,10 +94,10 @@ async function mailerIdInfoAt(client, url) {
|
|
|
94
94
|
else {
|
|
95
95
|
throw (0, request_utils_1.makeException)(rep, 'Malformed reply');
|
|
96
96
|
}
|
|
97
|
-
if ((
|
|
98
|
-
(0, jwkeys_1.isLikeSignedKeyCert)(json["current-cert"])) {
|
|
97
|
+
if ((0, jwkeys_1.isLikeSignedKeyCert)(json["current-cert"])) {
|
|
99
98
|
transform.currentCert = json["current-cert"];
|
|
100
|
-
transform.previousCerts = json["previous-certs"]
|
|
99
|
+
transform.previousCerts = (Array.isArray(json["previous-certs"]) ?
|
|
100
|
+
json["previous-certs"].filter(jwkeys_1.isLikeSignedKeyCert) : []);
|
|
101
101
|
}
|
|
102
102
|
else {
|
|
103
103
|
throw (0, request_utils_1.makeException)(rep, 'Malformed reply');
|
|
@@ -106,7 +106,7 @@ async function mailerIdInfoAt(client, url) {
|
|
|
106
106
|
return transform;
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
|
-
* This returns a promise, resolvable to
|
|
109
|
+
* This returns a promise, resolvable to StorageRootRoute object.
|
|
110
110
|
* @param client
|
|
111
111
|
* @param url
|
|
112
112
|
*/
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/*
|
|
3
|
-
Copyright (C) 2017, 2019 3NSoft Inc.
|
|
3
|
+
Copyright (C) 2017, 2019, 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
|
|
@@ -29,7 +29,7 @@ function openSocket(url, sessionId) {
|
|
|
29
29
|
headers[request_utils_1.SESSION_ID_HEADER] = sessionId;
|
|
30
30
|
const ws = new WebSocket(url, { headers, agent: https_1.globalAgent });
|
|
31
31
|
const opening = (0, deferred_1.defer)();
|
|
32
|
-
const initOnError = err => opening.reject((0, http_1.makeConnectionException)(url, undefined, `Cannot open websocket connection due to error: ${err.message}`));
|
|
32
|
+
const initOnError = (err) => opening.reject((0, http_1.makeConnectionException)(url, undefined, `Cannot open websocket connection due to error: ${err.message}`));
|
|
33
33
|
const onNonOkReply = (req, res) => {
|
|
34
34
|
const errReply = {
|
|
35
35
|
url,
|
|
@@ -13,15 +13,20 @@
|
|
|
13
13
|
See the GNU General Public License for more details.
|
|
14
14
|
|
|
15
15
|
You should have received a copy of the GNU General Public License along with
|
|
16
|
-
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
16
|
+
this program. If not, see <http://www.gnu.org/licenses/>.
|
|
17
|
+
*/
|
|
17
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
19
|
exports.SingleObserverWrap = exports.MultiObserverWrap = void 0;
|
|
19
20
|
exports.makeRequestingClient = makeRequestingClient;
|
|
20
21
|
exports.makeRequestServer = makeRequestServer;
|
|
21
22
|
exports.makeEventfulServer = makeEventfulServer;
|
|
22
23
|
exports.makeSubscribingClient = makeSubscribingClient;
|
|
24
|
+
const runtime_1 = require("../exceptions/runtime");
|
|
23
25
|
const map_of_sets_1 = require("../map-of-sets");
|
|
24
26
|
const synced_1 = require("../processes/synced");
|
|
27
|
+
function makeEventException(params) {
|
|
28
|
+
return (0, runtime_1.makeRuntimeException)('events', params, {});
|
|
29
|
+
}
|
|
25
30
|
function toTransferrableError(e) {
|
|
26
31
|
if (e.runtimeException) {
|
|
27
32
|
return e;
|
|
@@ -142,7 +147,14 @@ class RequestingSide extends MessageHandler {
|
|
|
142
147
|
}
|
|
143
148
|
this.replyDeferreds.clear();
|
|
144
149
|
}
|
|
145
|
-
makeRequest(name, req, notifyCallback) {
|
|
150
|
+
async makeRequest(name, req, notifyCallback) {
|
|
151
|
+
if (!this.rawDuplex) {
|
|
152
|
+
throw makeEventException({
|
|
153
|
+
channel: this.channel,
|
|
154
|
+
duplexDisconnected: true,
|
|
155
|
+
request: name
|
|
156
|
+
});
|
|
157
|
+
}
|
|
146
158
|
this.counter += 1;
|
|
147
159
|
if (this.counter === Number.MAX_SAFE_INTEGER) {
|
|
148
160
|
this.counter = Number.MIN_SAFE_INTEGER;
|
|
@@ -225,26 +237,21 @@ class ReplyingSide extends MessageHandler {
|
|
|
225
237
|
}
|
|
226
238
|
}
|
|
227
239
|
errorReply(env, err) {
|
|
228
|
-
|
|
240
|
+
return {
|
|
229
241
|
type: 'reply',
|
|
230
242
|
reqName: env.name,
|
|
231
243
|
reqCount: env.count,
|
|
232
|
-
rep: null
|
|
244
|
+
rep: null,
|
|
245
|
+
err: (err.runtimeException ?
|
|
246
|
+
err : toTransferrableError(err))
|
|
233
247
|
};
|
|
234
|
-
if (err.runtimeException) {
|
|
235
|
-
reply.err = err;
|
|
236
|
-
}
|
|
237
|
-
else {
|
|
238
|
-
reply.err = toTransferrableError(err);
|
|
239
|
-
}
|
|
240
|
-
return reply;
|
|
241
248
|
}
|
|
242
249
|
normalReply(env, rep, isInProgress = false) {
|
|
243
250
|
const reply = {
|
|
244
251
|
type: 'reply',
|
|
245
252
|
reqName: env.name,
|
|
246
253
|
reqCount: env.count,
|
|
247
|
-
rep
|
|
254
|
+
rep,
|
|
248
255
|
};
|
|
249
256
|
if (isInProgress) {
|
|
250
257
|
reply.isInProgress = true;
|
|
@@ -283,14 +290,6 @@ Object.freeze(ReplyingSide);
|
|
|
283
290
|
function makeRequestServer(channel, comm) {
|
|
284
291
|
return (new ReplyingSide(channel, comm)).wrap();
|
|
285
292
|
}
|
|
286
|
-
function makeUnknownEventException(message) {
|
|
287
|
-
return {
|
|
288
|
-
runtimeException: true,
|
|
289
|
-
type: 'events',
|
|
290
|
-
unknownEvent: true,
|
|
291
|
-
message
|
|
292
|
-
};
|
|
293
|
-
}
|
|
294
293
|
const SUBSCRIBE_REQ_NAME = 'subscribe';
|
|
295
294
|
const UNSUBSCRIBE_REQ_NAME = 'unsubscribe';
|
|
296
295
|
class EventsSendingSide extends ReplyingSide {
|
|
@@ -313,7 +312,11 @@ class EventsSendingSide extends ReplyingSide {
|
|
|
313
312
|
const event = env.req;
|
|
314
313
|
const gr = this.findGroup(event);
|
|
315
314
|
if (!gr) {
|
|
316
|
-
throw
|
|
315
|
+
throw makeEventException({
|
|
316
|
+
channel: this.channel,
|
|
317
|
+
unknownEvent: true,
|
|
318
|
+
message: `Events' channel ${event} is not found in handling subscribe`
|
|
319
|
+
});
|
|
317
320
|
}
|
|
318
321
|
this.subscribedEvents.add(event);
|
|
319
322
|
await gr.subscribe(event);
|
|
@@ -322,7 +325,11 @@ class EventsSendingSide extends ReplyingSide {
|
|
|
322
325
|
const event = env.req;
|
|
323
326
|
const gr = this.findGroup(event);
|
|
324
327
|
if (!gr) {
|
|
325
|
-
throw
|
|
328
|
+
throw makeEventException({
|
|
329
|
+
channel: this.channel,
|
|
330
|
+
unknownEvent: true,
|
|
331
|
+
message: `Events' channel ${event} is not found in handling unsubscribe`
|
|
332
|
+
});
|
|
326
333
|
}
|
|
327
334
|
this.subscribedEvents.delete(event);
|
|
328
335
|
if (gr.unsubscribe) {
|
|
@@ -442,9 +449,7 @@ class EventsReceivingSide extends RequestingSide {
|
|
|
442
449
|
* name, to which listener is attached.
|
|
443
450
|
*/
|
|
444
451
|
this.listeners = new map_of_sets_1.MapOfSets();
|
|
445
|
-
this.channels = new IpcEventChannels((ipcChannel) => this.makeRequest(
|
|
446
|
-
.catch(err => this.completeEvent(ipcChannel, err)), (ipcChannel) => this.makeRequest(UNSUBSCRIBE_REQ_NAME, ipcChannel)
|
|
447
|
-
.catch(_ => { }));
|
|
452
|
+
this.channels = new IpcEventChannels(ipcChannel => this.makeRequest(SUBSCRIBE_REQ_NAME, ipcChannel).catch(err => this.completeEvent(ipcChannel, err)), ipcChannel => this.makeRequest(UNSUBSCRIBE_REQ_NAME, ipcChannel).catch(_ => { }));
|
|
448
453
|
}
|
|
449
454
|
handleMsg(env) {
|
|
450
455
|
if (env.type === 'event') {
|
|
@@ -6,4 +6,5 @@ export interface WSException extends web3n.RuntimeException {
|
|
|
6
6
|
socketSlow?: true;
|
|
7
7
|
socketClosed?: true;
|
|
8
8
|
}
|
|
9
|
+
export declare function makeWSException(params: Partial<WSException>, flags?: Partial<WSException>): WSException;
|
|
9
10
|
export declare function makeSubscriber(ws: WebSocket, ipcChannel: string | undefined): SubscribingClient;
|
|
@@ -16,10 +16,15 @@
|
|
|
16
16
|
this program. If not, see <http://www.gnu.org/licenses/>. */
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.makeEventfulServer = void 0;
|
|
19
|
+
exports.makeWSException = makeWSException;
|
|
19
20
|
exports.makeSubscriber = makeSubscriber;
|
|
21
|
+
const runtime_1 = require("../exceptions/runtime");
|
|
20
22
|
const generic_ipc_1 = require("./generic-ipc");
|
|
21
23
|
var generic_ipc_2 = require("./generic-ipc");
|
|
22
24
|
Object.defineProperty(exports, "makeEventfulServer", { enumerable: true, get: function () { return generic_ipc_2.makeEventfulServer; } });
|
|
25
|
+
function makeWSException(params, flags) {
|
|
26
|
+
return (0, runtime_1.makeRuntimeException)('websocket', params, flags !== null && flags !== void 0 ? flags : {});
|
|
27
|
+
}
|
|
23
28
|
const MAX_TXT_BUFFER = 64 * 1024;
|
|
24
29
|
/**
|
|
25
30
|
* This creates a json communication point on a given web socket.
|
|
@@ -37,12 +42,7 @@ function makeJsonCommPoint(ws) {
|
|
|
37
42
|
subscribe: obs => observers.add(obs),
|
|
38
43
|
postMessage(env) {
|
|
39
44
|
if (ws.bufferedAmount > MAX_TXT_BUFFER) {
|
|
40
|
-
|
|
41
|
-
runtimeException: true,
|
|
42
|
-
type: 'websocket',
|
|
43
|
-
socketSlow: true
|
|
44
|
-
};
|
|
45
|
-
throw exc;
|
|
45
|
+
throw makeWSException({ socketSlow: true });
|
|
46
46
|
}
|
|
47
47
|
ws.send(JSON.stringify(env));
|
|
48
48
|
}
|
|
@@ -84,13 +84,10 @@ function onClose(observers) {
|
|
|
84
84
|
observers.complete();
|
|
85
85
|
}
|
|
86
86
|
else {
|
|
87
|
-
|
|
88
|
-
runtimeException: true,
|
|
89
|
-
type: 'websocket',
|
|
87
|
+
observers.error(makeWSException({
|
|
90
88
|
socketClosed: true,
|
|
91
89
|
cause: { code, reason }
|
|
92
|
-
};
|
|
93
|
-
observers.error(exc);
|
|
90
|
+
}));
|
|
94
91
|
}
|
|
95
92
|
};
|
|
96
93
|
}
|
|
@@ -101,12 +98,7 @@ function onClose(observers) {
|
|
|
101
98
|
*/
|
|
102
99
|
function onError(ws, observers) {
|
|
103
100
|
return (err) => {
|
|
104
|
-
|
|
105
|
-
runtimeException: true,
|
|
106
|
-
type: 'websocket',
|
|
107
|
-
cause: err
|
|
108
|
-
};
|
|
109
|
-
observers.error(exc);
|
|
101
|
+
observers.error(makeWSException({ cause: err }));
|
|
110
102
|
ws.close();
|
|
111
103
|
};
|
|
112
104
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2025 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 });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2025 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 });
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/*
|
|
3
|
+
Copyright (C) 2025 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 });
|