@litert/televoke 0.4.6 → 1.0.0-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/CHANGES.md +6 -0
- package/README.md +13 -8
- package/lib/client/Client.decl.d.ts +47 -0
- package/lib/client/Client.decl.d.ts.map +1 -0
- package/lib/client/Client.decl.js +18 -0
- package/lib/client/Client.decl.js.map +1 -0
- package/lib/client/JsonApiClient.impl.d.ts +28 -0
- package/lib/client/JsonApiClient.impl.d.ts.map +1 -0
- package/lib/client/JsonApiClient.impl.js +169 -0
- package/lib/client/JsonApiClient.impl.js.map +1 -0
- package/lib/client/LegacyHttpClient.impl.d.ts +62 -0
- package/lib/client/LegacyHttpClient.impl.d.ts.map +1 -0
- package/lib/client/LegacyHttpClient.impl.js +163 -0
- package/lib/client/LegacyHttpClient.impl.js.map +1 -0
- package/lib/client/index.d.ts +19 -0
- package/lib/client/index.d.ts.map +1 -0
- package/lib/client/index.js +35 -0
- package/lib/client/index.js.map +1 -0
- package/lib/index.d.ts +18 -20
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +19 -20
- package/lib/index.js.map +1 -1
- package/lib/server/LegacyServerChannel.impl.d.ts +38 -0
- package/lib/server/LegacyServerChannel.impl.d.ts.map +1 -0
- package/lib/server/LegacyServerChannel.impl.js +51 -0
- package/lib/server/LegacyServerChannel.impl.js.map +1 -0
- package/lib/server/Server.decl.d.ts +81 -0
- package/lib/server/Server.decl.d.ts.map +1 -0
- package/lib/server/Server.decl.js +18 -0
- package/lib/server/Server.decl.js.map +1 -0
- package/lib/server/Server.impl.d.ts +33 -0
- package/lib/server/Server.impl.d.ts.map +1 -0
- package/lib/server/Server.impl.js +58 -0
- package/lib/server/Server.impl.js.map +1 -0
- package/lib/server/ServerChannel.d.ts +20 -0
- package/lib/server/ServerChannel.d.ts.map +1 -0
- package/lib/server/ServerChannel.js +23 -0
- package/lib/server/ServerChannel.js.map +1 -0
- package/lib/server/SimpleJsonApiRouter.d.ts +28 -0
- package/lib/server/SimpleJsonApiRouter.d.ts.map +1 -0
- package/lib/server/SimpleJsonApiRouter.js +92 -0
- package/lib/server/SimpleJsonApiRouter.js.map +1 -0
- package/lib/server/index.d.ts +19 -0
- package/lib/server/index.d.ts.map +1 -0
- package/lib/server/index.js +35 -0
- package/lib/server/index.js.map +1 -0
- package/lib/shared/BinaryStream.d.ts +32 -0
- package/lib/shared/BinaryStream.d.ts.map +1 -0
- package/lib/shared/BinaryStream.js +93 -0
- package/lib/shared/BinaryStream.js.map +1 -0
- package/lib/shared/BinaryStreamManager.d.ts +52 -0
- package/lib/shared/BinaryStreamManager.d.ts.map +1 -0
- package/lib/shared/BinaryStreamManager.js +105 -0
- package/lib/shared/BinaryStreamManager.js.map +1 -0
- package/lib/shared/Channel.impl.d.ts +79 -0
- package/lib/shared/Channel.impl.d.ts.map +1 -0
- package/lib/shared/Channel.impl.js +433 -0
- package/lib/shared/Channel.impl.js.map +1 -0
- package/lib/shared/Constants.d.ts +32 -0
- package/lib/shared/Constants.d.ts.map +1 -0
- package/lib/shared/Constants.js +35 -0
- package/lib/shared/Constants.js.map +1 -0
- package/lib/shared/Encodings/index.d.ts +18 -0
- package/lib/shared/Encodings/index.d.ts.map +1 -0
- package/lib/shared/Encodings/index.js +21 -0
- package/lib/shared/Encodings/index.js.map +1 -0
- package/lib/shared/Encodings/v1/EncoderV1.d.ts +22 -0
- package/lib/shared/Encodings/v1/EncoderV1.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/EncoderV1.js +47 -0
- package/lib/shared/Encodings/v1/EncoderV1.js.map +1 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.d.ts +78 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.js +53 -0
- package/lib/shared/Encodings/v1/Protocol.v1.decls.js.map +1 -0
- package/lib/shared/Encodings/v1/index.d.ts +18 -0
- package/lib/shared/Encodings/v1/index.d.ts.map +1 -0
- package/lib/shared/Encodings/v1/index.js +34 -0
- package/lib/shared/Encodings/v1/index.js.map +1 -0
- package/lib/shared/Encodings/v2/Constants.v2.d.ts +29 -0
- package/lib/shared/Encodings/v2/Constants.v2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/Constants.v2.js +34 -0
- package/lib/shared/Encodings/v2/Constants.v2.js.map +1 -0
- package/lib/shared/Encodings/v2/DecoderV2.d.ts +27 -0
- package/lib/shared/Encodings/v2/DecoderV2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/DecoderV2.js +279 -0
- package/lib/shared/Encodings/v2/DecoderV2.js.map +1 -0
- package/lib/shared/Encodings/v2/EncoderV2.d.ts +21 -0
- package/lib/shared/Encodings/v2/EncoderV2.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/EncoderV2.js +176 -0
- package/lib/shared/Encodings/v2/EncoderV2.js.map +1 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.d.ts +95 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.js +18 -0
- package/lib/shared/Encodings/v2/Encoding.v2.decl.js.map +1 -0
- package/lib/shared/Encodings/v2/index.d.ts +20 -0
- package/lib/shared/Encodings/v2/index.d.ts.map +1 -0
- package/lib/shared/Encodings/v2/index.js +35 -0
- package/lib/shared/Encodings/v2/index.js.map +1 -0
- package/lib/shared/Errors.d.ts +60 -0
- package/lib/shared/Errors.d.ts.map +1 -0
- package/lib/shared/Errors.js +75 -0
- package/lib/shared/Errors.js.map +1 -0
- package/lib/shared/Shared.decl.d.ts +296 -0
- package/lib/shared/Shared.decl.d.ts.map +1 -0
- package/lib/shared/Shared.decl.js +18 -0
- package/lib/shared/Shared.decl.js.map +1 -0
- package/lib/shared/Utils.d.ts +25 -0
- package/lib/shared/Utils.d.ts.map +1 -0
- package/lib/shared/Utils.js +46 -0
- package/lib/shared/Utils.js.map +1 -0
- package/lib/shared/index.d.ts +23 -0
- package/lib/shared/index.d.ts.map +1 -0
- package/lib/shared/index.js +39 -0
- package/lib/shared/index.js.map +1 -0
- package/lib/transporters/Transporter.decl.d.ts +90 -0
- package/lib/transporters/Transporter.decl.d.ts.map +1 -0
- package/lib/transporters/Transporter.decl.js +18 -0
- package/lib/transporters/Transporter.decl.js.map +1 -0
- package/lib/transporters/http-listener/AbstractHttpListener.d.ts +32 -0
- package/lib/transporters/http-listener/AbstractHttpListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/AbstractHttpListener.js +46 -0
- package/lib/transporters/http-listener/AbstractHttpListener.js.map +1 -0
- package/lib/transporters/http-listener/Http.Decl.d.ts +95 -0
- package/lib/transporters/http-listener/Http.Decl.d.ts.map +1 -0
- package/lib/transporters/http-listener/Http.Decl.js +52 -0
- package/lib/transporters/http-listener/Http.Decl.js.map +1 -0
- package/lib/transporters/http-listener/HttpListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpListener.js +73 -0
- package/lib/transporters/http-listener/HttpListener.js.map +1 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.js +72 -0
- package/lib/transporters/http-listener/HttpUnixSocketListener.js.map +1 -0
- package/lib/transporters/http-listener/HttpsListener.d.ts +18 -0
- package/lib/transporters/http-listener/HttpsListener.d.ts.map +1 -0
- package/lib/transporters/http-listener/HttpsListener.js +73 -0
- package/lib/transporters/http-listener/HttpsListener.js.map +1 -0
- package/lib/transporters/http-listener/index.d.ts +20 -0
- package/lib/transporters/http-listener/index.d.ts.map +1 -0
- package/lib/transporters/http-listener/index.js +36 -0
- package/lib/transporters/http-listener/index.js.map +1 -0
- package/lib/transporters/index.d.ts +17 -0
- package/lib/transporters/index.d.ts.map +1 -0
- package/lib/transporters/index.js +18 -0
- package/lib/transporters/index.js.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.d.ts +24 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.d.ts.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.js +167 -0
- package/lib/transporters/legacy-http/LegacyHttp.Server.js.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.d.ts +28 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.d.ts.map +1 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.js +55 -0
- package/lib/transporters/legacy-http/LegacyHttp.Transporter.js.map +1 -0
- package/lib/transporters/legacy-http/index.d.ts +18 -0
- package/lib/transporters/legacy-http/index.d.ts.map +1 -0
- package/lib/transporters/legacy-http/index.js +34 -0
- package/lib/transporters/legacy-http/index.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.Tcp.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.Tls.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.d.ts +34 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.js +78 -0
- package/lib/transporters/lwdfx/LwDFX.Transporter.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.d.ts +19 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.js +33 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.d.ts +21 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.js +64 -0
- package/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.js.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.decl.d.ts +18 -0
- package/lib/transporters/lwdfx/LwDFX.decl.d.ts.map +1 -0
- package/lib/transporters/lwdfx/LwDFX.decl.js +18 -0
- package/lib/transporters/lwdfx/LwDFX.decl.js.map +1 -0
- package/lib/transporters/lwdfx/index.d.ts +23 -0
- package/lib/transporters/lwdfx/index.d.ts.map +1 -0
- package/lib/transporters/lwdfx/index.js +39 -0
- package/lib/transporters/lwdfx/index.js.map +1 -0
- package/lib/transporters/memory/Memory.Impl.d.ts +43 -0
- package/lib/transporters/memory/Memory.Impl.d.ts.map +1 -0
- package/lib/transporters/memory/Memory.Impl.js +227 -0
- package/lib/transporters/memory/Memory.Impl.js.map +1 -0
- package/lib/transporters/memory/index.d.ts +17 -0
- package/lib/transporters/memory/index.d.ts.map +1 -0
- package/lib/transporters/memory/index.js +33 -0
- package/lib/transporters/memory/index.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Client.d.ts +20 -0
- package/lib/transporters/websocket/WebSocket.Client.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Client.js +68 -0
- package/lib/transporters/websocket/WebSocket.Client.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Server.d.ts +25 -0
- package/lib/transporters/websocket/WebSocket.Server.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Server.js +87 -0
- package/lib/transporters/websocket/WebSocket.Server.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.Transporter.d.ts +34 -0
- package/lib/transporters/websocket/WebSocket.Transporter.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.Transporter.js +106 -0
- package/lib/transporters/websocket/WebSocket.Transporter.js.map +1 -0
- package/lib/transporters/websocket/WebSocket.decl.d.ts +19 -0
- package/lib/transporters/websocket/WebSocket.decl.d.ts.map +1 -0
- package/lib/transporters/websocket/WebSocket.decl.js +22 -0
- package/lib/transporters/websocket/WebSocket.decl.js.map +1 -0
- package/lib/transporters/websocket/index.d.ts +19 -0
- package/lib/transporters/websocket/index.d.ts.map +1 -0
- package/lib/transporters/websocket/index.js +35 -0
- package/lib/transporters/websocket/index.js.map +1 -0
- package/package.json +12 -12
- package/src/lib/client/Client.decl.ts +61 -0
- package/src/lib/client/JsonApiClient.impl.ts +258 -0
- package/src/lib/client/LegacyHttpClient.impl.ts +278 -0
- package/src/lib/client/index.ts +19 -0
- package/src/lib/index.ts +18 -20
- package/src/lib/server/LegacyServerChannel.impl.ts +71 -0
- package/src/lib/server/Server.decl.ts +109 -0
- package/src/lib/server/Server.impl.ts +90 -0
- package/src/lib/server/ServerChannel.ts +20 -0
- package/src/lib/server/SimpleJsonApiRouter.ts +135 -0
- package/src/lib/server/index.ts +19 -0
- package/src/lib/shared/BinaryStream.ts +131 -0
- package/src/lib/shared/BinaryStreamManager.ts +142 -0
- package/src/lib/shared/Channel.impl.ts +641 -0
- package/src/lib/shared/Constants.ts +35 -0
- package/src/lib/shared/Encodings/index.ts +18 -0
- package/src/lib/shared/Encodings/v1/EncoderV1.ts +66 -0
- package/src/lib/shared/Encodings/v1/Protocol.v1.decls.ts +96 -0
- package/src/lib/shared/Encodings/v1/index.ts +18 -0
- package/src/lib/shared/Encodings/v2/Constants.v2.ts +31 -0
- package/src/lib/shared/Encodings/v2/DecoderV2.ts +404 -0
- package/src/lib/shared/Encodings/v2/EncoderV2.ts +283 -0
- package/src/lib/shared/Encodings/v2/Encoding.v2.decl.ts +133 -0
- package/src/lib/shared/Encodings/v2/index.ts +20 -0
- package/src/lib/shared/Errors.ts +94 -0
- package/src/lib/shared/Shared.decl.ts +347 -0
- package/src/lib/shared/Utils.ts +51 -0
- package/src/lib/shared/index.ts +23 -0
- package/src/lib/transporters/Transporter.decl.ts +117 -0
- package/src/lib/transporters/http-listener/AbstractHttpListener.ts +57 -0
- package/src/lib/transporters/http-listener/Http.Decl.ts +141 -0
- package/src/lib/transporters/http-listener/HttpListener.ts +102 -0
- package/src/lib/transporters/http-listener/HttpUnixSocketListener.ts +97 -0
- package/src/lib/transporters/http-listener/HttpsListener.ts +102 -0
- package/src/lib/transporters/http-listener/index.ts +20 -0
- package/src/lib/transporters/index.ts +17 -0
- package/src/lib/transporters/legacy-http/LegacyHttp.Server.ts +262 -0
- package/src/lib/transporters/legacy-http/LegacyHttp.Transporter.ts +66 -0
- package/src/lib/transporters/legacy-http/index.ts +18 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tcp.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tcp.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tls.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.Tls.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.Transporter.ts +100 -0
- package/src/lib/transporters/lwdfx/LwDFX.UnixSocket.Client.ts +34 -0
- package/src/lib/transporters/lwdfx/LwDFX.UnixSocket.Server.ts +94 -0
- package/src/lib/transporters/lwdfx/LwDFX.decl.ts +19 -0
- package/src/lib/transporters/lwdfx/index.ts +23 -0
- package/src/lib/transporters/memory/Memory.Impl.ts +363 -0
- package/src/lib/transporters/memory/index.ts +17 -0
- package/src/lib/transporters/websocket/WebSocket.Client.ts +76 -0
- package/src/lib/transporters/websocket/WebSocket.Server.ts +118 -0
- package/src/lib/transporters/websocket/WebSocket.Transporter.ts +132 -0
- package/src/lib/transporters/websocket/WebSocket.decl.ts +21 -0
- package/src/lib/transporters/websocket/index.ts +19 -0
- package/lib/Client/BuiltInRIDGenerator.d.ts +0 -4
- package/lib/Client/BuiltInRIDGenerator.d.ts.map +0 -1
- package/lib/Client/BuiltInRIDGenerator.js +0 -18
- package/lib/Client/BuiltInRIDGenerator.js.map +0 -1
- package/lib/Client/Common.d.ts +0 -47
- package/lib/Client/Common.d.ts.map +0 -1
- package/lib/Client/Common.js +0 -18
- package/lib/Client/Common.js.map +0 -1
- package/lib/Client/Errors.d.ts +0 -26
- package/lib/Client/Errors.d.ts.map +0 -1
- package/lib/Client/Errors.js +0 -80
- package/lib/Client/Errors.js.map +0 -1
- package/lib/Client/HttpClient.d.ts +0 -37
- package/lib/Client/HttpClient.d.ts.map +0 -1
- package/lib/Client/HttpClient.js +0 -148
- package/lib/Client/HttpClient.js.map +0 -1
- package/lib/Client/HttpsClient.d.ts +0 -40
- package/lib/Client/HttpsClient.d.ts.map +0 -1
- package/lib/Client/HttpsClient.js +0 -144
- package/lib/Client/HttpsClient.js.map +0 -1
- package/lib/Client/TCPClient.d.ts +0 -34
- package/lib/Client/TCPClient.d.ts.map +0 -1
- package/lib/Client/TCPClient.js +0 -271
- package/lib/Client/TCPClient.js.map +0 -1
- package/lib/Client/TLSClient.d.ts +0 -34
- package/lib/Client/TLSClient.d.ts.map +0 -1
- package/lib/Client/TLSClient.js +0 -265
- package/lib/Client/TLSClient.js.map +0 -1
- package/lib/Client/index.d.ts +0 -23
- package/lib/Client/index.d.ts.map +0 -1
- package/lib/Client/index.js +0 -39
- package/lib/Client/index.js.map +0 -1
- package/lib/Common/API.d.ts +0 -19
- package/lib/Common/API.d.ts.map +0 -1
- package/lib/Common/API.js +0 -18
- package/lib/Common/API.js.map +0 -1
- package/lib/Common/Encoding.d.ts +0 -32
- package/lib/Common/Encoding.d.ts.map +0 -1
- package/lib/Common/Encoding.js +0 -20
- package/lib/Common/Encoding.js.map +0 -1
- package/lib/Common/Request.d.ts +0 -23
- package/lib/Common/Request.d.ts.map +0 -1
- package/lib/Common/Request.js +0 -18
- package/lib/Common/Request.js.map +0 -1
- package/lib/Common/Response.d.ts +0 -60
- package/lib/Common/Response.d.ts.map +0 -1
- package/lib/Common/Response.js +0 -42
- package/lib/Common/Response.js.map +0 -1
- package/lib/Common/index.d.ts +0 -20
- package/lib/Common/index.d.ts.map +0 -1
- package/lib/Common/index.js +0 -36
- package/lib/Common/index.js.map +0 -1
- package/lib/Encoder/Decoder.d.ts +0 -18
- package/lib/Encoder/Decoder.d.ts.map +0 -1
- package/lib/Encoder/Decoder.js +0 -136
- package/lib/Encoder/Decoder.js.map +0 -1
- package/lib/Encoder/Encoder.d.ts +0 -18
- package/lib/Encoder/Encoder.d.ts.map +0 -1
- package/lib/Encoder/Encoder.js +0 -35
- package/lib/Encoder/Encoder.js.map +0 -1
- package/lib/Encoder/Errors.d.ts +0 -17
- package/lib/Encoder/Errors.d.ts.map +0 -1
- package/lib/Encoder/Errors.js +0 -26
- package/lib/Encoder/Errors.js.map +0 -1
- package/lib/Errors.d.ts +0 -20
- package/lib/Errors.d.ts.map +0 -1
- package/lib/Errors.js +0 -40
- package/lib/Errors.js.map +0 -1
- package/lib/Server/Common/Gateway.d.ts +0 -26
- package/lib/Server/Common/Gateway.d.ts.map +0 -1
- package/lib/Server/Common/Gateway.js +0 -18
- package/lib/Server/Common/Gateway.js.map +0 -1
- package/lib/Server/Common/Request.d.ts +0 -21
- package/lib/Server/Common/Request.d.ts.map +0 -1
- package/lib/Server/Common/Request.js +0 -18
- package/lib/Server/Common/Request.js.map +0 -1
- package/lib/Server/Common/Router.d.ts +0 -41
- package/lib/Server/Common/Router.d.ts.map +0 -1
- package/lib/Server/Common/Router.js +0 -18
- package/lib/Server/Common/Router.js.map +0 -1
- package/lib/Server/Common/Server.d.ts +0 -57
- package/lib/Server/Common/Server.d.ts.map +0 -1
- package/lib/Server/Common/Server.js +0 -18
- package/lib/Server/Common/Server.js.map +0 -1
- package/lib/Server/Common/index.d.ts +0 -20
- package/lib/Server/Common/index.d.ts.map +0 -1
- package/lib/Server/Common/index.js +0 -36
- package/lib/Server/Common/index.js.map +0 -1
- package/lib/Server/Errors.d.ts +0 -25
- package/lib/Server/Errors.d.ts.map +0 -1
- package/lib/Server/Errors.js +0 -74
- package/lib/Server/Errors.js.map +0 -1
- package/lib/Server/Gateways/Http.d.ts +0 -18
- package/lib/Server/Gateways/Http.d.ts.map +0 -1
- package/lib/Server/Gateways/Http.js +0 -144
- package/lib/Server/Gateways/Http.js.map +0 -1
- package/lib/Server/Gateways/TCP.d.ts +0 -23
- package/lib/Server/Gateways/TCP.d.ts.map +0 -1
- package/lib/Server/Gateways/TCP.js +0 -146
- package/lib/Server/Gateways/TCP.js.map +0 -1
- package/lib/Server/Server.d.ts +0 -18
- package/lib/Server/Server.d.ts.map +0 -1
- package/lib/Server/Server.js +0 -200
- package/lib/Server/Server.js.map +0 -1
- package/lib/Server/SimpleRouter.d.ts +0 -41
- package/lib/Server/SimpleRouter.d.ts.map +0 -1
- package/lib/Server/SimpleRouter.js +0 -54
- package/lib/Server/SimpleRouter.js.map +0 -1
- package/lib/Server/index.d.ts +0 -22
- package/lib/Server/index.d.ts.map +0 -1
- package/lib/Server/index.js +0 -38
- package/lib/Server/index.js.map +0 -1
- package/src/lib/Client/BuiltInRIDGenerator.ts +0 -21
- package/src/lib/Client/Common.ts +0 -63
- package/src/lib/Client/Errors.ts +0 -87
- package/src/lib/Client/HttpClient.ts +0 -232
- package/src/lib/Client/HttpsClient.ts +0 -238
- package/src/lib/Client/TCPClient.ts +0 -420
- package/src/lib/Client/TLSClient.ts +0 -422
- package/src/lib/Client/index.ts +0 -23
- package/src/lib/Common/API.ts +0 -20
- package/src/lib/Common/Encoding.ts +0 -42
- package/src/lib/Common/Request.ts +0 -28
- package/src/lib/Common/Response.ts +0 -67
- package/src/lib/Common/index.ts +0 -20
- package/src/lib/Encoder/Decoder.ts +0 -206
- package/src/lib/Encoder/Encoder.ts +0 -41
- package/src/lib/Encoder/Errors.ts +0 -24
- package/src/lib/Errors.ts +0 -40
- package/src/lib/Server/Common/Gateway.ts +0 -37
- package/src/lib/Server/Common/Request.ts +0 -24
- package/src/lib/Server/Common/Router.ts +0 -52
- package/src/lib/Server/Common/Server.ts +0 -68
- package/src/lib/Server/Common/index.ts +0 -20
- package/src/lib/Server/Errors.ts +0 -80
- package/src/lib/Server/Gateways/Http.ts +0 -203
- package/src/lib/Server/Gateways/TCP.ts +0 -221
- package/src/lib/Server/Server.ts +0 -268
- package/src/lib/Server/SimpleRouter.ts +0 -95
- package/src/lib/Server/index.ts +0 -22
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import type * as Listener from '../http-listener';
|
|
18
|
+
import type * as Http from 'node:http';
|
|
19
|
+
import type * as dT from '../Transporter.decl';
|
|
20
|
+
import * as Shared from '../../shared';
|
|
21
|
+
import { EventEmitter } from 'node:events';
|
|
22
|
+
import { LegacyHttpTransporter } from './LegacyHttp.Transporter';
|
|
23
|
+
import * as v1 from '../../shared/Encodings/v1';
|
|
24
|
+
|
|
25
|
+
const encoder = new v1.TvEncoderV1();
|
|
26
|
+
|
|
27
|
+
const INVALID_REQUEST_RESPONSE = Buffer.from(encoder.encodeApiErrorResponse(
|
|
28
|
+
'null',
|
|
29
|
+
Shared.Encodings.v1.EResponseCode.MALFORMED_ARGUMENTS,
|
|
30
|
+
'INVALID REQUEST',
|
|
31
|
+
0
|
|
32
|
+
));
|
|
33
|
+
|
|
34
|
+
function refuseBadRequest(resp: Http.ServerResponse): void {
|
|
35
|
+
|
|
36
|
+
try {
|
|
37
|
+
|
|
38
|
+
resp.writeHead(400, {
|
|
39
|
+
'content-length': INVALID_REQUEST_RESPONSE.byteLength,
|
|
40
|
+
});
|
|
41
|
+
const socket = resp.socket!;
|
|
42
|
+
resp.end(INVALID_REQUEST_RESPONSE);
|
|
43
|
+
socket.destroy();
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
|
|
47
|
+
// do nothing.
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export interface IHttpGatewayOptions {
|
|
52
|
+
|
|
53
|
+
hostname?: string;
|
|
54
|
+
|
|
55
|
+
port?: number;
|
|
56
|
+
|
|
57
|
+
backlog?: number;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
class LegacyHttpGateway extends EventEmitter implements dT.IGateway {
|
|
61
|
+
|
|
62
|
+
public constructor(
|
|
63
|
+
private readonly _listener: Listener.IHttpListener,
|
|
64
|
+
private readonly _server: dT.IServer,
|
|
65
|
+
) {
|
|
66
|
+
|
|
67
|
+
super();
|
|
68
|
+
|
|
69
|
+
if (this._server.router.encoding !== 'json') {
|
|
70
|
+
|
|
71
|
+
throw new TypeError('Legacy HTTP gateway only supports JSON encoding');
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
this._listener
|
|
75
|
+
.on('error', (e) => this.emit('error', e))
|
|
76
|
+
.setLegacyApiProcessor(this._onRequest);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public get running(): boolean {
|
|
80
|
+
|
|
81
|
+
return this._listener.running;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
private readonly _onRequest = (req: Http.IncomingMessage, resp: Http.ServerResponse): void => {
|
|
85
|
+
|
|
86
|
+
if (req.method !== 'POST' || !req.headers['content-length']) {
|
|
87
|
+
|
|
88
|
+
refuseBadRequest(resp);
|
|
89
|
+
this.emit('error', new Shared.errors.invalid_packet({
|
|
90
|
+
reason: 'invalid_request',
|
|
91
|
+
data: {
|
|
92
|
+
'method': req.method,
|
|
93
|
+
'headers': req.headers,
|
|
94
|
+
'url': req.url,
|
|
95
|
+
},
|
|
96
|
+
}));
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const length = parseInt(req.headers['content-length']);
|
|
101
|
+
|
|
102
|
+
if (!Number.isSafeInteger(length) || length > v1.MAX_PACKET_SIZE) { // Maximum request packet is 64MB
|
|
103
|
+
|
|
104
|
+
refuseBadRequest(resp);
|
|
105
|
+
this.emit('error', new Shared.errors.invalid_packet({
|
|
106
|
+
reason: 'invalid_packet_length',
|
|
107
|
+
data: {
|
|
108
|
+
'length': length,
|
|
109
|
+
'max': v1.MAX_PACKET_SIZE,
|
|
110
|
+
},
|
|
111
|
+
}));
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const buf: Buffer = Buffer.allocUnsafe(length);
|
|
116
|
+
|
|
117
|
+
let offset: number = 0;
|
|
118
|
+
|
|
119
|
+
const recvAt = Date.now();
|
|
120
|
+
|
|
121
|
+
resp.on('error', (e) => this.emit('error', e));
|
|
122
|
+
|
|
123
|
+
req.on('error', (e) => this.emit('error', e))
|
|
124
|
+
.on('data', (chunk: Buffer) => {
|
|
125
|
+
|
|
126
|
+
const index = offset;
|
|
127
|
+
|
|
128
|
+
offset += chunk.byteLength;
|
|
129
|
+
|
|
130
|
+
if (offset > length) {
|
|
131
|
+
|
|
132
|
+
refuseBadRequest(resp);
|
|
133
|
+
this.emit('error', new Shared.errors.invalid_packet({
|
|
134
|
+
reason: 'length_exceeded',
|
|
135
|
+
recv: offset,
|
|
136
|
+
expected: length,
|
|
137
|
+
}));
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
chunk.copy(buf, index);
|
|
142
|
+
})
|
|
143
|
+
.on('end', () => {
|
|
144
|
+
|
|
145
|
+
let input: any;
|
|
146
|
+
|
|
147
|
+
if (offset !== length || buf[0] !== 123 || buf[offset - 1] !== 125) {
|
|
148
|
+
|
|
149
|
+
refuseBadRequest(resp);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
try {
|
|
154
|
+
|
|
155
|
+
input = JSON.parse(buf as any);
|
|
156
|
+
}
|
|
157
|
+
catch (e) {
|
|
158
|
+
|
|
159
|
+
refuseBadRequest(resp);
|
|
160
|
+
this.emit('error', new Shared.errors.invalid_packet({
|
|
161
|
+
reason: 'invalid_json',
|
|
162
|
+
data: buf,
|
|
163
|
+
}, e));
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (typeof input?.api !== 'string') {
|
|
168
|
+
|
|
169
|
+
refuseBadRequest(resp);
|
|
170
|
+
this.emit('error', new Shared.errors.invalid_packet({
|
|
171
|
+
reason: 'malformed_json',
|
|
172
|
+
data: input,
|
|
173
|
+
}));
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
this._server.processLegacyApi((result) => {
|
|
178
|
+
|
|
179
|
+
if (!resp.writable) {
|
|
180
|
+
|
|
181
|
+
return;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
if (result instanceof Shared.TelevokeError) {
|
|
185
|
+
|
|
186
|
+
if (result instanceof Shared.errors.app_error) {
|
|
187
|
+
|
|
188
|
+
const data = encoder.encodeApiErrorResponse(
|
|
189
|
+
input.rid,
|
|
190
|
+
v1.EResponseCode.FAILURE,
|
|
191
|
+
result.message,
|
|
192
|
+
recvAt
|
|
193
|
+
);
|
|
194
|
+
|
|
195
|
+
resp.setHeader('content-length', Buffer.byteLength(data));
|
|
196
|
+
resp.end(data);
|
|
197
|
+
}
|
|
198
|
+
else if (result instanceof Shared.errors.api_not_found) {
|
|
199
|
+
|
|
200
|
+
const data = encoder.encodeApiErrorResponse(
|
|
201
|
+
input.rid,
|
|
202
|
+
v1.EResponseCode.API_NOT_FOUND,
|
|
203
|
+
'null',
|
|
204
|
+
recvAt
|
|
205
|
+
);
|
|
206
|
+
|
|
207
|
+
resp.setHeader('content-length', Buffer.byteLength(data));
|
|
208
|
+
resp.end(data);
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
|
|
212
|
+
const data = encoder.encodeApiErrorResponse(
|
|
213
|
+
input.rid,
|
|
214
|
+
v1.EResponseCode.SYSTEM_ERROR,
|
|
215
|
+
'null',
|
|
216
|
+
recvAt
|
|
217
|
+
);
|
|
218
|
+
|
|
219
|
+
resp.setHeader('content-length', Buffer.byteLength(data));
|
|
220
|
+
resp.end(data);
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const data = encoder.encodeApiOkResponse(input.rid, result ?? null, recvAt);
|
|
227
|
+
|
|
228
|
+
resp.setHeader('content-length', Buffer.byteLength(data));
|
|
229
|
+
resp.end(data);
|
|
230
|
+
|
|
231
|
+
}, input.api, input.args, new LegacyHttpTransporter(req));
|
|
232
|
+
});
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
public async start(): Promise<void> {
|
|
236
|
+
|
|
237
|
+
if (this.running) {
|
|
238
|
+
|
|
239
|
+
return;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
await this._listener.start();
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
public async stop(): Promise<void> {
|
|
246
|
+
|
|
247
|
+
if (!this.running) {
|
|
248
|
+
|
|
249
|
+
return Promise.resolve();
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
await this._listener.stop();
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
export function createLegacyHttpGateway(
|
|
257
|
+
listener: Listener.IHttpListener,
|
|
258
|
+
server: dT.IServer
|
|
259
|
+
): dT.IGateway {
|
|
260
|
+
|
|
261
|
+
return new LegacyHttpGateway(listener, server);
|
|
262
|
+
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as Http from 'node:http';
|
|
18
|
+
import type * as Shared from '../../shared';
|
|
19
|
+
|
|
20
|
+
const PROPERTY_NAMES = ['remoteAddress', 'remotePort', 'localAddress', 'localPort', 'url', 'headers'];
|
|
21
|
+
|
|
22
|
+
export class LegacyHttpTransporter implements Shared.ITransporter {
|
|
23
|
+
|
|
24
|
+
public readonly protocol = 'http';
|
|
25
|
+
|
|
26
|
+
public constructor(
|
|
27
|
+
private readonly _req: Http.IncomingMessage,
|
|
28
|
+
) {
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public readonly writable = false;
|
|
33
|
+
|
|
34
|
+
public getPropertyNames(): string[] {
|
|
35
|
+
|
|
36
|
+
return PROPERTY_NAMES;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
public getAllProperties(): Record<string, unknown> {
|
|
40
|
+
|
|
41
|
+
return {
|
|
42
|
+
'remoteAddress': this._req.socket.remoteAddress,
|
|
43
|
+
'remotePort': this._req.socket.remotePort,
|
|
44
|
+
'localAddress': this._req.socket.localAddress,
|
|
45
|
+
'localPort': this._req.socket.localPort,
|
|
46
|
+
'url': this._req.url,
|
|
47
|
+
'headers': this._req.headers,
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public getProperty(name: string): unknown {
|
|
52
|
+
|
|
53
|
+
switch (name) {
|
|
54
|
+
case 'localPort':
|
|
55
|
+
case 'localAddress':
|
|
56
|
+
case 'remotePort':
|
|
57
|
+
case 'remoteAddress':
|
|
58
|
+
return this._req.socket[name];
|
|
59
|
+
case 'url':
|
|
60
|
+
case 'headers':
|
|
61
|
+
return this._req[name];
|
|
62
|
+
default:
|
|
63
|
+
return undefined;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
export * from './LegacyHttp.Server';
|
|
18
|
+
export * from './LegacyHttp.Transporter';
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as LwDFX from '@litert/lwdfx';
|
|
18
|
+
import type * as dT from '../Transporter.decl';
|
|
19
|
+
import { LwDFXTransporter } from './LwDFX.Transporter';
|
|
20
|
+
|
|
21
|
+
class LwDfxTcpConnector implements dT.IConnector {
|
|
22
|
+
|
|
23
|
+
public constructor(private readonly _opts: LwDFX.Tcp.ITcpClientOptions) {}
|
|
24
|
+
|
|
25
|
+
public async connect(): Promise<dT.ITransporter> {
|
|
26
|
+
|
|
27
|
+
return new LwDFXTransporter('lwdfx/tcp', await LwDFX.Tcp.connect(this._opts));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function createTcpConnector(opts: LwDFX.Tcp.ITcpClientOptions): dT.IConnector {
|
|
32
|
+
|
|
33
|
+
return new LwDfxTcpConnector(opts);
|
|
34
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as LwDFX from '@litert/lwdfx';
|
|
18
|
+
import type * as dT from '../Transporter.decl';
|
|
19
|
+
import { EventEmitter } from 'node:events';
|
|
20
|
+
import { LwDFXTransporter } from './LwDFX.Transporter';
|
|
21
|
+
import type * as dL from './LwDFX.decl';
|
|
22
|
+
|
|
23
|
+
export type ILwDfxTcpGatewayOptions = LwDFX.Tcp.ITcpGatewayOptions;
|
|
24
|
+
|
|
25
|
+
class LwDfxTcpGateway extends EventEmitter implements dT.IGateway {
|
|
26
|
+
|
|
27
|
+
private _gateway: LwDFX.Tcp.ITcpGateway | null = null;
|
|
28
|
+
|
|
29
|
+
private readonly _lwdfxServer: LwDFX.IServer;
|
|
30
|
+
|
|
31
|
+
public constructor(
|
|
32
|
+
serverOpts: dL.ILwDfxServerOptions,
|
|
33
|
+
private readonly _gatewayOpts: ILwDfxTcpGatewayOptions,
|
|
34
|
+
private readonly _server: dT.IServer,
|
|
35
|
+
) {
|
|
36
|
+
|
|
37
|
+
super();
|
|
38
|
+
|
|
39
|
+
this._lwdfxServer = LwDFX.createServer({
|
|
40
|
+
...serverOpts,
|
|
41
|
+
alpWhitelist: ['televoke2']
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
this._lwdfxServer.on('connection', (conn) => {
|
|
45
|
+
|
|
46
|
+
this._server.registerChannel(new LwDFXTransporter('lwdfx/tcp', conn));
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public get running(): boolean {
|
|
51
|
+
|
|
52
|
+
return !!this._gateway;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async start(): Promise<void> {
|
|
56
|
+
|
|
57
|
+
if (this._gateway) {
|
|
58
|
+
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this._gateway = LwDFX.Tcp.createGateway(this._lwdfxServer, this._gatewayOpts);
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
|
|
66
|
+
await this._gateway.start();
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
|
|
70
|
+
this._gateway = null;
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public async stop(): Promise<void> {
|
|
76
|
+
|
|
77
|
+
if (!this._gateway) {
|
|
78
|
+
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
await this._gateway.stop();
|
|
83
|
+
this._gateway = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function createTcpGateway(
|
|
88
|
+
server: dT.IServer,
|
|
89
|
+
gatewayOpts: ILwDfxTcpGatewayOptions = {},
|
|
90
|
+
serverOpts: dL.ILwDfxServerOptions = {},
|
|
91
|
+
): dT.IGateway {
|
|
92
|
+
|
|
93
|
+
return new LwDfxTcpGateway(serverOpts, gatewayOpts, server);
|
|
94
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as LwDFX from '@litert/lwdfx';
|
|
18
|
+
import type * as dT from '../Transporter.decl';
|
|
19
|
+
import { LwDFXTransporter } from './LwDFX.Transporter';
|
|
20
|
+
|
|
21
|
+
class LwDfxTlsConnector implements dT.IConnector {
|
|
22
|
+
|
|
23
|
+
public constructor(private readonly _opts: LwDFX.Tls.ITlsClientOptions) {}
|
|
24
|
+
|
|
25
|
+
public async connect(): Promise<dT.ITransporter> {
|
|
26
|
+
|
|
27
|
+
return new LwDFXTransporter('lwdfx/tls', await LwDFX.Tls.connect(this._opts));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export function createTlsConnector(opts: LwDFX.Tls.ITlsClientOptions): dT.IConnector {
|
|
32
|
+
|
|
33
|
+
return new LwDfxTlsConnector(opts);
|
|
34
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as LwDFX from '@litert/lwdfx';
|
|
18
|
+
import type * as dT from '../Transporter.decl';
|
|
19
|
+
import type * as dL from './LwDFX.decl';
|
|
20
|
+
import { EventEmitter } from 'node:events';
|
|
21
|
+
import { LwDFXTransporter } from './LwDFX.Transporter';
|
|
22
|
+
|
|
23
|
+
export type ILwDfxTlsGatewayOptions = LwDFX.Tls.ITlsGatewayOptions;
|
|
24
|
+
|
|
25
|
+
class LwDfxTlsGateway extends EventEmitter implements dT.IGateway {
|
|
26
|
+
|
|
27
|
+
private _gateway: LwDFX.Tls.ITlsGateway | null = null;
|
|
28
|
+
|
|
29
|
+
private readonly _lwdfxServer: LwDFX.IServer;
|
|
30
|
+
|
|
31
|
+
public constructor(
|
|
32
|
+
serverOpts: dL.ILwDfxServerOptions,
|
|
33
|
+
private readonly _gatewayOpts: ILwDfxTlsGatewayOptions,
|
|
34
|
+
private readonly _server: dT.IServer,
|
|
35
|
+
) {
|
|
36
|
+
|
|
37
|
+
super();
|
|
38
|
+
|
|
39
|
+
this._lwdfxServer = LwDFX.createServer({
|
|
40
|
+
...serverOpts,
|
|
41
|
+
alpWhitelist: ['televoke2']
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
this._lwdfxServer.on('connection', (conn) => {
|
|
45
|
+
|
|
46
|
+
this._server.registerChannel(new LwDFXTransporter('lwdfx/tls', conn));
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public get running(): boolean {
|
|
51
|
+
|
|
52
|
+
return !!this._gateway;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public async start(): Promise<void> {
|
|
56
|
+
|
|
57
|
+
if (this._gateway) {
|
|
58
|
+
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this._gateway = LwDFX.Tls.createGateway(this._lwdfxServer, this._gatewayOpts);
|
|
63
|
+
|
|
64
|
+
try {
|
|
65
|
+
|
|
66
|
+
await this._gateway.start();
|
|
67
|
+
}
|
|
68
|
+
catch (e) {
|
|
69
|
+
|
|
70
|
+
this._gateway = null;
|
|
71
|
+
throw e;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
public async stop(): Promise<void> {
|
|
76
|
+
|
|
77
|
+
if (!this._gateway) {
|
|
78
|
+
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
await this._gateway.stop();
|
|
83
|
+
this._gateway = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function createTlsGateway(
|
|
88
|
+
server: dT.IServer,
|
|
89
|
+
gatewayOpts: ILwDfxTlsGatewayOptions,
|
|
90
|
+
serverOpts: dL.ILwDfxServerOptions = {},
|
|
91
|
+
): dT.IGateway {
|
|
92
|
+
|
|
93
|
+
return new LwDfxTlsGateway(serverOpts, gatewayOpts, server);
|
|
94
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright 2023 Angus.Fenying <fenying@litert.org>
|
|
3
|
+
*
|
|
4
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
* you may not use this file except in compliance with the License.
|
|
6
|
+
* You may obtain a copy of the License at
|
|
7
|
+
*
|
|
8
|
+
* https://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
*
|
|
10
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
* See the License for the specific language governing permissions and
|
|
14
|
+
* limitations under the License.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
import * as LwDFX from '@litert/lwdfx';
|
|
18
|
+
import * as Shared from '../../shared';
|
|
19
|
+
import type * as dT from '../Transporter.decl';
|
|
20
|
+
import { EventEmitter } from 'node:events';
|
|
21
|
+
|
|
22
|
+
const PROPERTY_NAMES = ['remoteAddress', 'remotePort', 'localAddress', 'localPort'];
|
|
23
|
+
|
|
24
|
+
export class LwDFXTransporter extends EventEmitter implements dT.ITransporter, Shared.ITransporter {
|
|
25
|
+
|
|
26
|
+
public constructor(
|
|
27
|
+
public readonly protocol: string,
|
|
28
|
+
protected readonly _conn: LwDFX.IConnection
|
|
29
|
+
) {
|
|
30
|
+
super();
|
|
31
|
+
|
|
32
|
+
this._conn
|
|
33
|
+
.on('end', () => this.emit('end'))
|
|
34
|
+
.on('finish', () => this.emit('finish'))
|
|
35
|
+
.on('frame', (data) => this.emit('frame', data))
|
|
36
|
+
.on('error', (e) => this.emit('error', e))
|
|
37
|
+
.on('close', () => this.emit('close'));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public destroy(): void {
|
|
41
|
+
|
|
42
|
+
this._conn.destroy();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
public getPropertyNames(): string[] {
|
|
46
|
+
|
|
47
|
+
return PROPERTY_NAMES;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public getAllProperties(): Record<string, unknown> {
|
|
51
|
+
|
|
52
|
+
return {
|
|
53
|
+
'remoteAddress': this._conn.remoteAddress,
|
|
54
|
+
'remotePort': this._conn.remotePort,
|
|
55
|
+
'localAddress': this._conn.localAddress,
|
|
56
|
+
'localPort': this._conn.localPort,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
public getProperty(name: string): unknown {
|
|
61
|
+
|
|
62
|
+
switch (name) {
|
|
63
|
+
case 'localPort':
|
|
64
|
+
case 'localAddress':
|
|
65
|
+
case 'remotePort':
|
|
66
|
+
case 'remoteAddress':
|
|
67
|
+
return this._conn[name];
|
|
68
|
+
default:
|
|
69
|
+
return undefined;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
public get writable(): boolean {
|
|
74
|
+
|
|
75
|
+
return this._conn.connected;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
public write(frame: string | Buffer | Array<string | Buffer>): void {
|
|
79
|
+
|
|
80
|
+
if (!this._conn.writable) {
|
|
81
|
+
|
|
82
|
+
throw new Shared.errors.network_error({ reason: 'conn_lost' });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
this._conn.write(frame);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public end(frame?: Buffer | string): void {
|
|
89
|
+
|
|
90
|
+
if (this._conn.writable) {
|
|
91
|
+
|
|
92
|
+
if (frame) {
|
|
93
|
+
|
|
94
|
+
this._conn.write(frame);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
this._conn.end();
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|