@theia/core 1.44.0 → 1.45.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.
- package/README.md +6 -6
- package/i18n/nls.cs.json +10 -3
- package/i18n/nls.de.json +10 -3
- package/i18n/nls.es.json +10 -3
- package/i18n/nls.fr.json +10 -3
- package/i18n/nls.hu.json +10 -3
- package/i18n/nls.it.json +10 -3
- package/i18n/nls.ja.json +10 -3
- package/i18n/nls.json +10 -3
- package/i18n/nls.pl.json +10 -3
- package/i18n/nls.pt-br.json +10 -3
- package/i18n/nls.pt-pt.json +10 -3
- package/i18n/nls.ru.json +10 -3
- package/i18n/nls.zh-cn.json +10 -3
- package/lib/browser/common-frontend-contribution.d.ts +6 -0
- package/lib/browser/common-frontend-contribution.d.ts.map +1 -1
- package/lib/browser/common-frontend-contribution.js +52 -9
- package/lib/browser/common-frontend-contribution.js.map +1 -1
- package/lib/browser/connection-status-service.d.ts +2 -2
- package/lib/browser/connection-status-service.d.ts.map +1 -1
- package/lib/browser/connection-status-service.js +3 -3
- package/lib/browser/connection-status-service.js.map +1 -1
- package/lib/browser/connection-status-service.spec.js +6 -6
- package/lib/browser/connection-status-service.spec.js.map +1 -1
- package/lib/browser/core-preferences.d.ts.map +1 -1
- package/lib/browser/core-preferences.js +16 -0
- package/lib/browser/core-preferences.js.map +1 -1
- package/lib/browser/dialogs.d.ts +0 -1
- package/lib/browser/dialogs.d.ts.map +1 -1
- package/lib/browser/dialogs.js +1 -34
- package/lib/browser/dialogs.js.map +1 -1
- package/lib/browser/frontend-application-module.d.ts.map +1 -1
- package/lib/browser/frontend-application-module.js +1 -0
- package/lib/browser/frontend-application-module.js.map +1 -1
- package/lib/browser/messaging/connection-source.d.ts +9 -0
- package/lib/browser/messaging/connection-source.d.ts.map +1 -0
- package/lib/browser/messaging/connection-source.js +20 -0
- package/lib/browser/messaging/connection-source.js.map +1 -0
- package/lib/browser/messaging/frontend-id-provider.d.ts +13 -0
- package/lib/browser/messaging/frontend-id-provider.d.ts.map +1 -0
- package/lib/browser/messaging/frontend-id-provider.js +40 -0
- package/lib/browser/messaging/frontend-id-provider.js.map +1 -0
- package/lib/browser/messaging/messaging-frontend-module.d.ts.map +1 -1
- package/lib/browser/messaging/messaging-frontend-module.js +18 -1
- package/lib/browser/messaging/messaging-frontend-module.js.map +1 -1
- package/lib/browser/messaging/service-connection-provider.d.ts +48 -0
- package/lib/browser/messaging/service-connection-provider.d.ts.map +1 -0
- package/lib/browser/messaging/service-connection-provider.js +115 -0
- package/lib/browser/messaging/service-connection-provider.js.map +1 -0
- package/lib/browser/messaging/ws-connection-provider.d.ts +7 -38
- package/lib/browser/messaging/ws-connection-provider.d.ts.map +1 -1
- package/lib/browser/messaging/ws-connection-provider.js +17 -121
- package/lib/browser/messaging/ws-connection-provider.js.map +1 -1
- package/lib/browser/messaging/ws-connection-source.d.ts +41 -0
- package/lib/browser/messaging/ws-connection-source.d.ts.map +1 -0
- package/lib/browser/messaging/ws-connection-source.js +210 -0
- package/lib/browser/messaging/ws-connection-source.js.map +1 -0
- package/lib/browser/preload/i18n-preload-contribution.js +1 -1
- package/lib/browser/preload/i18n-preload-contribution.js.map +1 -1
- package/lib/browser/shell/application-shell.js +1 -1
- package/lib/browser/shell/application-shell.js.map +1 -1
- package/lib/browser/tree/tree-compression/compressed-tree-widget.d.ts +1 -0
- package/lib/browser/tree/tree-compression/compressed-tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-compression/compressed-tree-widget.js +5 -0
- package/lib/browser/tree/tree-compression/compressed-tree-widget.js.map +1 -1
- package/lib/browser/tree/tree-widget.d.ts +6 -0
- package/lib/browser/tree/tree-widget.d.ts.map +1 -1
- package/lib/browser/tree/tree-widget.js +21 -11
- package/lib/browser/tree/tree-widget.js.map +1 -1
- package/lib/browser/user-working-directory-provider.d.ts +8 -1
- package/lib/browser/user-working-directory-provider.d.ts.map +1 -1
- package/lib/browser/user-working-directory-provider.js +22 -1
- package/lib/browser/user-working-directory-provider.js.map +1 -1
- package/lib/browser/window/default-secondary-window-service.d.ts +3 -0
- package/lib/browser/window/default-secondary-window-service.d.ts.map +1 -1
- package/lib/browser/window/default-secondary-window-service.js +55 -1
- package/lib/browser/window/default-secondary-window-service.js.map +1 -1
- package/lib/common/message-rpc/channel.d.ts.map +1 -1
- package/lib/common/message-rpc/channel.js +7 -1
- package/lib/common/message-rpc/channel.js.map +1 -1
- package/lib/common/message-rpc/message-buffer.d.ts +2 -0
- package/lib/common/message-rpc/message-buffer.d.ts.map +1 -1
- package/lib/common/message-rpc/message-buffer.js +4 -0
- package/lib/common/message-rpc/message-buffer.js.map +1 -1
- package/lib/common/message-rpc/uint8-array-message-buffer.d.ts +1 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.d.ts.map +1 -1
- package/lib/common/message-rpc/uint8-array-message-buffer.js +6 -0
- package/lib/common/message-rpc/uint8-array-message-buffer.js.map +1 -1
- package/lib/common/messaging/connection-management.d.ts +25 -0
- package/lib/common/messaging/connection-management.d.ts.map +1 -0
- package/lib/common/messaging/connection-management.js +38 -0
- package/lib/common/messaging/connection-management.js.map +1 -0
- package/lib/common/messaging/handler.d.ts +1 -0
- package/lib/common/messaging/handler.d.ts.map +1 -1
- package/lib/common/messaging/handler.js +2 -1
- package/lib/common/messaging/handler.js.map +1 -1
- package/lib/common/messaging/socket-write-buffer.d.ts +11 -0
- package/lib/common/messaging/socket-write-buffer.d.ts.map +1 -0
- package/lib/common/messaging/socket-write-buffer.js +50 -0
- package/lib/common/messaging/socket-write-buffer.js.map +1 -0
- package/lib/common/messaging/web-socket-channel.d.ts +7 -35
- package/lib/common/messaging/web-socket-channel.d.ts.map +1 -1
- package/lib/common/messaging/web-socket-channel.js +20 -9
- package/lib/common/messaging/web-socket-channel.js.map +1 -1
- package/lib/electron-browser/messaging/electron-frontend-id-provider.d.ts +5 -0
- package/lib/electron-browser/messaging/electron-frontend-id-provider.d.ts.map +1 -0
- package/lib/{electron-node/token/electron-token-messaging-contribution.js → electron-browser/messaging/electron-frontend-id-provider.js} +9 -28
- package/lib/electron-browser/messaging/electron-frontend-id-provider.js.map +1 -0
- package/lib/electron-browser/messaging/electron-ipc-connection-source.d.ts +24 -0
- package/lib/electron-browser/messaging/electron-ipc-connection-source.d.ts.map +1 -0
- package/lib/electron-browser/messaging/{electron-ipc-connection-provider.js → electron-ipc-connection-source.js} +19 -19
- package/lib/electron-browser/messaging/electron-ipc-connection-source.js.map +1 -0
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts +7 -0
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.d.ts.map +1 -0
- package/lib/electron-browser/messaging/{electron-local-ws-connection-provider.js → electron-local-ws-connection-source.js} +7 -7
- package/lib/electron-browser/messaging/electron-local-ws-connection-source.js.map +1 -0
- package/lib/electron-browser/messaging/electron-messaging-frontend-module.d.ts.map +1 -1
- package/lib/electron-browser/messaging/electron-messaging-frontend-module.js +45 -13
- package/lib/electron-browser/messaging/electron-messaging-frontend-module.js.map +1 -1
- package/lib/electron-browser/messaging/electron-ws-connection-source.d.ts +12 -0
- package/lib/electron-browser/messaging/electron-ws-connection-source.d.ts.map +1 -0
- package/lib/electron-browser/messaging/{electron-ws-connection-provider.js → electron-ws-connection-source.js} +14 -21
- package/lib/electron-browser/messaging/electron-ws-connection-source.js.map +1 -0
- package/lib/electron-browser/preload.d.ts.map +1 -1
- package/lib/electron-browser/preload.js +10 -0
- package/lib/electron-browser/preload.js.map +1 -1
- package/lib/electron-browser/window/electron-window-module.js +2 -2
- package/lib/electron-browser/window/electron-window-module.js.map +1 -1
- package/lib/electron-browser/window/electron-window-service.d.ts +4 -0
- package/lib/electron-browser/window/electron-window-service.d.ts.map +1 -1
- package/lib/electron-browser/window/electron-window-service.js +13 -0
- package/lib/electron-browser/window/electron-window-service.js.map +1 -1
- package/lib/electron-common/electron-api.d.ts +6 -0
- package/lib/electron-common/electron-api.d.ts.map +1 -1
- package/lib/electron-common/electron-api.js +3 -1
- package/lib/electron-common/electron-api.js.map +1 -1
- package/lib/electron-main/electron-api-main.d.ts +1 -0
- package/lib/electron-main/electron-api-main.d.ts.map +1 -1
- package/lib/electron-main/electron-api-main.js +15 -0
- package/lib/electron-main/electron-api-main.js.map +1 -1
- package/lib/electron-main/electron-main-application-module.js +5 -5
- package/lib/electron-main/electron-main-application-module.js.map +1 -1
- package/lib/electron-main/electron-main-application.d.ts +7 -13
- package/lib/electron-main/electron-main-application.d.ts.map +1 -1
- package/lib/electron-main/electron-main-application.js +36 -26
- package/lib/electron-main/electron-main-application.js.map +1 -1
- package/lib/electron-main/messaging/electron-connection-handler.d.ts.map +1 -0
- package/lib/electron-main/messaging/electron-connection-handler.js.map +1 -0
- package/lib/electron-main/messaging/electron-messaging-contribution.d.ts +13 -22
- package/lib/electron-main/messaging/electron-messaging-contribution.d.ts.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-contribution.js +39 -39
- package/lib/electron-main/messaging/electron-messaging-contribution.js.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-service.d.ts.map +1 -1
- package/lib/electron-main/messaging/electron-messaging-service.js.map +1 -1
- package/lib/electron-main/theia-electron-window.d.ts +2 -2
- package/lib/electron-main/theia-electron-window.d.ts.map +1 -1
- package/lib/electron-main/theia-electron-window.js +3 -2
- package/lib/electron-main/theia-electron-window.js.map +1 -1
- package/lib/node/messaging/default-messaging-service.d.ts +29 -0
- package/lib/node/messaging/default-messaging-service.d.ts.map +1 -0
- package/lib/node/messaging/default-messaging-service.js +140 -0
- package/lib/node/messaging/default-messaging-service.js.map +1 -0
- package/lib/node/messaging/frontend-connection-service.d.ts +7 -0
- package/lib/node/messaging/frontend-connection-service.d.ts.map +1 -0
- package/lib/node/messaging/frontend-connection-service.js +19 -0
- package/lib/node/messaging/frontend-connection-service.js.map +1 -0
- package/lib/node/messaging/messaging-backend-module.d.ts.map +1 -1
- package/lib/node/messaging/messaging-backend-module.js +23 -9
- package/lib/node/messaging/messaging-backend-module.js.map +1 -1
- package/lib/node/messaging/messaging-service.d.ts +2 -3
- package/lib/node/messaging/messaging-service.d.ts.map +1 -1
- package/lib/node/messaging/test/test-web-socket-channel.d.ts +3 -3
- package/lib/node/messaging/test/test-web-socket-channel.d.ts.map +1 -1
- package/lib/node/messaging/test/test-web-socket-channel.js +38 -24
- package/lib/node/messaging/test/test-web-socket-channel.js.map +1 -1
- package/lib/node/messaging/websocket-endpoint.d.ts +21 -0
- package/lib/node/messaging/websocket-endpoint.d.ts.map +1 -0
- package/lib/node/messaging/websocket-endpoint.js +89 -0
- package/lib/node/messaging/websocket-endpoint.js.map +1 -0
- package/lib/node/messaging/websocket-frontend-connection-service.d.ts +30 -0
- package/lib/node/messaging/websocket-frontend-connection-service.d.ts.map +1 -0
- package/lib/node/messaging/websocket-frontend-connection-service.js +173 -0
- package/lib/node/messaging/websocket-frontend-connection-service.js.map +1 -0
- package/package.json +6 -6
- package/src/browser/common-frontend-contribution.ts +55 -9
- package/src/browser/connection-status-service.spec.ts +6 -6
- package/src/browser/connection-status-service.ts +2 -2
- package/src/browser/core-preferences.ts +16 -0
- package/src/browser/dialogs.ts +0 -34
- package/src/browser/frontend-application-module.ts +1 -0
- package/src/browser/messaging/connection-source.ts +26 -0
- package/src/browser/messaging/frontend-id-provider.ts +37 -0
- package/src/browser/messaging/messaging-frontend-module.ts +20 -2
- package/src/browser/messaging/service-connection-provider.ts +126 -0
- package/src/browser/messaging/ws-connection-provider.ts +16 -141
- package/src/browser/messaging/ws-connection-source.ts +210 -0
- package/src/browser/preload/i18n-preload-contribution.ts +1 -1
- package/src/browser/shell/application-shell.ts +1 -1
- package/src/browser/tree/tree-compression/compressed-tree-widget.tsx +27 -7
- package/src/browser/tree/tree-widget.tsx +21 -10
- package/src/browser/user-working-directory-provider.ts +32 -3
- package/src/browser/window/default-secondary-window-service.ts +54 -1
- package/src/common/i18n/nls.metadata.json +7208 -6923
- package/src/common/message-rpc/channel.ts +5 -1
- package/src/common/message-rpc/message-buffer.ts +6 -0
- package/src/common/message-rpc/uint8-array-message-buffer.ts +7 -0
- package/src/common/messaging/connection-management.ts +43 -0
- package/src/common/messaging/handler.ts +2 -0
- package/src/common/messaging/socket-write-buffer.ts +52 -0
- package/src/common/messaging/web-socket-channel.ts +28 -45
- package/src/electron-browser/messaging/electron-frontend-id-provider.ts +25 -0
- package/src/electron-browser/messaging/{electron-ipc-connection-provider.ts → electron-ipc-connection-source.ts} +17 -13
- package/src/electron-browser/messaging/{electron-local-ws-connection-provider.ts → electron-local-ws-connection-source.ts} +2 -2
- package/src/electron-browser/messaging/electron-messaging-frontend-module.ts +49 -12
- package/src/electron-browser/messaging/{electron-ws-connection-provider.ts → electron-ws-connection-source.ts} +6 -17
- package/src/electron-browser/preload.ts +15 -1
- package/src/electron-browser/window/electron-window-module.ts +1 -1
- package/src/electron-browser/window/electron-window-service.ts +11 -0
- package/src/electron-common/electron-api.ts +7 -0
- package/src/electron-main/electron-api-main.ts +20 -1
- package/src/electron-main/electron-main-application-module.ts +5 -5
- package/src/electron-main/electron-main-application.ts +46 -41
- package/src/electron-main/messaging/electron-messaging-contribution.ts +45 -43
- package/src/electron-main/messaging/electron-messaging-service.ts +1 -0
- package/src/electron-main/theia-electron-window.ts +4 -3
- package/src/node/messaging/default-messaging-service.ts +129 -0
- package/src/node/messaging/frontend-connection-service.ts +24 -0
- package/src/node/messaging/messaging-backend-module.ts +25 -10
- package/src/node/messaging/messaging-service.ts +3 -3
- package/src/node/messaging/test/test-web-socket-channel.ts +32 -27
- package/src/node/messaging/websocket-endpoint.ts +79 -0
- package/src/node/messaging/websocket-frontend-connection-service.ts +171 -0
- package/lib/common/messaging/abstract-connection-provider.d.ts +0 -45
- package/lib/common/messaging/abstract-connection-provider.d.ts.map +0 -1
- package/lib/common/messaging/abstract-connection-provider.js +0 -93
- package/lib/common/messaging/abstract-connection-provider.js.map +0 -1
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts +0 -19
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.d.ts.map +0 -1
- package/lib/electron-browser/messaging/electron-ipc-connection-provider.js.map +0 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-provider.d.ts +0 -7
- package/lib/electron-browser/messaging/electron-local-ws-connection-provider.d.ts.map +0 -1
- package/lib/electron-browser/messaging/electron-local-ws-connection-provider.js.map +0 -1
- package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts +0 -17
- package/lib/electron-browser/messaging/electron-ws-connection-provider.d.ts.map +0 -1
- package/lib/electron-browser/messaging/electron-ws-connection-provider.js.map +0 -1
- package/lib/electron-common/messaging/electron-connection-handler.d.ts.map +0 -1
- package/lib/electron-common/messaging/electron-connection-handler.js.map +0 -1
- package/lib/electron-node/token/electron-token-messaging-contribution.d.ts +0 -16
- package/lib/electron-node/token/electron-token-messaging-contribution.d.ts.map +0 -1
- package/lib/electron-node/token/electron-token-messaging-contribution.js.map +0 -1
- package/lib/node/messaging/messaging-contribution.d.ts +0 -44
- package/lib/node/messaging/messaging-contribution.d.ts.map +0 -1
- package/lib/node/messaging/messaging-contribution.js +0 -210
- package/lib/node/messaging/messaging-contribution.js.map +0 -1
- package/src/common/messaging/abstract-connection-provider.ts +0 -115
- package/src/electron-node/token/electron-token-messaging-contribution.ts +0 -41
- package/src/node/messaging/messaging-contribution.ts +0 -197
- /package/lib/{electron-common → electron-main}/messaging/electron-connection-handler.d.ts +0 -0
- /package/lib/{electron-common → electron-main}/messaging/electron-connection-handler.js +0 -0
- /package/src/{electron-common → electron-main}/messaging/electron-connection-handler.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messaging-contribution.d.ts","sourceRoot":"","sources":["../../../src/node/messaging/messaging-contribution.ts"],"names":[],"mappings":";AAgBA,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AAC7B,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,EAAU,MAAM,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAA4C,UAAU,E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************************************************************************
|
|
3
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
4
|
-
//
|
|
5
|
-
// This program and the accompanying materials are made available under the
|
|
6
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
7
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
8
|
-
//
|
|
9
|
-
// This Source Code may also be made available under the following Secondary
|
|
10
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
11
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
12
|
-
// with the GNU Classpath Exception which is available at
|
|
13
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
14
|
-
//
|
|
15
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
16
|
-
// *****************************************************************************
|
|
17
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
20
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
21
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
22
|
-
};
|
|
23
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
|
-
};
|
|
26
|
-
var MessagingContribution_1;
|
|
27
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.MessagingContribution = exports.MessagingContainer = void 0;
|
|
29
|
-
const socket_io_1 = require("socket.io");
|
|
30
|
-
const inversify_1 = require("inversify");
|
|
31
|
-
const common_1 = require("../../common");
|
|
32
|
-
const web_socket_channel_1 = require("../../common/messaging/web-socket-channel");
|
|
33
|
-
const messaging_service_1 = require("./messaging-service");
|
|
34
|
-
const connection_container_module_1 = require("./connection-container-module");
|
|
35
|
-
const Route = require("route-parser");
|
|
36
|
-
const ws_request_validators_1 = require("../ws-request-validators");
|
|
37
|
-
const messaging_listeners_1 = require("./messaging-listeners");
|
|
38
|
-
const channel_1 = require("../../common/message-rpc/channel");
|
|
39
|
-
exports.MessagingContainer = Symbol('MessagingContainer');
|
|
40
|
-
let MessagingContribution = MessagingContribution_1 = class MessagingContribution {
|
|
41
|
-
constructor() {
|
|
42
|
-
this.wsHandlers = new MessagingContribution_1.ConnectionHandlers();
|
|
43
|
-
this.channelHandlers = new MessagingContribution_1.ConnectionHandlers();
|
|
44
|
-
this.checkAliveTimeout = 30000; // 30 seconds
|
|
45
|
-
this.maxHttpBufferSize = 1e8; // 100 MB
|
|
46
|
-
}
|
|
47
|
-
init() {
|
|
48
|
-
this.ws(web_socket_channel_1.WebSocketChannel.wsPath, (_, socket) => this.handleChannels(socket));
|
|
49
|
-
for (const contribution of this.contributions.getContributions()) {
|
|
50
|
-
contribution.configure(this);
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
wsChannel(spec, callback) {
|
|
54
|
-
this.channelHandlers.push(spec, (params, channel) => callback(params, channel));
|
|
55
|
-
}
|
|
56
|
-
ws(spec, callback) {
|
|
57
|
-
this.wsHandlers.push(spec, callback);
|
|
58
|
-
}
|
|
59
|
-
onStart(server) {
|
|
60
|
-
const socketServer = new socket_io_1.Server(server, {
|
|
61
|
-
pingInterval: this.checkAliveTimeout,
|
|
62
|
-
pingTimeout: this.checkAliveTimeout * 2,
|
|
63
|
-
maxHttpBufferSize: this.maxHttpBufferSize
|
|
64
|
-
});
|
|
65
|
-
// Accept every namespace by using /.*/
|
|
66
|
-
socketServer.of(/.*/).on('connection', async (socket) => {
|
|
67
|
-
const request = socket.request;
|
|
68
|
-
// Socket.io strips the `origin` header of the incoming request
|
|
69
|
-
// We provide a `fix-origin` header in the `WebSocketConnectionProvider`
|
|
70
|
-
request.headers.origin = request.headers['fix-origin'];
|
|
71
|
-
if (await this.allowConnect(socket.request)) {
|
|
72
|
-
await this.handleConnection(socket);
|
|
73
|
-
this.messagingListener.onDidWebSocketUpgrade(socket.request, socket);
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
socket.disconnect(true);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}
|
|
80
|
-
async handleConnection(socket) {
|
|
81
|
-
const pathname = socket.nsp.name;
|
|
82
|
-
if (pathname && !this.wsHandlers.route(pathname, socket)) {
|
|
83
|
-
console.error('Cannot find a ws handler for the path: ' + pathname);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
async allowConnect(request) {
|
|
87
|
-
try {
|
|
88
|
-
return this.wsRequestValidator.allowWsUpgrade(request);
|
|
89
|
-
}
|
|
90
|
-
catch (e) {
|
|
91
|
-
return false;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
handleChannels(socket) {
|
|
95
|
-
const socketChannel = new web_socket_channel_1.WebSocketChannel(this.toIWebSocket(socket));
|
|
96
|
-
const multiplexer = new channel_1.ChannelMultiplexer(socketChannel);
|
|
97
|
-
const channelHandlers = this.getConnectionChannelHandlers(socket);
|
|
98
|
-
multiplexer.onDidOpenChannel(event => {
|
|
99
|
-
if (channelHandlers.route(event.id, event.channel)) {
|
|
100
|
-
console.debug(`Opening channel for service path '${event.id}'.`);
|
|
101
|
-
event.channel.onClose(() => console.debug(`Closing channel on service path '${event.id}'.`));
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
toIWebSocket(socket) {
|
|
106
|
-
return {
|
|
107
|
-
close: () => {
|
|
108
|
-
socket.removeAllListeners('disconnect');
|
|
109
|
-
socket.removeAllListeners('error');
|
|
110
|
-
socket.removeAllListeners('message');
|
|
111
|
-
socket.disconnect();
|
|
112
|
-
},
|
|
113
|
-
isConnected: () => socket.connected,
|
|
114
|
-
onClose: cb => socket.on('disconnect', reason => cb(reason)),
|
|
115
|
-
onError: cb => socket.on('error', error => cb(error)),
|
|
116
|
-
onMessage: cb => socket.on('message', data => cb(data)),
|
|
117
|
-
send: message => socket.emit('message', message)
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
createSocketContainer(socket) {
|
|
121
|
-
const connectionContainer = this.container.createChild();
|
|
122
|
-
connectionContainer.bind(socket_io_1.Socket).toConstantValue(socket);
|
|
123
|
-
return connectionContainer;
|
|
124
|
-
}
|
|
125
|
-
getConnectionChannelHandlers(socket) {
|
|
126
|
-
const connectionContainer = this.createSocketContainer(socket);
|
|
127
|
-
(0, common_1.bindContributionProvider)(connectionContainer, common_1.ConnectionHandler);
|
|
128
|
-
connectionContainer.load(...this.connectionModules.getContributions());
|
|
129
|
-
const connectionChannelHandlers = new MessagingContribution_1.ConnectionHandlers(this.channelHandlers);
|
|
130
|
-
const connectionHandlers = connectionContainer.getNamed(common_1.ContributionProvider, common_1.ConnectionHandler);
|
|
131
|
-
for (const connectionHandler of connectionHandlers.getContributions(true)) {
|
|
132
|
-
connectionChannelHandlers.push(connectionHandler.path, (_, channel) => {
|
|
133
|
-
connectionHandler.onConnection(channel);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
return connectionChannelHandlers;
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
__decorate([
|
|
140
|
-
(0, inversify_1.inject)(exports.MessagingContainer),
|
|
141
|
-
__metadata("design:type", Object)
|
|
142
|
-
], MessagingContribution.prototype, "container", void 0);
|
|
143
|
-
__decorate([
|
|
144
|
-
(0, inversify_1.inject)(common_1.ContributionProvider),
|
|
145
|
-
(0, inversify_1.named)(connection_container_module_1.ConnectionContainerModule),
|
|
146
|
-
__metadata("design:type", Object)
|
|
147
|
-
], MessagingContribution.prototype, "connectionModules", void 0);
|
|
148
|
-
__decorate([
|
|
149
|
-
(0, inversify_1.inject)(common_1.ContributionProvider),
|
|
150
|
-
(0, inversify_1.named)(messaging_service_1.MessagingService.Contribution),
|
|
151
|
-
__metadata("design:type", Object)
|
|
152
|
-
], MessagingContribution.prototype, "contributions", void 0);
|
|
153
|
-
__decorate([
|
|
154
|
-
(0, inversify_1.inject)(ws_request_validators_1.WsRequestValidator),
|
|
155
|
-
__metadata("design:type", ws_request_validators_1.WsRequestValidator)
|
|
156
|
-
], MessagingContribution.prototype, "wsRequestValidator", void 0);
|
|
157
|
-
__decorate([
|
|
158
|
-
(0, inversify_1.inject)(messaging_listeners_1.MessagingListener),
|
|
159
|
-
__metadata("design:type", messaging_listeners_1.MessagingListener)
|
|
160
|
-
], MessagingContribution.prototype, "messagingListener", void 0);
|
|
161
|
-
__decorate([
|
|
162
|
-
(0, inversify_1.postConstruct)(),
|
|
163
|
-
__metadata("design:type", Function),
|
|
164
|
-
__metadata("design:paramtypes", []),
|
|
165
|
-
__metadata("design:returntype", void 0)
|
|
166
|
-
], MessagingContribution.prototype, "init", null);
|
|
167
|
-
MessagingContribution = MessagingContribution_1 = __decorate([
|
|
168
|
-
(0, inversify_1.injectable)()
|
|
169
|
-
], MessagingContribution);
|
|
170
|
-
exports.MessagingContribution = MessagingContribution;
|
|
171
|
-
(function (MessagingContribution) {
|
|
172
|
-
class ConnectionHandlers {
|
|
173
|
-
constructor(parent) {
|
|
174
|
-
this.parent = parent;
|
|
175
|
-
this.handlers = [];
|
|
176
|
-
}
|
|
177
|
-
push(spec, callback) {
|
|
178
|
-
const route = new Route(spec);
|
|
179
|
-
const handler = (path, channel) => {
|
|
180
|
-
const params = route.match(path);
|
|
181
|
-
if (!params) {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
callback(params, channel);
|
|
185
|
-
return route.reverse(params);
|
|
186
|
-
};
|
|
187
|
-
this.handlers.push(handler);
|
|
188
|
-
}
|
|
189
|
-
route(path, connection) {
|
|
190
|
-
for (const handler of this.handlers) {
|
|
191
|
-
try {
|
|
192
|
-
const result = handler(path, connection);
|
|
193
|
-
if (result) {
|
|
194
|
-
return result;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
catch (e) {
|
|
198
|
-
console.error(e);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
if (this.parent) {
|
|
202
|
-
return this.parent.route(path, connection);
|
|
203
|
-
}
|
|
204
|
-
return false;
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
MessagingContribution.ConnectionHandlers = ConnectionHandlers;
|
|
208
|
-
})(MessagingContribution = exports.MessagingContribution || (exports.MessagingContribution = {}));
|
|
209
|
-
exports.MessagingContribution = MessagingContribution;
|
|
210
|
-
//# sourceMappingURL=messaging-contribution.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"messaging-contribution.js","sourceRoot":"","sources":["../../../src/node/messaging/messaging-contribution.ts"],"names":[],"mappings":";AAAA,gFAAgF;AAChF,yCAAyC;AACzC,EAAE;AACF,2EAA2E;AAC3E,mEAAmE;AACnE,wCAAwC;AACxC,EAAE;AACF,4EAA4E;AAC5E,8EAA8E;AAC9E,6EAA6E;AAC7E,yDAAyD;AACzD,uDAAuD;AACvD,EAAE;AACF,gFAAgF;AAChF,gFAAgF;;;;;;;;;;;;;AAIhF,yCAA2C;AAC3C,yCAA4F;AAC5F,yCAAiG;AACjG,kFAAyF;AAEzF,2DAAuD;AACvD,+EAA0E;AAC1E,sCAAuC;AACvC,oEAA8D;AAC9D,+DAA0D;AAC1D,8DAA+E;AAElE,QAAA,kBAAkB,GAAG,MAAM,CAAC,oBAAoB,CAAC,CAAC;AAG/D,IAAa,qBAAqB,6BAAlC,MAAa,qBAAqB;IAAlC;QAiBuB,eAAU,GAAG,IAAI,uBAAqB,CAAC,kBAAkB,EAAU,CAAC;QACpE,oBAAe,GAAG,IAAI,uBAAqB,CAAC,kBAAkB,EAAW,CAAC;QAkBnF,sBAAiB,GAAG,KAAK,CAAC,CAAC,aAAa;QACxC,sBAAiB,GAAG,GAAG,CAAC,CAAC,SAAS;IAsFhD,CAAC;IAtG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AN,MAAM,CAAwB;YAHlC,aAAQ,GAAwD,EAAE,CAAC;QAIlF,CAAC;QAEL,IAAI,CAAC,IAAY,EAAE,QAAsE;YACrF,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAC;YAC9B,MAAM,OAAO,GAAG,CAAC,IAAY,EAAE,OAAU,EAAkB,EAAE;gBACzD,MAAM,MAAM,GAAG,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;gBACjC,IAAI,CAAC,MAAM,EAAE;oBACT,OAAO,KAAK,CAAC;iBAChB;gBACD,QAAQ,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;gBAC1B,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACjC,CAAC,CAAC;YACF,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QAChC,CAAC;QAED,KAAK,CAAC,IAAY,EAAE,UAAa;YAC7B,KAAK,MAAM,OAAO,IAAI,IAAI,CAAC,QAAQ,EAAE;gBACjC,IAAI;oBACA,MAAM,MAAM,GAAG,OAAO,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;oBACzC,IAAI,MAAM,EAAE;wBACR,OAAO,MAAM,CAAC;qBACjB;iBACJ;gBAAC,OAAO,CAAC,EAAE;oBACR,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;iBACpB;aACJ;YACD,IAAI,IAAI,CAAC,MAAM,EAAE;gBACb,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;aAC9C;YACD,OAAO,KAAK,CAAC;QACjB,CAAC;KACJ;IApCY,wCAAkB,qBAoC9B,CAAA;AACL,CAAC,EAtCgB,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAsCrC;AAnKY,sDAAqB"}
|
|
@@ -1,115 +0,0 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { injectable, interfaces } from 'inversify';
|
|
18
|
-
import { Emitter, Event } from '../event';
|
|
19
|
-
import { ConnectionHandler } from './handler';
|
|
20
|
-
import { RpcProxy, RpcProxyFactory } from './proxy-factory';
|
|
21
|
-
import { Channel, ChannelMultiplexer } from '../message-rpc/channel';
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Factor common logic according to `ElectronIpcConnectionProvider` and
|
|
25
|
-
* `WebSocketConnectionProvider`. This class handles channels in a somewhat
|
|
26
|
-
* generic way.
|
|
27
|
-
*/
|
|
28
|
-
@injectable()
|
|
29
|
-
export abstract class AbstractConnectionProvider<AbstractOptions extends object> {
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Create a proxy object to remote interface of T type
|
|
33
|
-
* over an electron ipc connection for the given path and proxy factory.
|
|
34
|
-
*/
|
|
35
|
-
static createProxy<T extends object>(container: interfaces.Container, path: string, factory: RpcProxyFactory<T>): RpcProxy<T>;
|
|
36
|
-
/**
|
|
37
|
-
* Create a proxy object to remote interface of T type
|
|
38
|
-
* over an electron ipc connection for the given path.
|
|
39
|
-
*
|
|
40
|
-
* An optional target can be provided to handle
|
|
41
|
-
* notifications and requests from a remote side.
|
|
42
|
-
*/
|
|
43
|
-
static createProxy<T extends object>(container: interfaces.Container, path: string, target?: object): RpcProxy<T> {
|
|
44
|
-
throw new Error('abstract');
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
protected readonly onIncomingMessageActivityEmitter: Emitter<void> = new Emitter();
|
|
48
|
-
get onIncomingMessageActivity(): Event<void> {
|
|
49
|
-
return this.onIncomingMessageActivityEmitter.event;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Create a proxy object to remote interface of T type
|
|
54
|
-
* over a web socket connection for the given path and proxy factory.
|
|
55
|
-
*/
|
|
56
|
-
createProxy<T extends object>(path: string, factory: RpcProxyFactory<T>): RpcProxy<T>;
|
|
57
|
-
/**
|
|
58
|
-
* Create a proxy object to remote interface of T type
|
|
59
|
-
* over a web socket connection for the given path.
|
|
60
|
-
*
|
|
61
|
-
* An optional target can be provided to handle
|
|
62
|
-
* notifications and requests from a remote side.
|
|
63
|
-
*/
|
|
64
|
-
createProxy<T extends object>(path: string, target?: object): RpcProxy<T>;
|
|
65
|
-
createProxy<T extends object>(path: string, arg?: object): RpcProxy<T> {
|
|
66
|
-
const factory = arg instanceof RpcProxyFactory ? arg : new RpcProxyFactory<T>(arg);
|
|
67
|
-
this.listen({
|
|
68
|
-
path,
|
|
69
|
-
onConnection: c => factory.listen(c)
|
|
70
|
-
});
|
|
71
|
-
return factory.createProxy();
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
protected channelMultiplexer?: ChannelMultiplexer;
|
|
75
|
-
|
|
76
|
-
// A set of channel opening functions that are executed if the backend reconnects to restore the
|
|
77
|
-
// the channels that were open before the disconnect occurred.
|
|
78
|
-
protected reconnectChannelOpeners: Array<() => Promise<void>> = [];
|
|
79
|
-
|
|
80
|
-
protected initializeMultiplexer(): void {
|
|
81
|
-
const mainChannel = this.createMainChannel();
|
|
82
|
-
mainChannel.onMessage(() => this.onIncomingMessageActivityEmitter.fire());
|
|
83
|
-
this.channelMultiplexer = new ChannelMultiplexer(mainChannel);
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Install a connection handler for the given path.
|
|
88
|
-
*/
|
|
89
|
-
listen(handler: ConnectionHandler, options?: AbstractOptions): void {
|
|
90
|
-
this.openChannel(handler.path, channel => {
|
|
91
|
-
handler.onConnection(channel);
|
|
92
|
-
}, options);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
async openChannel(path: string, handler: (channel: Channel) => void, options?: AbstractOptions): Promise<void> {
|
|
96
|
-
if (!this.channelMultiplexer) {
|
|
97
|
-
throw new Error('The channel multiplexer has not been initialized yet!');
|
|
98
|
-
}
|
|
99
|
-
const newChannel = await this.channelMultiplexer.open(path);
|
|
100
|
-
newChannel.onClose(() => {
|
|
101
|
-
const { reconnecting } = { reconnecting: true, ...options };
|
|
102
|
-
if (reconnecting) {
|
|
103
|
-
this.reconnectChannelOpeners.push(() => this.openChannel(path, handler, options));
|
|
104
|
-
}
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
handler(newChannel);
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Create the main connection that is used for multiplexing all service channels.
|
|
112
|
-
*/
|
|
113
|
-
protected abstract createMainChannel(): Channel;
|
|
114
|
-
|
|
115
|
-
}
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2020 Ericsson and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import * as http from 'http';
|
|
18
|
-
import { injectable, inject } from 'inversify';
|
|
19
|
-
import { MessagingContribution } from '../../node/messaging/messaging-contribution';
|
|
20
|
-
import { ElectronTokenValidator } from './electron-token-validator';
|
|
21
|
-
|
|
22
|
-
/**
|
|
23
|
-
* Override the browser MessagingContribution class to refuse connections that do not include a specific token.
|
|
24
|
-
* @deprecated since 1.8.0
|
|
25
|
-
*/
|
|
26
|
-
@injectable()
|
|
27
|
-
export class ElectronMessagingContribution extends MessagingContribution {
|
|
28
|
-
|
|
29
|
-
@inject(ElectronTokenValidator)
|
|
30
|
-
protected readonly tokenValidator: ElectronTokenValidator;
|
|
31
|
-
|
|
32
|
-
/**
|
|
33
|
-
* Only allow token-bearers.
|
|
34
|
-
*/
|
|
35
|
-
protected override async allowConnect(request: http.IncomingMessage): Promise<boolean> {
|
|
36
|
-
if (this.tokenValidator.allowRequest(request)) {
|
|
37
|
-
return super.allowConnect(request);
|
|
38
|
-
}
|
|
39
|
-
return false;
|
|
40
|
-
}
|
|
41
|
-
}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 TypeFox and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import * as http from 'http';
|
|
18
|
-
import * as https from 'https';
|
|
19
|
-
import { Server, Socket } from 'socket.io';
|
|
20
|
-
import { injectable, inject, named, postConstruct, interfaces, Container } from 'inversify';
|
|
21
|
-
import { ContributionProvider, ConnectionHandler, bindContributionProvider } from '../../common';
|
|
22
|
-
import { IWebSocket, WebSocketChannel } from '../../common/messaging/web-socket-channel';
|
|
23
|
-
import { BackendApplicationContribution } from '../backend-application';
|
|
24
|
-
import { MessagingService } from './messaging-service';
|
|
25
|
-
import { ConnectionContainerModule } from './connection-container-module';
|
|
26
|
-
import Route = require('route-parser');
|
|
27
|
-
import { WsRequestValidator } from '../ws-request-validators';
|
|
28
|
-
import { MessagingListener } from './messaging-listeners';
|
|
29
|
-
import { Channel, ChannelMultiplexer } from '../../common/message-rpc/channel';
|
|
30
|
-
|
|
31
|
-
export const MessagingContainer = Symbol('MessagingContainer');
|
|
32
|
-
|
|
33
|
-
@injectable()
|
|
34
|
-
export class MessagingContribution implements BackendApplicationContribution, MessagingService {
|
|
35
|
-
|
|
36
|
-
@inject(MessagingContainer)
|
|
37
|
-
protected readonly container: interfaces.Container;
|
|
38
|
-
|
|
39
|
-
@inject(ContributionProvider) @named(ConnectionContainerModule)
|
|
40
|
-
protected readonly connectionModules: ContributionProvider<interfaces.ContainerModule>;
|
|
41
|
-
|
|
42
|
-
@inject(ContributionProvider) @named(MessagingService.Contribution)
|
|
43
|
-
protected readonly contributions: ContributionProvider<MessagingService.Contribution>;
|
|
44
|
-
|
|
45
|
-
@inject(WsRequestValidator)
|
|
46
|
-
protected readonly wsRequestValidator: WsRequestValidator;
|
|
47
|
-
|
|
48
|
-
@inject(MessagingListener)
|
|
49
|
-
protected readonly messagingListener: MessagingListener;
|
|
50
|
-
|
|
51
|
-
protected readonly wsHandlers = new MessagingContribution.ConnectionHandlers<Socket>();
|
|
52
|
-
protected readonly channelHandlers = new MessagingContribution.ConnectionHandlers<Channel>();
|
|
53
|
-
|
|
54
|
-
@postConstruct()
|
|
55
|
-
protected init(): void {
|
|
56
|
-
this.ws(WebSocketChannel.wsPath, (_, socket) => this.handleChannels(socket));
|
|
57
|
-
for (const contribution of this.contributions.getContributions()) {
|
|
58
|
-
contribution.configure(this);
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
wsChannel(spec: string, callback: (params: MessagingService.PathParams, channel: Channel) => void): void {
|
|
63
|
-
this.channelHandlers.push(spec, (params, channel) => callback(params, channel));
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
ws(spec: string, callback: (params: MessagingService.PathParams, socket: Socket) => void): void {
|
|
67
|
-
this.wsHandlers.push(spec, callback);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
protected checkAliveTimeout = 30000; // 30 seconds
|
|
71
|
-
protected maxHttpBufferSize = 1e8; // 100 MB
|
|
72
|
-
|
|
73
|
-
onStart(server: http.Server | https.Server): void {
|
|
74
|
-
const socketServer = new Server(server, {
|
|
75
|
-
pingInterval: this.checkAliveTimeout,
|
|
76
|
-
pingTimeout: this.checkAliveTimeout * 2,
|
|
77
|
-
maxHttpBufferSize: this.maxHttpBufferSize
|
|
78
|
-
});
|
|
79
|
-
// Accept every namespace by using /.*/
|
|
80
|
-
socketServer.of(/.*/).on('connection', async socket => {
|
|
81
|
-
const request = socket.request;
|
|
82
|
-
// Socket.io strips the `origin` header of the incoming request
|
|
83
|
-
// We provide a `fix-origin` header in the `WebSocketConnectionProvider`
|
|
84
|
-
request.headers.origin = request.headers['fix-origin'] as string;
|
|
85
|
-
if (await this.allowConnect(socket.request)) {
|
|
86
|
-
await this.handleConnection(socket);
|
|
87
|
-
this.messagingListener.onDidWebSocketUpgrade(socket.request, socket);
|
|
88
|
-
} else {
|
|
89
|
-
socket.disconnect(true);
|
|
90
|
-
}
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
protected async handleConnection(socket: Socket): Promise<void> {
|
|
95
|
-
const pathname = socket.nsp.name;
|
|
96
|
-
if (pathname && !this.wsHandlers.route(pathname, socket)) {
|
|
97
|
-
console.error('Cannot find a ws handler for the path: ' + pathname);
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
protected async allowConnect(request: http.IncomingMessage): Promise<boolean> {
|
|
102
|
-
try {
|
|
103
|
-
return this.wsRequestValidator.allowWsUpgrade(request);
|
|
104
|
-
} catch (e) {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
protected handleChannels(socket: Socket): void {
|
|
110
|
-
const socketChannel = new WebSocketChannel(this.toIWebSocket(socket));
|
|
111
|
-
const multiplexer = new ChannelMultiplexer(socketChannel);
|
|
112
|
-
const channelHandlers = this.getConnectionChannelHandlers(socket);
|
|
113
|
-
multiplexer.onDidOpenChannel(event => {
|
|
114
|
-
if (channelHandlers.route(event.id, event.channel)) {
|
|
115
|
-
console.debug(`Opening channel for service path '${event.id}'.`);
|
|
116
|
-
event.channel.onClose(() => console.debug(`Closing channel on service path '${event.id}'.`));
|
|
117
|
-
}
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
protected toIWebSocket(socket: Socket): IWebSocket {
|
|
122
|
-
return {
|
|
123
|
-
close: () => {
|
|
124
|
-
socket.removeAllListeners('disconnect');
|
|
125
|
-
socket.removeAllListeners('error');
|
|
126
|
-
socket.removeAllListeners('message');
|
|
127
|
-
socket.disconnect();
|
|
128
|
-
},
|
|
129
|
-
isConnected: () => socket.connected,
|
|
130
|
-
onClose: cb => socket.on('disconnect', reason => cb(reason)),
|
|
131
|
-
onError: cb => socket.on('error', error => cb(error)),
|
|
132
|
-
onMessage: cb => socket.on('message', data => cb(data)),
|
|
133
|
-
send: message => socket.emit('message', message)
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
protected createSocketContainer(socket: Socket): Container {
|
|
138
|
-
const connectionContainer: Container = this.container.createChild() as Container;
|
|
139
|
-
connectionContainer.bind(Socket).toConstantValue(socket);
|
|
140
|
-
return connectionContainer;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
protected getConnectionChannelHandlers(socket: Socket): MessagingContribution.ConnectionHandlers<Channel> {
|
|
144
|
-
const connectionContainer = this.createSocketContainer(socket);
|
|
145
|
-
bindContributionProvider(connectionContainer, ConnectionHandler);
|
|
146
|
-
connectionContainer.load(...this.connectionModules.getContributions());
|
|
147
|
-
const connectionChannelHandlers = new MessagingContribution.ConnectionHandlers(this.channelHandlers);
|
|
148
|
-
const connectionHandlers = connectionContainer.getNamed<ContributionProvider<ConnectionHandler>>(ContributionProvider, ConnectionHandler);
|
|
149
|
-
for (const connectionHandler of connectionHandlers.getContributions(true)) {
|
|
150
|
-
connectionChannelHandlers.push(connectionHandler.path, (_, channel) => {
|
|
151
|
-
connectionHandler.onConnection(channel);
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
return connectionChannelHandlers;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export namespace MessagingContribution {
|
|
160
|
-
export class ConnectionHandlers<T> {
|
|
161
|
-
protected readonly handlers: ((path: string, connection: T) => string | false)[] = [];
|
|
162
|
-
|
|
163
|
-
constructor(
|
|
164
|
-
protected readonly parent?: ConnectionHandlers<T>
|
|
165
|
-
) { }
|
|
166
|
-
|
|
167
|
-
push(spec: string, callback: (params: MessagingService.PathParams, connection: T) => void): void {
|
|
168
|
-
const route = new Route(spec);
|
|
169
|
-
const handler = (path: string, channel: T): string | false => {
|
|
170
|
-
const params = route.match(path);
|
|
171
|
-
if (!params) {
|
|
172
|
-
return false;
|
|
173
|
-
}
|
|
174
|
-
callback(params, channel);
|
|
175
|
-
return route.reverse(params);
|
|
176
|
-
};
|
|
177
|
-
this.handlers.push(handler);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
route(path: string, connection: T): string | false {
|
|
181
|
-
for (const handler of this.handlers) {
|
|
182
|
-
try {
|
|
183
|
-
const result = handler(path, connection);
|
|
184
|
-
if (result) {
|
|
185
|
-
return result;
|
|
186
|
-
}
|
|
187
|
-
} catch (e) {
|
|
188
|
-
console.error(e);
|
|
189
|
-
}
|
|
190
|
-
}
|
|
191
|
-
if (this.parent) {
|
|
192
|
-
return this.parent.route(path, connection);
|
|
193
|
-
}
|
|
194
|
-
return false;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|